]> git.sesse.net Git - vlc/blob - src/audio_decoder/adec_bit_stream.h
. split the audio decoder into adec_generic, adec_layer1 and adec_layer2
[vlc] / src / audio_decoder / adec_bit_stream.h
1 /*****************************************************************************
2  * audio_bit_stream.h: getbits functions for the audio decoder
3  *****************************************************************************
4  * Copyright (C) 2000 VideoLAN
5  *
6  * Authors:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 static __inline__ u8 GetByte (adec_bit_stream_t * p_bit_stream)
24 {
25     /* Are there some bytes left in the current buffer ? */
26     if (p_bit_stream->byte_stream.p_byte >= p_bit_stream->byte_stream.p_end) {
27         /* no, switch to next buffer */
28         adec_byte_stream_next (&p_bit_stream->byte_stream);
29     }
30
31     p_bit_stream->total_bytes_read++;
32
33     return *(p_bit_stream->byte_stream.p_byte++);
34 }
35
36 static __inline__ void NeedBits (adec_bit_stream_t * p_bit_stream, int i_bits)
37 {
38     while (p_bit_stream->i_available < i_bits) {
39         p_bit_stream->buffer |=
40             ((u32)GetByte (p_bit_stream)) << (24 - p_bit_stream->i_available);
41         p_bit_stream->i_available += 8;
42     }
43 }
44
45 static __inline__ void DumpBits (adec_bit_stream_t * p_bit_stream, int i_bits)
46 {
47     p_bit_stream->buffer <<= i_bits;
48     p_bit_stream->i_available -= i_bits;
49 }