1 /*****************************************************************************
2 * ac3_mantissa.c: ac3 mantissa computation
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: ac3_mantissa.c,v 1.1 2001/11/13 12:09:17 henri Exp $
7 * Authors: Michel Kaempf <maxx@via.ecp.fr>
8 * Aaron Holtzman <aholtzma@engr.uvic.ca>
9 * Renaud Dartus <reno@videolan.org>
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 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
31 #include <string.h> /* memcpy() */
39 #include "audio_output.h"
41 #include "modules_export.h"
43 #include "stream_control.h"
44 #include "input_ext-dec.h"
47 #include "ac3_imdct.h"
48 #include "ac3_downmix.h"
49 #include "ac3_decoder.h"
51 #include "ac3_mantissa.h"
53 void mantissa_unpack (ac3dec_t * p_ac3dec)
58 p_ac3dec->mantissa.q_1_pointer = -1;
59 p_ac3dec->mantissa.q_2_pointer = -1;
60 p_ac3dec->mantissa.q_4_pointer = -1;
62 for (i=0; i< p_ac3dec->bsi.nfchans; i++) {
63 for (j=0; j < p_ac3dec->audblk.endmant[i]; j++)
64 *(p_ac3dec->samples+i*256+j) = coeff_get_float(p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j],
65 p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j]);
67 if (p_ac3dec->audblk.cplinu && p_ac3dec->audblk.chincpl[i] && !(done_cpl)) {
68 /* ncplmant is equal to 12 * ncplsubnd
69 * Don't dither coupling channel until channel
70 * separation so that interchannel noise is uncorrelated
72 for (j=p_ac3dec->audblk.cplstrtmant; j < p_ac3dec->audblk.cplendmant; j++)
73 p_ac3dec->audblk.cpl_flt[j] = coeff_get_float(p_ac3dec, p_ac3dec->audblk.cpl_bap[j],
74 0, p_ac3dec->audblk.cpl_exp[j]);
79 /* uncouple the channel if necessary */
80 if (p_ac3dec->audblk.cplinu) {
81 for (i=0; i< p_ac3dec->bsi.nfchans; i++) {
82 if (p_ac3dec->audblk.chincpl[i])
83 uncouple_channel(p_ac3dec, i);
87 if (p_ac3dec->bsi.lfeon) {
88 /* There are always 7 mantissas for lfe, no dither for lfe */
89 for (j=0; j < 7 ; j++)
90 *(p_ac3dec->samples+5*256+j) = coeff_get_float(p_ac3dec, p_ac3dec->audblk.lfe_bap[j],
91 0, p_ac3dec->audblk.lfe_exp[j]);