]> git.sesse.net Git - vlc/blob - src/ac3_decoder/ac3_bit_stream.h
Created a small&clean public interface for the ac3 decoder (see ac3_decoder.h)
[vlc] / src / ac3_decoder / ac3_bit_stream.h
1 static __inline__ u8 GetByte (ac3_byte_stream_t * p_byte_stream)
2 {
3     /* Are there some bytes left in the current buffer ? */
4     if (p_byte_stream->p_byte >= p_byte_stream->p_end) {
5         /* no, switch to next buffer */
6         ac3_byte_stream_next (p_byte_stream);
7     }
8
9     return *(p_byte_stream->p_byte++);
10 }
11
12 static __inline__ void NeedBits (ac3_bit_stream_t * p_bit_stream, int i_bits)
13 {
14     while (p_bit_stream->i_available < i_bits) {
15         p_bit_stream->buffer |=
16             ((u32)GetByte (&p_bit_stream->byte_stream)) << (24 - p_bit_stream->i_available);
17         p_bit_stream->i_available += 8;
18     }
19 }
20
21 static __inline__ void DumpBits (ac3_bit_stream_t * p_bit_stream, int i_bits)
22 {
23     p_bit_stream->buffer <<= i_bits;
24     p_bit_stream->i_available -= i_bits;
25     p_bit_stream->total_bits_read += i_bits;
26 }