]> git.sesse.net Git - vlc/blob - src/ac3_decoder/ac3_decoder.c
* Header cleaning: filled all empty authors fields, added CVS $Id stuff.
[vlc] / src / ac3_decoder / ac3_decoder.c
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 $
6  *
7  * Authors: Michel Kaempf <maxx@via.ecp.fr>
8  *          Michel Lespinasse <walken@zoy.org>
9  *          Aaron Holtzman <aholtzma@engr.uvic.ca>
10  *
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.
15  * 
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.
20  *
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  *****************************************************************************/
25
26 #include "defs.h"
27
28 #include "int_types.h"
29 #include "ac3_decoder.h"
30 #include "ac3_internal.h"
31
32 #include <stdio.h>
33
34 void imdct_init (imdct_t * p_imdct);
35
36 int ac3_init (ac3dec_t * p_ac3dec)
37 {
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);
42     
43     return 0;
44 }
45
46 int ac3_decode_frame (ac3dec_t * p_ac3dec, s16 * buffer)
47 {
48     int i;
49     
50     if (parse_bsi (p_ac3dec))
51         return 1;
52     
53     for (i = 0; i < 6; i++) {
54         if (parse_audblk (p_ac3dec, i))
55             return 1;
56         if (exponent_unpack (p_ac3dec))
57             return 1;
58         bit_allocate (p_ac3dec);
59         mantissa_unpack (p_ac3dec);
60         if  (p_ac3dec->bsi.acmod == 0x2)
61             rematrix (p_ac3dec);
62         imdct (p_ac3dec, buffer);
63 //        downmix (p_ac3dec, buffer);
64
65         buffer += 2*256;
66     }
67
68     parse_auxdata (p_ac3dec);
69
70     return 0;
71 }