1 /*****************************************************************************
2 * ac3_bit_stream.h: getbits functions for the ac3 decoder
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
6 * Authors: Michel Lespinasse <walken@zoy.org>
7 * Renaud Dartus <reno@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 static __inline__ u32 bitstream_get (ac3_bit_stream_t * p_bit_stream,
29 while (p_bit_stream->i_available < num_bits)
31 if (p_bit_stream->byte_stream.p_byte >= p_bit_stream->byte_stream.p_end)
33 ac3dec_thread_t * p_ac3dec = p_bit_stream->byte_stream.info;
35 /* no, switch to next buffer */
36 if(!p_ac3dec->p_fifo->b_die)
37 ac3_byte_stream_next (&p_bit_stream->byte_stream);
39 p_bit_stream->buffer |=((u32) *(p_bit_stream->byte_stream.p_byte++))
40 << (24 - p_bit_stream->i_available);
41 p_bit_stream->i_available += 8;
43 result = p_bit_stream->buffer >> (32 - num_bits);
44 p_bit_stream->buffer <<= num_bits;
45 p_bit_stream->i_available -= num_bits;
46 p_bit_stream->total_bits_read += num_bits;