Commit a906b2f5 authored by Renaud Dartus's avatar Renaud Dartus
Browse files

* Move ac3 globals variables into structures

* Adding authors
* Prepared to add asm imdct and downmix
parent 1c5f8330
......@@ -218,7 +218,8 @@ AC3_DECODER = src/ac3_decoder/ac3_decoder_thread.o \
src/ac3_decoder/ac3_mantissa.o \
src/ac3_decoder/ac3_rematrix.o \
src/ac3_decoder/ac3_imdct.o \
src/ac3_decoder/ac3_downmix.o
src/ac3_decoder/ac3_downmix.o \
src/ac3_decoder/ac3_downmix_c.o
LPCM_DECODER = src/lpcm_decoder/lpcm_decoder_thread.o \
src/lpcm_decoder/lpcm_decoder.o
......
......@@ -3,7 +3,9 @@
*****************************************************************************
* Copyright (C) 2000 VideoLAN
*
* Authors:
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Aaron Holtzman <aholtzma@engr.uvic.ca>
* Renaud Dartus <reno@videolan.org>
*
* 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
......@@ -25,49 +27,40 @@
#include "ac3_decoder.h"
#include "ac3_internal.h"
/*
static inline s16 logadd (s16 a, s16 b);
static s16 calc_lowcomp (s16 a, s16 b0, s16 b1, s16 bin);
static inline u16 min (s16 a, s16 b);
static inline u16 max (s16 a, s16 b);
*/
static void ba_compute_psd (s16 start, s16 end, s16 exps[],
s16 psd[], s16 bndpsd[]);
static void ba_compute_psd (bit_allocate_t * p_bit, s16 start, s16 end, s16 exps[]);
static void ba_compute_excitation (s16 start, s16 end, s16 fgain,
s16 fastleak, s16 slowleak, s16 is_lfe,
s16 bndpsd[], s16 excite[]);
static void ba_compute_mask (s16 start, s16 end, u16 fscod,
static void ba_compute_excitation (bit_allocate_t * p_bit, s16 start, s16 end, s16 fgain,
s16 fastleak, s16 slowleak, s16 is_lfe);
static void ba_compute_mask (bit_allocate_t * p_bit, s16 start, s16 end, u16 fscod,
u16 deltbae, u16 deltnseg, u16 deltoffst[],
u16 deltba[], u16 deltlen[], s16 excite[],
s16 mask[]);
static void ba_compute_bap (s16 start, s16 end, s16 snroffset,
s16 psd[], s16 mask[], s16 bap[]);
u16 deltba[], u16 deltlen[]);
static void ba_compute_bap (bit_allocate_t * p_bit, s16 start, s16 end,
s16 snroffset, s16 bap[]);
/* Misc LUTs for bit allocation process */
static s16 slowdec[] = { 0x0f, 0x11, 0x13, 0x15 };
static s16 fastdec[] = { 0x3f, 0x53, 0x67, 0x7b };
static s16 slowgain[] = { 0x540, 0x4d8, 0x478, 0x410 };
static s16 dbpbtab[] = { 0x000, 0x700, 0x900, 0xb00 };
static const s16 slowdec[] = { 0x0f, 0x11, 0x13, 0x15 };
static const s16 fastdec[] = { 0x3f, 0x53, 0x67, 0x7b };
static const s16 slowgain[] = { 0x540, 0x4d8, 0x478, 0x410 };
static const s16 dbpbtab[] = { 0x000, 0x700, 0x900, 0xb00 };
static u16 floortab[] = { 0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800 };
static s16 fastgain[] = { 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400 };
static const u16 floortab[] = { 0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800 };
static const s16 fastgain[] = { 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400 };
static s16 bndtab[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
static const s16 bndtab[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 31,
34, 37, 40, 43, 46, 49, 55, 61, 67, 73,
79, 85, 97, 109, 121, 133, 157, 181, 205, 229 };
static s16 bndsz[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
static const s16 bndsz[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 3, 3,
3, 3, 3, 3, 3, 6, 6, 6, 6, 6,
6, 12, 12, 12, 12, 24, 24, 24, 24, 24 };
static s16 masktab[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
static const s16 masktab[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 28, 29,
29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34,
34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 37, 37, 37,
......@@ -85,7 +78,7 @@ static s16 masktab[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0 };
static s16 latab[] = { 0x0040, 0x003f, 0x003e, 0x003d, 0x003c, 0x003b, 0x003a, 0x0039,
static const s16 latab[] = { 0x0040, 0x003f, 0x003e, 0x003d, 0x003c, 0x003b, 0x003a, 0x0039,
0x0038, 0x0037, 0x0036, 0x0035, 0x0034, 0x0034, 0x0033, 0x0032,
0x0031, 0x0030, 0x002f, 0x002f, 0x002e, 0x002d, 0x002c, 0x002c,
0x002b, 0x002a, 0x0029, 0x0029, 0x0028, 0x0027, 0x0026, 0x0026,
......@@ -119,7 +112,7 @@ static s16 latab[] = { 0x0040, 0x003f, 0x003e, 0x003d, 0x003c, 0x003b, 0x003a, 0
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000};
static s16 hth[][50] = {{ 0x04d0, 0x04d0, 0x0440, 0x0400, 0x03e0, 0x03c0, 0x03b0, 0x03b0,
static const s16 hth[][50] = {{ 0x04d0, 0x04d0, 0x0440, 0x0400, 0x03e0, 0x03c0, 0x03b0, 0x03b0,
0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x0390, 0x0390, 0x0390,
0x0380, 0x0380, 0x0370, 0x0370, 0x0360, 0x0360, 0x0350, 0x0350,
0x0340, 0x0340, 0x0330, 0x0320, 0x0310, 0x0300, 0x02f0, 0x02f0,
......@@ -144,21 +137,11 @@ static s16 hth[][50] = {{ 0x04d0, 0x04d0, 0x0440, 0x0400, 0x03e0, 0x03c0, 0x03b0
0x0450, 0x04e0 }};
static s16 baptab[] = { 0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6,
static const s16 baptab[] = { 0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6,
6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10,
10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14,
14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15 };
static s16 sdecay;
static s16 fdecay;
static s16 sgain;
static s16 dbknee;
static s16 floor;
static s16 psd[256];
static s16 bndpsd[256];
static s16 excite[256];
static s16 mask[256];
static __inline__ u16 max (s16 a, s16 b)
{
return (a > b ? a : b);
......@@ -218,11 +201,11 @@ void bit_allocate (ac3dec_t * p_ac3dec)
return;
/* Do some setup before we do the bit alloc */
sdecay = slowdec[p_ac3dec->audblk.sdcycod];
fdecay = fastdec[p_ac3dec->audblk.fdcycod];
sgain = slowgain[p_ac3dec->audblk.sgaincod];
dbknee = dbpbtab[p_ac3dec->audblk.dbpbcod];
floor = floortab[p_ac3dec->audblk.floorcod];
p_ac3dec->bit_allocate.sdecay = slowdec[p_ac3dec->audblk.sdcycod];
p_ac3dec->bit_allocate.fdecay = fastdec[p_ac3dec->audblk.fdcycod];
p_ac3dec->bit_allocate.sgain = slowgain[p_ac3dec->audblk.sgaincod];
p_ac3dec->bit_allocate.dbknee = dbpbtab[p_ac3dec->audblk.dbpbcod];
p_ac3dec->bit_allocate.floor = floortab[p_ac3dec->audblk.floorcod];
/* if all the SNR offset constants are zero then the whole block is zero */
if (!p_ac3dec->audblk.csnroffst && !p_ac3dec->audblk.fsnroffst[0] &&
......@@ -239,24 +222,22 @@ void bit_allocate (ac3dec_t * p_ac3dec)
start = 0;
end = p_ac3dec->audblk.endmant[i] ;
fgain = fastgain[p_ac3dec->audblk.fgaincod[i]];
snroffset = (((p_ac3dec->audblk.csnroffst - 15) << 4) + p_ac3dec->audblk.fsnroffst[i]) << 2 ;
snroffset = (((p_ac3dec->audblk.csnroffst - 15) << 4) + p_ac3dec->audblk.fsnroffst[i]) << 2;
fastleak = 0;
slowleak = 0;
ba_compute_psd (start, end, p_ac3dec->audblk.fbw_exp[i], psd, bndpsd);
ba_compute_psd (&p_ac3dec->bit_allocate, start, end, p_ac3dec->audblk.fbw_exp[i]);
ba_compute_excitation (start, end , fgain, fastleak, slowleak, 0,
bndpsd, excite);
ba_compute_excitation (&p_ac3dec->bit_allocate, start, end , fgain, fastleak, slowleak, 0);
ba_compute_mask (start, end, p_ac3dec->syncinfo.fscod,
ba_compute_mask (&p_ac3dec->bit_allocate, start, end, p_ac3dec->syncinfo.fscod,
p_ac3dec->audblk.deltbae[i],
p_ac3dec->audblk.deltnseg[i],
p_ac3dec->audblk.deltoffst[i],
p_ac3dec->audblk.deltba[i],
p_ac3dec->audblk.deltlen[i], excite, mask);
p_ac3dec->audblk.deltlen[i]);
ba_compute_bap (start, end, snroffset, psd, mask,
p_ac3dec->audblk.fbw_bap[i]);
ba_compute_bap (&p_ac3dec->bit_allocate, start, end, snroffset, p_ac3dec->audblk.fbw_bap[i]);
}
if (p_ac3dec->audblk.cplinu) {
......@@ -267,20 +248,18 @@ void bit_allocate (ac3dec_t * p_ac3dec)
fastleak = (p_ac3dec->audblk.cplfleak << 8) + 768;
slowleak = (p_ac3dec->audblk.cplsleak << 8) + 768;
ba_compute_psd (start, end, p_ac3dec->audblk.cpl_exp, psd, bndpsd);
ba_compute_psd (&p_ac3dec->bit_allocate, start, end, p_ac3dec->audblk.cpl_exp);
ba_compute_excitation (start, end , fgain, fastleak, slowleak, 0,
bndpsd, excite);
ba_compute_excitation (&p_ac3dec->bit_allocate, start, end , fgain, fastleak, slowleak, 0);
ba_compute_mask (start, end, p_ac3dec->syncinfo.fscod,
ba_compute_mask (&p_ac3dec->bit_allocate, start, end, p_ac3dec->syncinfo.fscod,
p_ac3dec->audblk.cpldeltbae,
p_ac3dec->audblk.cpldeltnseg,
p_ac3dec->audblk.cpldeltoffst,
p_ac3dec->audblk.cpldeltba,
p_ac3dec->audblk.cpldeltlen, excite, mask);
p_ac3dec->audblk.cpldeltlen);
ba_compute_bap (start, end, snroffset, psd, mask,
p_ac3dec->audblk.cpl_bap);
ba_compute_bap (&p_ac3dec->bit_allocate, start, end, snroffset, p_ac3dec->audblk.cpl_bap);
}
if (p_ac3dec->bsi.lfeon) {
......@@ -291,29 +270,25 @@ void bit_allocate (ac3dec_t * p_ac3dec)
fastleak = 0;
slowleak = 0;
ba_compute_psd (start, end, p_ac3dec->audblk.lfe_exp, psd, bndpsd);
ba_compute_psd (&p_ac3dec->bit_allocate, start, end, p_ac3dec->audblk.lfe_exp);
ba_compute_excitation (start, end , fgain, fastleak, slowleak, 1,
bndpsd, excite);
ba_compute_excitation (&p_ac3dec->bit_allocate, start, end , fgain, fastleak, slowleak, 1);
ba_compute_mask (start, end, p_ac3dec->syncinfo.fscod, 2, 0, 0, 0, 0,
excite, mask);
ba_compute_mask (&p_ac3dec->bit_allocate, start, end, p_ac3dec->syncinfo.fscod, 2, 0, 0, 0, 0);
ba_compute_bap (start, end, snroffset, psd, mask,
p_ac3dec->audblk.lfe_bap);
ba_compute_bap (&p_ac3dec->bit_allocate, start, end, snroffset, p_ac3dec->audblk.lfe_bap);
}
}
static void ba_compute_psd (s16 start, s16 end, s16 exps[], s16 psd[],
s16 bndpsd[])
static void ba_compute_psd (bit_allocate_t * p_bit, s16 start, s16 end, s16 exps[])
{
int bin,i,j,k;
s16 lastbin = 0;
/* Map the exponents into dBs */
for (bin=start; bin<end; bin++) {
psd[bin] = (3072 - (exps[bin] << 7));
p_bit->psd[bin] = (3072 - (exps[bin] << 7));
}
/* Integrate the psd function over each bit allocation band */
......@@ -322,11 +297,11 @@ static void ba_compute_psd (s16 start, s16 end, s16 exps[], s16 psd[],
do {
lastbin = min(bndtab[k] + bndsz[k], end);
bndpsd[k] = psd[j];
p_bit->bndpsd[k] = p_bit->psd[j];
j++;
for (i = j; i < lastbin; i++) {
bndpsd[k] = logadd(bndpsd[k], psd[j]);
p_bit->bndpsd[k] = logadd(p_bit->bndpsd[k],p_bit->psd[j]);
j++;
}
......@@ -334,9 +309,8 @@ static void ba_compute_psd (s16 start, s16 end, s16 exps[], s16 psd[],
} while (end > lastbin);
}
static void ba_compute_excitation (s16 start, s16 end,s16 fgain, s16 fastleak,
s16 slowleak, s16 is_lfe, s16 bndpsd[],
s16 excite[])
static void ba_compute_excitation (bit_allocate_t * p_bit, s16 start, s16 end,
s16 fgain, s16 fastleak, s16 slowleak, s16 is_lfe)
{
int bin;
s16 bndstrt;
......@@ -349,22 +323,24 @@ static void ba_compute_excitation (s16 start, s16 end,s16 fgain, s16 fastleak,
bndend = masktab[end - 1] + 1;
if (bndstrt == 0) { /* For fbw and lfe channels */
lowcomp = calc_lowcomp(lowcomp, bndpsd[0], bndpsd[1], 0);
excite[0] = bndpsd[0] - fgain - lowcomp;
lowcomp = calc_lowcomp(lowcomp, bndpsd[1], bndpsd[2], 1);
excite[1] = bndpsd[1] - fgain - lowcomp;
lowcomp = calc_lowcomp(lowcomp, p_bit->bndpsd[0], p_bit->bndpsd[1], 0);
p_bit->excite[0] = p_bit->bndpsd[0] - fgain - lowcomp;
lowcomp = calc_lowcomp(lowcomp, p_bit->bndpsd[1], p_bit->bndpsd[2], 1);
p_bit->excite[1] = p_bit->bndpsd[1] - fgain - lowcomp;
begin = 7 ;
/* Note: Do not call calc_lowcomp() for the last band of the lfe channel, (bin = 6) */
for (bin = 2; bin < 7; bin++) {
if (!(is_lfe && (bin == 6)))
lowcomp = calc_lowcomp (lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
fastleak = bndpsd[bin] - fgain;
slowleak = bndpsd[bin] - sgain;
excite[bin] = fastleak - lowcomp;
lowcomp = calc_lowcomp (lowcomp, p_bit->bndpsd[bin], p_bit->bndpsd[bin+1], bin);
fastleak = p_bit->bndpsd[bin] - fgain;
slowleak = p_bit->bndpsd[bin] - p_bit->sgain;
p_bit->excite[bin] = fastleak - lowcomp;
if (!(is_lfe && (bin == 6))) {
if (bndpsd[bin] <= bndpsd[bin+1]) {
if (p_bit->bndpsd[bin] <=
p_bit->bndpsd[bin+1])
{
begin = bin + 1 ;
break;
}
......@@ -373,12 +349,13 @@ static void ba_compute_excitation (s16 start, s16 end,s16 fgain, s16 fastleak,
for (bin = begin; bin < min(bndend, 22); bin++) {
if (!(is_lfe && (bin == 6)))
lowcomp = calc_lowcomp (lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
fastleak -= fdecay ;
fastleak = max(fastleak, bndpsd[bin] - fgain);
slowleak -= sdecay ;
slowleak = max(slowleak, bndpsd[bin] - sgain);
excite[bin] = max(fastleak - lowcomp, slowleak);
lowcomp = calc_lowcomp (lowcomp, p_bit->bndpsd[bin],
p_bit->bndpsd[bin+1], bin);
fastleak -= p_bit->fdecay ;
fastleak = max(fastleak, p_bit->bndpsd[bin] - fgain);
slowleak -= p_bit->sdecay ;
slowleak = max(slowleak, p_bit->bndpsd[bin] - p_bit->sgain);
p_bit->excite[bin] = max(fastleak - lowcomp, slowleak);
}
begin = 22;
} else { /* For coupling channel */
......@@ -386,17 +363,17 @@ static void ba_compute_excitation (s16 start, s16 end,s16 fgain, s16 fastleak,
}
for (bin = begin; bin < bndend; bin++) {
fastleak -= fdecay;
fastleak = max(fastleak, bndpsd[bin] - fgain);
slowleak -= sdecay;
slowleak = max(slowleak, bndpsd[bin] - sgain);
excite[bin] = max(fastleak, slowleak) ;
fastleak -= p_bit->fdecay;
fastleak = max(fastleak, p_bit->bndpsd[bin] - fgain);
slowleak -= p_bit->sdecay;
slowleak = max(slowleak, p_bit->bndpsd[bin] - p_bit->sgain);
p_bit->excite[bin] = max(fastleak, slowleak) ;
}
}
static void ba_compute_mask (s16 start, s16 end, u16 fscod, u16 deltbae,
u16 deltnseg, u16 deltoffst[], u16 deltba[],
u16 deltlen[], s16 excite[], s16 mask[])
static void ba_compute_mask (bit_allocate_t * p_bit, s16 start, s16 end, u16 fscod,
u16 deltbae, u16 deltnseg, u16 deltoffst[],
u16 deltba[], u16 deltlen[])
{
int bin,k;
s16 bndstrt;
......@@ -408,10 +385,10 @@ static void ba_compute_mask (s16 start, s16 end, u16 fscod, u16 deltbae,
/* Compute the masking curve */
for (bin = bndstrt; bin < bndend; bin++) {
if (bndpsd[bin] < dbknee) {
excite[bin] += ((dbknee - bndpsd[bin]) >> 2);
if (p_bit->bndpsd[bin] < p_bit->dbknee) {
p_bit->excite[bin] += ((p_bit->dbknee - p_bit->bndpsd[bin]) >> 2);
}
mask[bin] = max(excite[bin], hth[fscod][bin]);
p_bit->mask[bin] = max(p_bit->excite[bin], hth[fscod][bin]);
}
/* Perform delta bit modulation if necessary */
......@@ -427,15 +404,15 @@ static void ba_compute_mask (s16 start, s16 end, u16 fscod, u16 deltbae,
delta = (deltba[seg] - 4) << 7;
}
for (k = 0; k < deltlen[seg]; k++) {
mask[band] += delta;
p_bit->mask[band] += delta;
band++;
}
}
}
}
static void ba_compute_bap (s16 start, s16 end, s16 snroffset, s16 psd[],
s16 mask[], s16 bap[])
static void ba_compute_bap (bit_allocate_t * p_bit, s16 start, s16 end, s16 snroffset,
s16 bap[])
{
int i,j,k;
s16 lastbin = 0;
......@@ -447,16 +424,16 @@ static void ba_compute_bap (s16 start, s16 end, s16 snroffset, s16 psd[],
do {
lastbin = min(bndtab[j] + bndsz[j], end);
mask[j] -= snroffset;
mask[j] -= floor;
p_bit->mask[j] -= snroffset;
p_bit->mask[j] -= p_bit->floor;
if (mask[j] < 0)
mask[j] = 0;
if (p_bit->mask[j] < 0)
p_bit->mask[j] = 0;
mask[j] &= 0x1fe0;
mask[j] += floor;
p_bit->mask[j] &= 0x1fe0;
p_bit->mask[j] += p_bit->floor;
for (k = i; k < lastbin; k++) {
address = (psd[i] - mask[j]) >> 5;
address = (p_bit->psd[i] - p_bit->mask[j]) >> 5;
address = min(63, max(0, address));
bap[i] = baptab[address];
i++;
......
......@@ -3,7 +3,8 @@
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
*
* Authors: Renaud Dartus <reno@videolan.org>
* Authors: Michel Lespinasse <walken@zoy.org>
* Renaud Dartus <reno@videolan.org>
*
*
* This program is free software; you can redistribute it and/or modify
......
......@@ -3,7 +3,9 @@
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
*
* Authors:
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@zoy.org>
* Aaron Holtzman <aholtzma@engr.uvic.ca>
*
* 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
......@@ -19,17 +21,24 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include "defs.h"
#include "int_types.h"
#include "ac3_decoder.h"
#include "ac3_internal.h"
#include <stdio.h>
void imdct_init (imdct_t * p_imdct);
int ac3_init (ac3dec_t * p_ac3dec)
{
//p_ac3dec->bit_stream.buffer = 0;
//p_ac3dec->bit_stream.i_available = 0;
p_ac3dec->mantissa.lfsr_state = 1; /* dither_gen initialization */
imdct_init(&p_ac3dec->imdct);
return 0;
}
......@@ -39,7 +48,7 @@ int ac3_decode_frame (ac3dec_t * p_ac3dec, s16 * buffer)
if (parse_bsi (p_ac3dec))
return 1;
for (i = 0; i < 6; i++) {
if (parse_audblk (p_ac3dec, i))
return 1;
......@@ -49,8 +58,8 @@ int ac3_decode_frame (ac3dec_t * p_ac3dec, s16 * buffer)
mantissa_unpack (p_ac3dec);
if (p_ac3dec->bsi.acmod == 0x2)
rematrix (p_ac3dec);
imdct (p_ac3dec);
downmix (p_ac3dec, buffer);
imdct (p_ac3dec, buffer);
// downmix (p_ac3dec, buffer);
buffer += 2*256;
}
......
......@@ -3,8 +3,8 @@
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
*
* Authors:
* Michel Kaempf <maxx@via.ecp.fr>
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Renaud Dartus <reno@videolan.org>
*
* 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
......@@ -355,6 +355,63 @@ typedef struct ac3_bit_stream_s
unsigned int total_bits_read; /* temporary */
} ac3_bit_stream_t;
typedef struct bit_allocate_s
{
s16 psd[256];
s16 bndpsd[256];
s16 excite[256];
s16 mask[256];
s16 sdecay;
s16 fdecay;
s16 sgain;
s16 dbknee;
s16 floor;
} bit_allocate_t;
/* These store the persistent state of the packed mantissas */
typedef struct mantissa_s
{
float q_1[2];
float q_2[2];
float q_4[1];
s32 q_1_pointer;
s32 q_2_pointer;
s32 q_4_pointer;
u16 lfsr_state;
} mantissa_t;
typedef struct complex_s {
float real;
float imag;
} complex_t;
#define N 512
typedef struct imdct_s
{
complex_t buf[N/4];
/* Delay buffer for time domain interleaving */
float delay[6][256];
/* Twiddle factors for IMDCT */
float xcos1[N/4];
float xsin1[N/4];
float xcos2[N/8];
float xsin2[N/8];
/* Twiddle factor LUT */
complex_t *w[7];
complex_t w_1[1];
complex_t w_2[2];
complex_t w_4[4];
complex_t w_8[8];
complex_t w_16[16];
complex_t w_32[32];
complex_t w_64[64];
} imdct_t;
struct ac3dec_s
{
/*
......@@ -373,6 +430,10 @@ struct ac3dec_s
stream_coeffs_t coeffs;
stream_samples_t samples;
bit_allocate_t bit_allocate;
mantissa_t mantissa;
imdct_t imdct;
};
/**** ac3 decoder inline functions ****/
......
......@@ -2,9 +2,9 @@
* ac3_decoder_thread.c: ac3 decoder thread
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_decoder_thread.c,v 1.24 2001/02/11 01:15:10 sam Exp $
* $Id: ac3_decoder_thread.c,v 1.25 2001/02/20 12:06:28 reno Exp $
*
* Authors:
* Authors: Michel Lespinasse <walken@zoy.org>
*
* 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
......@@ -164,9 +164,6 @@ static void RunThread (ac3dec_thread_t * p_ac3dec)
intf_DbgMsg ("ac3dec debug: running ac3 decoder thread (%p) (pid == %i)", p_ac3dec, getpid());
/* FIXME ! Qu'est-ce que c'est que ce bordel !?!?!?!? --Meuuh */
//msleep (INPUT_PTS_DELAY);
/* Initializing the ac3 decoder thread */
if (InitThread (p_ac3dec)) /* XXX?? */
{
......@@ -210,7 +207,7 @@ static void RunThread (ac3dec_thread_t * p_ac3dec)
{
if (p_byte_stream->p_byte >= p_byte_stream->p_end)
{
ac3_byte_stream_next (p_byte_stream);
ac3_byte_stream_next (p_byte_stream);
}
p_byte_stream->p_byte++;
}
......@@ -326,7 +323,6 @@ static void EndThread (ac3dec_thread_t * p_ac3dec)
void ac3_byte_stream_next (ac3_byte_stream_t * p_byte_stream)
{
ac3dec_thread_t * p_ac3dec = p_byte_stream->info;
/* We are looking for the next TS packet that contains real data,
* and not just a PES header */
do
...