ac3_mantissa.c 3.36 KB
Newer Older
1 2 3
/*****************************************************************************
 * ac3_mantissa.c: ac3 mantissa computation
 *****************************************************************************
Renaud Dartus's avatar
Renaud Dartus committed
4
 * Copyright (C) 1999, 2000, 2001 VideoLAN
Gildas Bazin's avatar
 
Gildas Bazin committed
5
 * $Id: ac3_mantissa.c,v 1.2 2001/11/25 22:52:21 gbazin Exp $
6
 *
Renaud Dartus's avatar
Renaud Dartus committed
7
 * Authors: Michel Kaempf <maxx@via.ecp.fr>
8
 *          Aaron Holtzman <aholtzma@engr.uvic.ca>
Renaud Dartus's avatar
Renaud Dartus committed
9
 *          Renaud Dartus <reno@videolan.org>
10 11 12 13 14
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
15
 * 
16 17
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
20
 *
21 22 23
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24
 *****************************************************************************/
Renaud Dartus's avatar
Renaud Dartus committed
25

Sam Hocevar's avatar
 
Sam Hocevar committed
26 27 28
/*****************************************************************************
 * Preamble
 *****************************************************************************/
29
#include "defs.h"
30

Sam Hocevar's avatar
 
Sam Hocevar committed
31 32
#include <string.h>                                              /* memcpy() */

33
#include "config.h"
34
#include "common.h"
35 36
#include "threads.h"
#include "mtime.h"
Sam Hocevar's avatar
 
Sam Hocevar committed
37 38
#include "intf_msg.h"

Henri Fallon's avatar
 
Henri Fallon committed
39 40
#include "audio_output.h"

Gildas Bazin's avatar
 
Gildas Bazin committed
41
#include "modules.h"
Henri Fallon's avatar
 
Henri Fallon committed
42 43
#include "modules_export.h"

44 45 46
#include "stream_control.h"
#include "input_ext-dec.h"

47

Sam Hocevar's avatar
 
Sam Hocevar committed
48 49
#include "ac3_imdct.h"
#include "ac3_downmix.h"
50
#include "ac3_decoder.h"
Michel Lespinasse's avatar
 
Michel Lespinasse committed
51

Sam Hocevar's avatar
 
Sam Hocevar committed
52
#include "ac3_mantissa.h"
53

Michel Lespinasse's avatar
 
Michel Lespinasse committed
54
void mantissa_unpack (ac3dec_t * p_ac3dec)
55
{
56
    int i, j;
57
    u32 done_cpl = 0;
58

59 60 61
    p_ac3dec->mantissa.q_1_pointer = -1;
    p_ac3dec->mantissa.q_2_pointer = -1;
    p_ac3dec->mantissa.q_4_pointer = -1;
62

63 64
    for (i=0; i< p_ac3dec->bsi.nfchans; i++) {
        for (j=0; j < p_ac3dec->audblk.endmant[i]; j++)
65
            *(p_ac3dec->samples+i*256+j) = coeff_get_float(p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j],
66
                    p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j]);
67

68 69 70 71 72 73 74 75 76
        if (p_ac3dec->audblk.cplinu && p_ac3dec->audblk.chincpl[i] && !(done_cpl)) {
        /* ncplmant is equal to 12 * ncplsubnd
         * Don't dither coupling channel until channel
         * separation so that interchannel noise is uncorrelated 
         */
            for (j=p_ac3dec->audblk.cplstrtmant; j < p_ac3dec->audblk.cplendmant; j++)
                p_ac3dec->audblk.cpl_flt[j] = coeff_get_float(p_ac3dec, p_ac3dec->audblk.cpl_bap[j],
                        0, p_ac3dec->audblk.cpl_exp[j]);
            done_cpl = 1;
77
        }
Sam Hocevar's avatar
 
Sam Hocevar committed
78
    }
79 80 81 82 83 84
    
    /* uncouple the channel if necessary */
    if (p_ac3dec->audblk.cplinu) {
        for (i=0; i< p_ac3dec->bsi.nfchans; i++) {
            if (p_ac3dec->audblk.chincpl[i])
                uncouple_channel(p_ac3dec, i);
85 86 87
        }
    }

88
    if (p_ac3dec->bsi.lfeon) {
89
        /* There are always 7 mantissas for lfe, no dither for lfe */
90
        for (j=0; j < 7 ; j++)
91
            *(p_ac3dec->samples+5*256+j) = coeff_get_float(p_ac3dec, p_ac3dec->audblk.lfe_bap[j],
92
                    0, p_ac3dec->audblk.lfe_exp[j]);
93
    }
94
}
Sam Hocevar's avatar
 
Sam Hocevar committed
95