]> git.sesse.net Git - vlc/blob - src/audio_decoder/audio_bit_stream.h
reecriture du deco mpeg audio
[vlc] / src / audio_decoder / audio_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 GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with this program; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *****************************************************************************/
23
24 static __inline__ u8 GetByte (adec_bit_stream_t * p_bit_stream)
25 {
26     /* Are there some bytes left in the current buffer ? */
27     if (p_bit_stream->byte_stream.p_byte >= p_bit_stream->byte_stream.p_end) {
28         /* no, switch to next buffer */
29         adec_byte_stream_next (&p_bit_stream->byte_stream);
30     }
31
32     p_bit_stream->total_bytes_read++;
33
34     return *(p_bit_stream->byte_stream.p_byte++);
35 }
36
37 static __inline__ void NeedBits (adec_bit_stream_t * p_bit_stream, int i_bits)
38 {
39     while (p_bit_stream->i_available < i_bits) {
40         p_bit_stream->buffer |=
41             ((u32)GetByte (p_bit_stream)) << (24 - p_bit_stream->i_available);
42         p_bit_stream->i_available += 8;
43     }
44 }
45
46 static __inline__ void DumpBits (adec_bit_stream_t * p_bit_stream, int i_bits)
47 {
48     p_bit_stream->buffer <<= i_bits;
49     p_bit_stream->i_available -= i_bits;
50 }