Commit 82671ab5 authored by Petri Hintukainen's avatar Petri Hintukainen

bits: avoid using too wide type

i_left is used to store values between 0 and 7.
parent 9204d795
......@@ -73,7 +73,7 @@ void bb_seek( BITBUFFER *bb, int64_t off, int whence)
b = off >> 3;
bb->p = &bb->p_start[b];
ssize_t i_tmp = bb->i_left - (off & 0x07);
int i_tmp = bb->i_left - (off & 0x07);
if (i_tmp <= 0) {
bb->i_left = 8 + i_tmp;
bb->p++;
......@@ -168,7 +168,7 @@ uint32_t bb_read( BITBUFFER *bb, int i_count )
uint32_t bs_read( BITSTREAM *bs, int i_count )
{
ssize_t left;
int left;
int bytes = (i_count + 7) >> 3;
if (bs->bb.p + bytes >= bs->bb.p_end) {
......@@ -184,13 +184,12 @@ uint32_t bs_read( BITSTREAM *bs, int i_count )
void bb_skip( BITBUFFER *bb, size_t i_count )
{
bb->i_left -= i_count;
bb->p += i_count >> 3;
bb->i_left -= i_count & 0x07;
if( bb->i_left <= 0 ) {
const int i_bytes = ( -bb->i_left + 8 ) / 8;
bb->p += i_bytes;
bb->i_left += 8 * i_bytes;
bb->p++;
bb->i_left += 8;
}
}
......
......@@ -28,7 +28,7 @@
#include <stdint.h>
#include <stdio.h> // SEEK_*
#include <sys/types.h> // *size_t
#include <stddef.h> // size_t
/**
......@@ -43,7 +43,7 @@ typedef struct {
const uint8_t *p;
const uint8_t *p_end;
ssize_t i_left; /* i_count number of available bits */
int i_left; /* i_count number of available bits */
} BITBUFFER;
typedef struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment