]> git.sesse.net Git - vlc/blob - plugins/ac3_adec/ac3_mantissa.c
* ALL: got rid of p_object->p_this which is now useless.
[vlc] / plugins / ac3_adec / ac3_mantissa.c
1 /*****************************************************************************
2  * ac3_mantissa.c: ac3 mantissa computation
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  * $Id: ac3_mantissa.c,v 1.7 2002/06/01 12:31:58 sam Exp $
6  *
7  * Authors: Michel Kaempf <maxx@via.ecp.fr>
8  *          Aaron Holtzman <aholtzma@engr.uvic.ca>
9  *          Renaud Dartus <reno@videolan.org>
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 /*****************************************************************************
27  * Preamble
28  *****************************************************************************/
29 #include <string.h>                                              /* memcpy() */
30
31 #include <vlc/vlc.h>
32 #include <vlc/decoder.h>
33
34 #include "ac3_imdct.h"
35 #include "ac3_downmix.h"
36 #include "ac3_adec.h"
37
38 #include "ac3_mantissa.h"
39
40 void mantissa_unpack (ac3dec_t * p_ac3dec)
41 {
42     int i, j;
43     u32 done_cpl = 0;
44
45     p_ac3dec->mantissa.q_1_pointer = -1;
46     p_ac3dec->mantissa.q_2_pointer = -1;
47     p_ac3dec->mantissa.q_4_pointer = -1;
48
49     for (i=0; i< p_ac3dec->bsi.nfchans; i++) {
50         for (j=0; j < p_ac3dec->audblk.endmant[i]; j++)
51             *(p_ac3dec->samples+i*256+j) = coeff_get_float(p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j],
52                     p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j]);
53
54         if (p_ac3dec->audblk.cplinu && p_ac3dec->audblk.chincpl[i] && !(done_cpl)) {
55         /* ncplmant is equal to 12 * ncplsubnd
56          * Don't dither coupling channel until channel
57          * separation so that interchannel noise is uncorrelated 
58          */
59             for (j=p_ac3dec->audblk.cplstrtmant; j < p_ac3dec->audblk.cplendmant; j++)
60                 p_ac3dec->audblk.cpl_flt[j] = coeff_get_float(p_ac3dec, p_ac3dec->audblk.cpl_bap[j],
61                         0, p_ac3dec->audblk.cpl_exp[j]);
62             done_cpl = 1;
63         }
64     }
65     
66     /* uncouple the channel if necessary */
67     if (p_ac3dec->audblk.cplinu) {
68         for (i=0; i< p_ac3dec->bsi.nfchans; i++) {
69             if (p_ac3dec->audblk.chincpl[i])
70                 uncouple_channel(p_ac3dec, i);
71         }
72     }
73
74     if (p_ac3dec->bsi.lfeon) {
75         /* There are always 7 mantissas for lfe, no dither for lfe */
76         for (j=0; j < 7 ; j++)
77             *(p_ac3dec->samples+5*256+j) = coeff_get_float(p_ac3dec, p_ac3dec->audblk.lfe_bap[j],
78                     0, p_ac3dec->audblk.lfe_exp[j]);
79     }
80 }
81