Go to the documentation of this file.
45 uint8_t *(*pf_forward)(uint8_t *, uint8_t *,
void *, size_t);
60 static inline void bs_init(
bs_t *s,
const void *p_data,
size_t i_data )
81 return( s->
p >= s->
p_end ? 1: 0 );
84 #define bs_forward( s, i ) \
85 s->p = s->pf_forward ? s->pf_forward( s->p, s->p_end, s->p_fwpriv, i ) : s->p + i
89 static const uint32_t i_mask[33] =
91 0x01, 0x03, 0x07, 0x0f,
92 0x1f, 0x3f, 0x7f, 0xff,
93 0x1ff, 0x3ff, 0x7ff, 0xfff,
94 0x1fff, 0x3fff, 0x7fff, 0xffff,
95 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff,
96 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff,
97 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff,
98 0x1fffffff,0x3fffffff,0x7fffffff,0xffffffff};
99 int i_shr, i_drop = 0;
100 uint32_t i_result = 0;
104 i_drop = i_count - 32;
115 if( ( i_shr = s->
i_left - i_count ) >= 0 )
118 i_result |= ( *s->
p >> i_shr )&i_mask[i_count];
133 i_result |= (*s->
p&i_mask[s->
i_left]) << -i_shr;
150 unsigned int i_result;
153 i_result = ( *s->
p >> s->
i_left )&0x01;
168 return bs_read( &s_tmp, i_count );
177 const size_t i_bytes = 1 + s->
i_left / -8;
179 if( i_bytes * 8 < i_bytes )
200 if( ( i_bits >> i_count )&0x01 )
202 *s->
p |= 1 << ( s->
i_left - 1 );
206 *s->
p &= ~( 1 << ( s->
i_left - 1 ) );
219 return s->
i_left % 8 == 0;
255 return (1U << i) - 1 +
bs_read( bs, i );
263 return (val & 0x01) ? (int_fast32_t)((val + 1) / 2)
264 : -(int_fast32_t)(val / 2);
static uint32_t bs_read1(bs_t *s)
Definition: vlc_bits.h:146
uint8_t * p_start
Definition: vlc_bits.h:37
static void bs_align(bs_t *s)
Definition: vlc_bits.h:222
static void bs_init(bs_t *s, const void *p_data, size_t i_data)
Definition: vlc_bits.h:60
void * p_fwpriv
Definition: vlc_bits.h:46
Definition: vlc_bits.h:35
uint8_t *(* pf_forward)(uint8_t *, uint8_t *, void *, size_t)
Definition: vlc_bits.h:45
bool b_read_only
Definition: vlc_bits.h:42
static uint32_t bs_show(bs_t *s, int i_count)
Definition: vlc_bits.h:165
ssize_t i_left
Definition: vlc_bits.h:41
#define bs_forward(s, i)
Definition: vlc_bits.h:84
static void bs_write_init(bs_t *s, void *p_data, size_t i_data)
Definition: vlc_bits.h:49
static int bs_pos(const bs_t *s)
Definition: vlc_bits.h:66
static int bs_remain(const bs_t *s)
Definition: vlc_bits.h:71
static uint_fast32_t bs_read_ue(bs_t *bs)
Definition: vlc_bits.h:248
static void bs_write(bs_t *s, int i_count, uint32_t i_bits)
Definition: vlc_bits.h:186
static bool bs_aligned(bs_t *s)
Definition: vlc_bits.h:217
static void bs_skip(bs_t *s, ssize_t i_count)
Definition: vlc_bits.h:171
uint8_t * p
Definition: vlc_bits.h:38
static uint32_t bs_read(bs_t *s, int i_count)
Definition: vlc_bits.h:87
uint8_t * p_end
Definition: vlc_bits.h:39
static void bs_align_1(bs_t *s)
Definition: vlc_bits.h:239
static int_fast32_t bs_read_se(bs_t *s)
Definition: vlc_bits.h:259
static void bs_align_0(bs_t *s)
Definition: vlc_bits.h:231
static int bs_eof(const bs_t *s)
Definition: vlc_bits.h:79