Commit a906b2f5 authored by Renaud Dartus's avatar Renaud Dartus

* 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
......
This diff is collapsed.
......@@ -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
......
This diff is collapsed.
/*****************************************************************************
* ac3_downmix.h: ac3 downmix functions
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
*
* Authors: 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
#define NORM 16384
typedef struct dm_par_s {
float unit;
float clev;
float slev;
} dm_par_t;
void downmix_3f_2r_to_2ch_c(float *samples, dm_par_t * dm_par);
void downmix_3f_1r_to_2ch_c(float *samples, dm_par_t * dm_par);
void downmix_2f_2r_to_2ch_c(float *samples, dm_par_t * dm_par);
void downmix_2f_1r_to_2ch_c(float *samples, dm_par_t * dm_par);
void downmix_3f_0r_to_2ch_c(float *samples, dm_par_t * dm_par);
void stream_sample_2ch_to_s16_c(s16 *s16_samples, float *left, float *right);
void stream_sample_1ch_to_s16_c(s16 *s16_samples, float *center);
/*****************************************************************************
* ac3_downmix_c.c: ac3 downmix functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
*
* Authors: Renaud Dartus <reno@videolan.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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
#include "defs.h"
#include "int_types.h"
#include "ac3_decoder.h"
#include "ac3_internal.h"
#include "ac3_bit_stream.h"
#include "ac3_downmix.h"
void __inline__ downmix_3f_2r_to_2ch_c (float *samples, dm_par_t *dm_par)
{
int i;
float *left, *right, *center, *left_sur, *right_sur;
float left_tmp, right_tmp;
left = samples;
center = samples + 256;
right = samples + 256*2;
left_sur = samples + 256*3;
right_sur = samples + 256*4;
for (i=0; i < 256; i++) {
left_tmp = dm_par->unit * *left + dm_par->clev * *center + dm_par->slev * *left_sur++;
right_tmp = dm_par->unit * *right++ + dm_par->clev * *center + dm_par->slev * *right_sur++;
*left++ = left_tmp;
*center++ = right_tmp;
}
}
void __inline__ downmix_2f_2r_to_2ch_c (float *samples, dm_par_t *dm_par)
{
int i;
float *left, *right, *left_sur, *right_sur;
float left_tmp, right_tmp;
left = &samples[0];
right = &samples[256];
left_sur = &samples[512];
right_sur = &samples[768];
for (i = 0; i < 256; i++) {
left_tmp = dm_par->unit * *left + dm_par->slev * *left_sur++;
right_tmp= dm_par->unit * *right + dm_par->slev * *right_sur++;
*left++ = left_tmp;
*right++ = right_tmp;
}
}
void __inline__ downmix_3f_1r_to_2ch_c (float *samples, dm_par_t *dm_par)
{
int i;
float *left, *right, *center, *right_sur;
float left_tmp, right_tmp;
left = &samples[0];
right = &samples[512];
center = &samples[256];
right_sur = &samples[768];
for (i = 0; i < 256; i++) {
left_tmp = dm_par->unit * *left + dm_par->clev * *center - dm_par->slev * *right_sur;
right_tmp= dm_par->unit * *right++ + dm_par->clev * *center + dm_par->slev * *right_sur++;
*left++ = left_tmp;
*center++ = right_tmp;
}
}
void __inline__ downmix_2f_1r_to_2ch_c (float *samples, dm_par_t *dm_par)
{
int i;
float *left, *right, *right_sur;
float left_tmp, right_tmp;
left = &samples[0];
right = &samples[256];
right_sur = &samples[512];
for (i = 0; i < 256; i++) {
left_tmp = dm_par->unit * *left - dm_par->slev * *right_sur;
right_tmp= dm_par->unit * *right + dm_par->slev * *right_sur++;
*left++ = left_tmp;
*right++ = right_tmp;
}
}
void __inline__ downmix_3f_0r_to_2ch_c (float *samples, dm_par_t *dm_par)
{
int i;
float *left, *right, *center;
float left_tmp, right_tmp;
left = &samples[0];
center = &samples[256];
right = &samples[512];
for (i = 0; i < 256; i++) {
left_tmp = dm_par->unit * *left + dm_par->clev * *center;
right_tmp= dm_par->unit * *right++ + dm_par->clev * *center;
*left++ = left_tmp;
*center++ = right_tmp;
}
}
void __inline__ stream_sample_2ch_to_s16_c (s16 *out_buf, float *left, float *right)
{
int i;
for (i=0; i < 256; i++) {
*out_buf++ = (s16) (*left++ * NORM);
*out_buf++ = (s16) (*right++ * NORM);
}
}
void __inline__ stream_sample_1ch_to_s16_c (s16 *out_buf, float *center)
{
int i;
float tmp;
for (i=0; i < 256; i++) {
*out_buf++ = tmp = (s16) (0.7071f * *center++ * NORM);
*out_buf++ = tmp * NORM;
}
}
......@@ -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
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
*****************************************************************************
* Copyright (C) 2000 VideoLAN
*
* 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
......@@ -36,13 +36,13 @@
void bit_allocate (ac3dec_t *);
/* ac3_downmix.c */
void downmix (ac3dec_t *, s16 *);
int downmix (ac3dec_t *, s16 *);
/* ac3_exponent.c */
int exponent_unpack (ac3dec_t *);
/* ac3_imdct.c */
void imdct (ac3dec_t * p_ac3dec);
void imdct (ac3dec_t * p_ac3dec, s16 * buffer);
/* ac3_mantissa.c */
void mantissa_unpack (ac3dec_t *);
......
......@@ -4,6 +4,7 @@
* Copyright (C) 1999, 2000, 2001 VideoLAN
*
* 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
......@@ -36,21 +37,21 @@
#define Q0 ((-2 << 15) / 3.0)
#define Q1 (0)
#define Q2 ((2 << 15) / 3.0)
static float q_1_0[ 32 ] =
static const float q_1_0[ 32 ] =
{
Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
0, 0, 0, 0, 0
};
static float q_1_1[ 32 ] =
static const float q_1_1[ 32 ] =
{
Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
0, 0, 0, 0, 0
};
static float q_1_2[ 32 ] =
static const float q_1_2[ 32 ] =
{
Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
......@@ -66,7 +67,7 @@ static float q_1_2[ 32 ] =
#define Q2 (0)
#define Q3 ((2 << 15) / 5.0)
#define Q4 ((4 << 15) / 5.0)
static float q_2_0[ 128 ] =
static const float q_2_0[ 128 ] =
{
Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,
Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,
......@@ -75,7 +76,7 @@ static float q_2_0[ 128 ] =
Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,
0, 0, 0
};
static float q_2_1[ 128 ] =
static const float q_2_1[ 128 ] =
{
Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
......@@ -84,7 +85,7 @@ static float q_2_1[ 128 ] =
Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
0, 0, 0
};
static float q_2_2[ 128 ] =
static const float q_2_2[ 128 ] =
{
Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
......@@ -110,7 +111,7 @@ static float q_2_2[ 128 ] =
#define Q8 ((6 << 15) / 11.0)
#define Q9 ((8 << 15) / 11.0)
#define QA ((10 << 15) / 11.0)
static float q_4_0[ 128 ] =
static const float q_4_0[ 128 ] =
{
Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
......@@ -125,7 +126,7 @@ static float q_4_0[ 128 ] =
QA, QA, QA, QA, QA, QA, QA, QA, QA, QA, QA,
0, 0, 0, 0, 0, 0, 0
};
static float q_4_1[ 128 ] =
static const float q_4_1[ 128 ] =
{
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
......@@ -154,14 +155,14 @@ static float q_4_1[ 128 ] =
/* Lookup tables of 0.16 two's complement quantization values */
static float q_3[8] =
static const float q_3[8] =
{
(-6 << 15)/7.0, (-4 << 15)/7.0, (-2 << 15)/7.0,
0 , (2 << 15)/7.0, (4 << 15)/7.0,
(6 << 15)/7.0, 0
};
static float q_5[16] =
static const float q_5[16] =
{
(-14 << 15)/15.0, (-12 << 15)/15.0, (-10 << 15)/15.0,
(-8 << 15)/15.0, (-6 << 15)/15.0, (-4 << 15)/15.0,
......@@ -171,22 +172,14 @@ static float q_5[16] =
0
};
/* These store the persistent state of the packed mantissas */
static float q_1[2];
static float q_2[2];
static float q_4[1];
static s32 q_1_pointer;
static s32 q_2_pointer;
static s32 q_4_pointer;
/* Conversion from bap to number of bits in the mantissas
* zeros account for cases 0,1,2,4 which are special cased */
static u16 qnttztab[16] =
static const u16 qnttztab[16] =
{
0, 0, 0, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
};
static float exp_lut[ 25 ] =
static const float exp_lut[ 25 ] =
{
6.10351562500000000000000000e-05,
3.05175781250000000000000000e-05,
......@@ -215,7 +208,7 @@ static float exp_lut[ 25 ] =
3.63797880709171295166015625e-12,
};
const u16 dither_lut[256] =
static const u16 dither_lut[256] =
{
0x0000, 0xa011, 0xe033, 0x4022, 0x6077, 0xc066, 0x8044, 0x2055,
0xc0ee, 0x60ff, 0x20dd, 0x80cc, 0xa099, 0x0088, 0x40aa, 0xe0bb,
......@@ -251,14 +244,13 @@ const u16 dither_lut[256] =
0x8bf4, 0x2be5, 0x6bc7, 0xcbd6, 0xeb83, 0x4b92, 0x0bb0, 0xaba1
};
u16 lfsr_state = 1;
static __inline__ u16 dither_gen (void)
static __inline__ u16 dither_gen (mantissa_t * p_mantissa)
{
s16 state;
state = dither_lut[lfsr_state >> 8] ^ (lfsr_state << 8);
lfsr_state = (u16) state;
state = dither_lut[p_mantissa->lfsr_state >> 8] ^
(p_mantissa->lfsr_state << 8);
p_mantissa->lfsr_state = (u16) state;
return ( (state * (s32) (0.707106 * 256.0)) >> 8 );
}
......@@ -274,75 +266,75 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp)
case 0:
if (p_ac3dec->audblk.dithflag[exp])
{
return ( dither_gen() * exp_lut[exp] );
return ( dither_gen(&p_ac3dec->mantissa) * exp_lut[exp] );
}
return (0);
case 1:
if (q_1_pointer >= 0)
if (p_ac3dec->mantissa.q_1_pointer >= 0)
{
return (q_1[q_1_pointer--] * exp_lut[exp]);
return (p_ac3dec->mantissa.q_1[p_ac3dec->mantissa.q_1_pointer--] * exp_lut[exp]);
}
if ((group_code = bitstream_get(&(p_ac3dec->bit_stream),5)) >= 27)
{
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
intf_WarnMsg ( 1, "ac3dec error: invalid mantissa" );
}
q_1[ 1 ] = q_1_1[ group_code ];
q_1[ 0 ] = q_1_2[ group_code ];
p_ac3dec->mantissa.q_1[ 1 ] = q_1_1[ group_code ];
p_ac3dec->mantissa.q_1[ 0 ] = q_1_2[ group_code ];
q_1_pointer = 1;
p_ac3dec->mantissa.q_1_pointer = 1;
return (q_1_0[group_code] * exp_lut[exp]);
case 2:
if (q_2_pointer >= 0)
if (p_ac3dec->mantissa.q_2_pointer >= 0)
{
return (q_2[q_2_pointer--] * exp_lut[exp]);
return (p_ac3dec->mantissa.q_2[p_ac3dec->mantissa.q_2_pointer--] * exp_lut[exp]);
}
if ((group_code = bitstream_get(&(p_ac3dec->bit_stream),7)) >= 125)
{
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
intf_WarnMsg ( 1, "ac3dec error: invalid mantissa" );
}
q_2[ 1 ] = q_2_1[ group_code ];
q_2[ 0 ] = q_2_2[ group_code ];
p_ac3dec->mantissa.q_2[ 1 ] = q_2_1[ group_code ];
p_ac3dec->mantissa.q_2[ 0 ] = q_2_2[ group_code ];
q_2_pointer = 1;
p_ac3dec->mantissa.q_2_pointer = 1;
return (q_2_0[ group_code ] * exp_lut[exp]);
case 3:
if ((group_code = bitstream_get(&(p_ac3dec->bit_stream),3)) >= 7)
{
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
intf_WarnMsg ( 1, "ac3dec error: invalid mantissa" );
}
return (q_3[group_code] * exp_lut[exp]);
case 4:
if (q_4_pointer >= 0)
if (p_ac3dec->mantissa.q_4_pointer >= 0)
{
return (q_4[q_4_pointer--] * exp_lut[exp]);
return (p_ac3dec->mantissa.q_4[p_ac3dec->mantissa.q_4_pointer--] * exp_lut[exp]);
}
if ((group_code = bitstream_get(&(p_ac3dec->bit_stream),7)) >= 121)
{
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
intf_WarnMsg ( 1, "ac3dec error: invalid mantissa" );
}
q_4[ 0 ] = q_4_1[ group_code ];
p_ac3dec->mantissa.q_4[ 0 ] = q_4_1[ group_code ];
q_4_pointer = 0;
p_ac3dec->mantissa.q_4_pointer = 0;
return (q_4_0[ group_code ] * exp_lut[exp]);
case 5:
if ((group_code = bitstream_get(&(p_ac3dec->bit_stream),4)) >= 15)
{
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
intf_WarnMsg ( 1, "ac3dec error: invalid mantissa" );
}
return (q_5[group_code] * exp_lut[exp]);
......@@ -394,7 +386,7 @@ static __inline__ void uncouple_channel (ac3dec_t * p_ac3dec, u32 ch)
* so the channels are uncorrelated */
if (p_ac3dec->audblk.dithflag[ch] && !p_ac3dec->audblk.cpl_bap[i])
{
p_ac3dec->coeffs.fbw[ch][i] = cpl_coord * dither_gen() *
p_ac3dec->coeffs.fbw[ch][i] = cpl_coord * dither_gen(&p_ac3dec->mantissa) *
exp_lut[p_ac3dec->audblk.cpl_exp[i]];
} else {
p_ac3dec->coeffs.fbw[ch][i] = cpl_coord * p_ac3dec->audblk.cplfbw[i];
......@@ -408,10 +400,10 @@ void mantissa_unpack (ac3dec_t * p_ac3dec)
{
int i, j;
q_1_pointer = -1;
q_2_pointer = -1;
q_4_pointer = -1;
p_ac3dec->mantissa.q_1_pointer = -1;
p_ac3dec->mantissa.q_2_pointer = -1;
p_ac3dec->mantissa.q_4_pointer = -1;
if (p_ac3dec->audblk.cplinu)
{
/* 1 */
......
......@@ -4,6 +4,7 @@
* Copyright (C) 1999, 2000, 2001 VideoLAN
*
* 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
......@@ -31,7 +32,7 @@
#include "ac3_bit_stream.h"
/* Misc LUT */
static u16 nfchans[] = { 2, 1, 2, 3, 3, 4, 4, 5 };
static const u16 nfchans[] = { 2, 1, 2, 3, 3, 4, 4, 5 };
struct frmsize_s
{
......@@ -39,7 +40,7 @@ struct frmsize_s
u16 frm_size[3];
};
static struct frmsize_s frmsizecod_tbl[] =
static const struct frmsize_s frmsizecod_tbl[] =
{
{ 32 ,{64 ,69 ,96 } },
{ 32 ,{64 ,70 ,96 } },
......@@ -80,7 +81,7 @@ static struct frmsize_s frmsizecod_tbl[] =
{ 640 ,{1280 ,1393 ,1920 } },
{ 640 ,{1280 ,1394 ,1920 } }};
static int fscod_tbl[] = {48000, 44100, 32000};
static const int fscod_tbl[] = {48000, 44100, 32000};
/* Some internal functions */
void parse_bsi_stats (ac3dec_t * p_ac3dec);
......@@ -264,6 +265,10 @@ int parse_bsi (ac3dec_t * p_ac3dec)
}
}
#ifdef STATS
parse_bsi_stats (p_ac3dec);
#endif
return 0;
}
......@@ -692,6 +697,10 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
}
}
#ifdef STATS
// parse_audblk_stats(p_ac3dec);
#endif
return 0;
}
......@@ -716,3 +725,69 @@ void parse_auxdata (ac3dec_t * p_ac3dec)
/* Get the crc */
bitstream_get(&(p_ac3dec->bit_stream),16);
}
void parse_bsi_stats (ac3dec_t * p_ac3dec) /*Some stats */
{
struct mixlev_s
{
float clev;
char *desc;
};
static const char *service_ids[8] =
{
"CM","ME","VI","HI",
"D", "C","E", "VO"
};
/*
static const struct mixlev_s cmixlev_tbl[4] =
{
{0.707, "(-3.0 dB)"}, {0.595, "(-4.5 dB)"},
{0.500, "(-6.0 dB)"}, {1.0, "Invalid"}
};
static const struct mixlev_s smixlev_tbl[4] =
{
{0.707, "(-3.0 dB)"}, {0.500, "(-6.0 dB)"},
{ 0.0, "off "}, { 1.0, "Invalid"}
};
*/
static int i;
if ( !i )
{
/* if ((p_ac3dec->bsi.acmod & 0x1) && (p_ac3dec->bsi.acmod != 0x1))
printf("CentreMixLevel %s ",cmixlev_tbl[p_ac3dec->bsi.cmixlev].desc);
if (p_ac3dec->bsi.acmod & 0x4)
printf("SurMixLevel %s",smixlev_tbl[p_ac3dec->bsi.cmixlev].desc);
*/
intf_Msg ( "(ac3dec_parsebsi) %s %d.%d Mode",
service_ids[p_ac3dec->bsi.bsmod],
p_ac3dec->bsi.nfchans,p_ac3dec->bsi.lfeon);
}
i++;
if ( i > 100 )
i = 0;
}
void parse_audblk_stats (ac3dec_t * p_ac3dec)
{
char *exp_strat_tbl[4] = {"R ","D15 ","D25 ","D45 "};
u32 i;
intf_ErrMsg ("(ac3dec_parseaudblk) ");
intf_ErrMsg ("%s ",p_ac3dec->audblk.cplinu ? "cpl on" : "cpl off");
intf_ErrMsg ("%s ",p_ac3dec->audblk.baie? "bai" : " ");
intf_ErrMsg ("%s ",p_ac3dec->audblk.snroffste? "snroffst" : " ");
intf_ErrMsg ("%s ",p_ac3dec->audblk.deltbaie? "deltba" : " ");
intf_ErrMsg ("%s ",p_ac3dec->audblk.phsflginu? "phsflg" : " ");
intf_ErrMsg ("(%s %s %s %s %s) ",exp_strat_tbl[p_ac3dec->audblk.chexpstr[0]],
exp_strat_tbl[p_ac3dec->audblk.chexpstr[1]],exp_strat_tbl[p_ac3dec->audblk.chexpstr[2]],
exp_strat_tbl[p_ac3dec->audblk.chexpstr[3]],exp_strat_tbl[p_ac3dec->audblk.chexpstr[4]]);
intf_ErrMsg ("[");
for(i=0;i<p_ac3dec->bsi.nfchans;i++)
intf_ErrMsg ("%1d",p_ac3dec->audblk.blksw[i]);
intf_ErrMsg ("]");
intf_ErrMsg ("\n");
}
......@@ -3,7 +3,8 @@
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
*
* Authors:
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* 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
......@@ -30,7 +31,7 @@ struct rematrix_band_s {
u32 end;
};
static struct rematrix_band_s rematrix_band[] = { {13,24}, {25,36}, {37 ,60}, {61,252}};
static const struct rematrix_band_s rematrix_band[] = { {13,24}, {25,36}, {37 ,60}, {61,252}};
static __inline__ u32 min (u32 a, u32 b)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment