]> git.sesse.net Git - vlc/blob - src/ac3_decoder/ac3_bit_stream.h
Encore un commit venu tout droit des abysses de l'enfer, d�sol� pour
[vlc] / src / ac3_decoder / ac3_bit_stream.h
1 /*****************************************************************************
2  * ac3_bit_stream.h: getbits functions for the ac3 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 (ac3_byte_stream_t * p_byte_stream)
25 {
26     /* Are there some bytes left in the current buffer ? */
27     if (p_byte_stream->p_byte >= p_byte_stream->p_end) {
28         /* no, switch to next buffer */
29         ac3_byte_stream_next (p_byte_stream);
30     }
31
32     return *(p_byte_stream->p_byte++);
33 }
34
35 static __inline__ void NeedBits (ac3_bit_stream_t * p_bit_stream, int i_bits)
36 {
37     while (p_bit_stream->i_available < i_bits) {
38         p_bit_stream->buffer |=
39             ((u32)GetByte (&p_bit_stream->byte_stream)) << (24 - p_bit_stream->i_available);
40         p_bit_stream->i_available += 8;
41     }
42 }
43
44 static __inline__ void DumpBits (ac3_bit_stream_t * p_bit_stream, int i_bits)
45 {
46     p_bit_stream->buffer <<= i_bits;
47     p_bit_stream->i_available -= i_bits;
48     p_bit_stream->total_bits_read += i_bits;
49 }