39 size_t (*pf_byte_forward)(
bs_t *, size_t);
40 size_t (*pf_byte_pos)(
const bs_t *);
68 if( (
size_t) (s->
p_end - s->
p) < i_count )
95static inline void bs_init(
bs_t *s,
const void *p_data,
size_t i_data )
106 bs_init( s, (
const void *) p_data, i_data );
120 return s->
i_left > 0 ? 0 : 1;
138static inline void bs_skip(
bs_t *s,
size_t i_count )
153 size_t bytes = i_count / 8;
159 i_count = i_count % 8;
168 else s->
i_left -= i_count;
171static inline uint32_t
bs_read(
bs_t *s, uint8_t i_count )
173 uint8_t i_shr, i_drop = 0;
174 uint32_t i_result = 0;
178 i_drop = i_count - 32;
192 uint_fast32_t mask = (UINT64_C(1) << i_count) - 1;
194 i_shr = s->
i_left - i_count;
196 i_result |= ( *s->
p >> i_shr ) & mask;
202 uint_fast32_t mask = (UINT64_C(1) << s->
i_left) - 1;
204 i_shr = i_count - s->
i_left;
209 i_result |= (*s->
p & mask) << i_shr;
229 return ( *s->
p >> s->
i_left )&0x01;
232static inline void bs_write(
bs_t *s, uint8_t i_count, uint32_t i_bits )
247 if( ( i_bits >> i_count )&0x01 )
249 *s->
p |= 1 << ( s->
i_left - 1 );
253 *s->
p &= ~( 1 << ( s->
i_left - 1 ) );
261 return s->
i_left % 8 == 0;
276#define bs_align_0( s ) bs_write_align( s, 0 )
277#define bs_align_1( s ) bs_write_align( s, 1 )
286 bs->
p < bs->
p_end && i < 31 )
289 return (1U << i) - 1 +
bs_read( bs, i );
297 return (val & 0x01) ? (int_fast32_t)((val + 1) / 2)
298 : -(int_fast32_t)(val / 2);
size_t(* pf_byte_pos)(const bs_t *)
Definition vlc_bits.h:41
size_t(* pf_byte_forward)(bs_t *, size_t)
Definition vlc_bits.h:40
uint8_t * p_end
Definition vlc_bits.h:48
uint8_t * p
Definition vlc_bits.h:47
uint8_t * p_start
Definition vlc_bits.h:46
uint8_t i_left
Definition vlc_bits.h:50
bs_byte_callbacks_t cb
Definition vlc_bits.h:54
bool b_read_only
Definition vlc_bits.h:51
void * p_priv
Definition vlc_bits.h:55
bool b_error
Definition vlc_bits.h:52
static void bs_init_custom(bs_t *s, const void *p_data, size_t i_data, const bs_byte_callbacks_t *cb, void *priv)
Definition vlc_bits.h:83
static size_t bs_impl_bytes_pos(const bs_t *s)
Definition vlc_bits.h:75
static void bs_write(bs_t *s, uint8_t i_count, uint32_t i_bits)
Definition vlc_bits.h:233
struct bs_s bs_t
Definition vlc_bits.h:35
static uint_fast32_t bs_read_ue(bs_t *bs)
Definition vlc_bits.h:281
static uint32_t bs_read1(bs_t *s)
Definition vlc_bits.h:222
static bool bs_aligned(bs_t *s)
Definition vlc_bits.h:260
static size_t bs_impl_bytes_forward(bs_t *s, size_t i_count)
Definition vlc_bits.h:58
static void bs_skip(bs_t *s, size_t i_count)
Definition vlc_bits.h:139
static void bs_write_init(bs_t *s, void *p_data, size_t i_data)
Definition vlc_bits.h:105
static uint32_t bs_read(bs_t *s, uint8_t i_count)
Definition vlc_bits.h:172
static void bs_align(bs_t *s)
Definition vlc_bits.h:265
static bool bs_error(const bs_t *s)
Definition vlc_bits.h:124
static size_t bs_pos(const bs_t *s)
Definition vlc_bits.h:134
static void bs_write_align(bs_t *s, uint8_t v)
Definition vlc_bits.h:271
static int bs_refill(bs_t *s)
Definition vlc_bits.h:111
static bool bs_eof(bs_t *s)
Definition vlc_bits.h:129
static void bs_init(bs_t *s, const void *p_data, size_t i_data)
Definition vlc_bits.h:96
static int_fast32_t bs_read_se(bs_t *s)
Definition vlc_bits.h:294
This file is a collection of common definitions and types.