1 /*****************************************************************************
2 * ac3_decoder.c: core ac3 decoder
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: ac3_decoder.c,v 1.28 2001/03/21 13:42:34 sam Exp $
7 * Authors: Michel Kaempf <maxx@via.ecp.fr>
8 * Michel Lespinasse <walken@zoy.org>
9 * Aaron Holtzman <aholtzma@engr.uvic.ca>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
28 #include "int_types.h"
29 #include "ac3_decoder.h"
30 #include "ac3_internal.h"
34 void imdct_init (imdct_t * p_imdct);
36 int ac3_init (ac3dec_t * p_ac3dec)
38 //p_ac3dec->bit_stream.buffer = 0;
39 //p_ac3dec->bit_stream.i_available = 0;
40 p_ac3dec->mantissa.lfsr_state = 1; /* dither_gen initialization */
41 imdct_init(&p_ac3dec->imdct);
46 int ac3_decode_frame (ac3dec_t * p_ac3dec, s16 * buffer)
50 if (parse_bsi (p_ac3dec))
53 for (i = 0; i < 6; i++) {
54 if (parse_audblk (p_ac3dec, i))
56 if (exponent_unpack (p_ac3dec))
58 bit_allocate (p_ac3dec);
59 mantissa_unpack (p_ac3dec);
60 if (p_ac3dec->bsi.acmod == 0x2)
62 imdct (p_ac3dec, buffer);
63 // downmix (p_ac3dec, buffer);
68 parse_auxdata (p_ac3dec);