Commit 3b94a56f authored by Renaud Dartus's avatar Renaud Dartus

* Begin of the new ac3_decoder ;)

  - New ac3_decoder_thread (we now use GetBits)

Please warn me if you encounter some problem
parent 39db76ab
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_bit_allocate.c: ac3 allocation tables * ac3_bit_allocate.c: ac3 allocation tables
***************************************************************************** *****************************************************************************
* Copyright (C) 2000 VideoLAN * Copyright (C) 2000 VideoLAN
* $Id: ac3_bit_allocate.c,v 1.17 2001/04/06 09:15:47 sam Exp $ * $Id: ac3_bit_allocate.c,v 1.18 2001/04/20 12:14:34 reno Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Aaron Holtzman <aholtzma@engr.uvic.ca> * Aaron Holtzman <aholtzma@engr.uvic.ca>
...@@ -24,9 +24,16 @@ ...@@ -24,9 +24,16 @@
*****************************************************************************/ *****************************************************************************/
#include "defs.h" #include "defs.h"
#include <string.h> /* memcpy(), memset() */ #include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "stream_control.h"
#include "input_ext-dec.h"
#include "int_types.h"
#include "ac3_decoder.h" #include "ac3_decoder.h"
#include "ac3_internal.h" #include "ac3_internal.h"
......
/*****************************************************************************
* ac3_bit_stream.h: getbits functions for the ac3 decoder
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: ac3_bit_stream.h,v 1.9 2001/03/21 13:42:34 sam Exp $
*
* Authors: Michel Lespinasse <walken@zoy.org>
* 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.
*****************************************************************************/
static __inline__ u32 bitstream_get (ac3_bit_stream_t * p_bit_stream,
u32 num_bits)
{
u32 result=0;
while (p_bit_stream->i_available < num_bits)
{
if (p_bit_stream->byte_stream.p_byte >= p_bit_stream->byte_stream.p_end)
{
ac3dec_thread_t * p_ac3dec = p_bit_stream->byte_stream.info;
/* no, switch to next buffer */
if(!p_ac3dec->p_fifo->b_die)
ac3_byte_stream_next (&p_bit_stream->byte_stream);
}
p_bit_stream->buffer |=((u32) *(p_bit_stream->byte_stream.p_byte++))
<< (24 - p_bit_stream->i_available);
p_bit_stream->i_available += 8;
}
result = p_bit_stream->buffer >> (32 - num_bits);
p_bit_stream->buffer <<= num_bits;
p_bit_stream->i_available -= num_bits;
p_bit_stream->total_bits_read += num_bits;
return result;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_decoder.c: core ac3 decoder * ac3_decoder.c: core ac3 decoder
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_decoder.c,v 1.28 2001/03/21 13:42:34 sam Exp $ * $Id: ac3_decoder.c,v 1.29 2001/04/20 12:14:34 reno Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@zoy.org> * Michel Lespinasse <walken@zoy.org>
...@@ -25,8 +25,21 @@ ...@@ -25,8 +25,21 @@
#include "defs.h" #include "defs.h"
#include "int_types.h" #include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "stream_control.h"
#include "input_ext-dec.h"
#include "audio_output.h"
#include "ac3_decoder.h" #include "ac3_decoder.h"
#include "ac3_decoder_thread.h"
#include "ac3_internal.h" #include "ac3_internal.h"
#include <stdio.h> #include <stdio.h>
...@@ -35,8 +48,8 @@ void imdct_init (imdct_t * p_imdct); ...@@ -35,8 +48,8 @@ void imdct_init (imdct_t * p_imdct);
int ac3_init (ac3dec_t * p_ac3dec) int ac3_init (ac3dec_t * p_ac3dec)
{ {
//p_ac3dec->bit_stream.buffer = 0; // p_ac3dec->bit_stream.buffer = 0;
//p_ac3dec->bit_stream.i_available = 0; // p_ac3dec->bit_stream.i_available = 0;
p_ac3dec->mantissa.lfsr_state = 1; /* dither_gen initialization */ p_ac3dec->mantissa.lfsr_state = 1; /* dither_gen initialization */
imdct_init(&p_ac3dec->imdct); imdct_init(&p_ac3dec->imdct);
...@@ -46,21 +59,50 @@ int ac3_init (ac3dec_t * p_ac3dec) ...@@ -46,21 +59,50 @@ int ac3_init (ac3dec_t * p_ac3dec)
int ac3_decode_frame (ac3dec_t * p_ac3dec, s16 * buffer) int ac3_decode_frame (ac3dec_t * p_ac3dec, s16 * buffer)
{ {
int i; int i;
ac3dec_thread_t * p_ac3dec_t = (ac3dec_thread_t *) p_ac3dec->bit_stream.p_callback_arg;
if (parse_bsi (p_ac3dec)) if (parse_bsi (p_ac3dec))
{
intf_WarnMsg (1,"Error during ac3parsing");
parse_auxdata (p_ac3dec);
return 1; return 1;
}
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if ((p_ac3dec_t->p_fifo->b_die) && (p_ac3dec_t->p_fifo->b_error))
{
return 1;
}
if (parse_audblk (p_ac3dec, i)) if (parse_audblk (p_ac3dec, i))
{
intf_WarnMsg (1,"Error during ac3audioblock");
parse_auxdata (p_ac3dec);
return 1; return 1;
}
if ((p_ac3dec_t->p_fifo->b_die) && (p_ac3dec_t->p_fifo->b_error))
{
return 1;
}
if (exponent_unpack (p_ac3dec)) if (exponent_unpack (p_ac3dec))
{
intf_WarnMsg (1,"Error during ac3unpack");
parse_auxdata (p_ac3dec);
return 1; return 1;
}
bit_allocate (p_ac3dec); bit_allocate (p_ac3dec);
mantissa_unpack (p_ac3dec); mantissa_unpack (p_ac3dec);
if ((p_ac3dec_t->p_fifo->b_die) && (p_ac3dec_t->p_fifo->b_error))
{
return 1;
}
if (p_ac3dec->bsi.acmod == 0x2) if (p_ac3dec->bsi.acmod == 0x2)
rematrix (p_ac3dec); rematrix (p_ac3dec);
imdct (p_ac3dec, buffer); imdct (p_ac3dec, buffer);
// downmix (p_ac3dec, buffer);
buffer += 2*256; buffer += 2*256;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_decoder.h : ac3 decoder interface * ac3_decoder.h : ac3 decoder interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_decoder.h,v 1.4 2001/03/21 13:42:34 sam Exp $ * $Id: ac3_decoder.h,v 1.5 2001/04/20 12:14:34 reno Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Renaud Dartus <reno@videolan.org> * Renaud Dartus <reno@videolan.org>
...@@ -32,22 +32,12 @@ typedef struct ac3_sync_info_s { ...@@ -32,22 +32,12 @@ typedef struct ac3_sync_info_s {
int bit_rate; /* nominal bit rate in kbps */ int bit_rate; /* nominal bit rate in kbps */
} ac3_sync_info_t; } ac3_sync_info_t;
typedef struct ac3_byte_stream_s {
u8 * p_byte;
u8 * p_end;
void * info;
} ac3_byte_stream_t;
/**** ac3 decoder API - functions publically provided by the ac3 decoder ****/ /**** ac3 decoder API - functions publically provided by the ac3 decoder ****/
int ac3_init (ac3dec_t * p_ac3dec); int ac3_init (ac3dec_t * p_ac3dec);
int ac3_sync_frame (ac3dec_t * p_ac3dec, ac3_sync_info_t * p_sync_info); int ac3_sync_frame (ac3dec_t * p_ac3dec, ac3_sync_info_t * p_sync_info);
int ac3_decode_frame (ac3dec_t * p_ac3dec, s16 * buffer); int ac3_decode_frame (ac3dec_t * p_ac3dec, s16 * buffer);
static ac3_byte_stream_t * ac3_byte_stream (ac3dec_t * p_ac3dec);
/**** ac3 decoder API - user functions to be provided to the ac3 decoder ****/
void ac3_byte_stream_next (ac3_byte_stream_t * p_byte_stream);
/**** EVERYTHING AFTER THIS POINT IS PRIVATE ! DO NOT USE DIRECTLY ****/ /**** EVERYTHING AFTER THIS POINT IS PRIVATE ! DO NOT USE DIRECTLY ****/
...@@ -347,15 +337,6 @@ typedef struct stream_samples_s ...@@ -347,15 +337,6 @@ typedef struct stream_samples_s
float channel[6][256]; float channel[6][256];
} stream_samples_t; } stream_samples_t;
typedef struct ac3_bit_stream_s
{
u32 buffer;
int i_available;
ac3_byte_stream_t byte_stream;
unsigned int total_bits_read; /* temporary */
} ac3_bit_stream_t;
typedef struct bit_allocate_s typedef struct bit_allocate_s
{ {
s16 psd[256]; s16 psd[256];
...@@ -420,7 +401,9 @@ struct ac3dec_s ...@@ -420,7 +401,9 @@ struct ac3dec_s
*/ */
/* The bit stream structure handles the PES stream at the bit level */ /* The bit stream structure handles the PES stream at the bit level */
ac3_bit_stream_t bit_stream; bit_stream_t bit_stream;
int i_available;
unsigned int total_bits_read; /* temporary */
/* /*
* Decoder properties * Decoder properties
...@@ -436,10 +419,3 @@ struct ac3dec_s ...@@ -436,10 +419,3 @@ struct ac3dec_s
mantissa_t mantissa; mantissa_t mantissa;
imdct_t imdct; imdct_t imdct;
}; };
/**** ac3 decoder inline functions ****/
static ac3_byte_stream_t * ac3_byte_stream (ac3dec_t * p_ac3dec)
{
return &(p_ac3dec->bit_stream.byte_stream);
}
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_decoder_thread.h : ac3 decoder thread interface * ac3_decoder_thread.h : ac3 decoder thread interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_decoder_thread.h,v 1.4 2001/03/21 13:42:34 sam Exp $ * $Id: ac3_decoder_thread.h,v 1.5 2001/04/20 12:14:34 reno Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* *
...@@ -30,12 +30,14 @@ typedef struct ac3dec_thread_s ...@@ -30,12 +30,14 @@ typedef struct ac3dec_thread_s
* Thread properties * Thread properties
*/ */
vlc_thread_t thread_id; /* id for thread functions */ vlc_thread_t thread_id; /* id for thread functions */
// bit_stream_t bit_stream;
/* /*
* Input properties * Input properties
*/ */
decoder_fifo_t * p_fifo; /* stores the PES stream data */ decoder_fifo_t * p_fifo; /* stores the PES stream data */
data_packet_t * p_data; // data_packet_t * p_data;
int sync_ptr; /* sync ptr from ac3 magic header */ int sync_ptr; /* sync ptr from ac3 magic header */
adec_config_t * p_config; adec_config_t * p_config;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_downmix.c: ac3 downmix functions * ac3_downmix.c: ac3 downmix functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_downmix.c,v 1.19 2001/04/06 09:15:47 sam Exp $ * $Id: ac3_downmix.c,v 1.20 2001/04/20 12:14:34 reno Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Aaron Holtzman <aholtzma@engr.uvic.ca> * Aaron Holtzman <aholtzma@engr.uvic.ca>
...@@ -24,10 +24,15 @@ ...@@ -24,10 +24,15 @@
*****************************************************************************/ *****************************************************************************/
#include "defs.h" #include "defs.h"
#include "int_types.h" #include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "stream_control.h"
#include "input_ext-dec.h"
#include "ac3_decoder.h" #include "ac3_decoder.h"
#include "ac3_internal.h" #include "ac3_internal.h"
#include "ac3_downmix.h" #include "ac3_downmix.h"
/* Pre-scaled downmix coefficients */ /* Pre-scaled downmix coefficients */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_downmix_c.c: ac3 downmix functions * ac3_downmix_c.c: ac3 downmix functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: ac3_downmix_c.c,v 1.4 2001/04/06 09:15:47 sam Exp $ * $Id: ac3_downmix_c.c,v 1.5 2001/04/20 12:14:34 reno Exp $
* *
* Authors: Renaud Dartus <reno@videolan.org> * Authors: Renaud Dartus <reno@videolan.org>
* Aaron Holtzman <aholtzma@engr.uvic.ca> * Aaron Holtzman <aholtzma@engr.uvic.ca>
...@@ -24,7 +24,13 @@ ...@@ -24,7 +24,13 @@
#include "defs.h" #include "defs.h"
#include "int_types.h" #include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "stream_control.h"
#include "input_ext-dec.h"
#include "ac3_decoder.h" #include "ac3_decoder.h"
#include "ac3_internal.h" #include "ac3_internal.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_exponent.c: ac3 exponent calculations * ac3_exponent.c: ac3 exponent calculations
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_exponent.c,v 1.22 2001/04/06 09:15:47 sam Exp $ * $Id: ac3_exponent.c,v 1.23 2001/04/20 12:14:34 reno Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@zoy.org> * Michel Lespinasse <walken@zoy.org>
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include "intf_msg.h" #include "intf_msg.h"
#include "ac3_bit_stream.h"
#include "ac3_internal.h" #include "ac3_internal.h"
static const s16 exps_1[128] = static const s16 exps_1[128] =
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_imdct.c: ac3 DCT * ac3_imdct.c: ac3 DCT
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_imdct.c,v 1.14 2001/03/21 13:42:34 sam Exp $ * $Id: ac3_imdct.c,v 1.15 2001/04/20 12:14:34 reno Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Aaron Holtzman <aholtzma@engr.uvic.ca> * Aaron Holtzman <aholtzma@engr.uvic.ca>
...@@ -28,7 +28,14 @@ ...@@ -28,7 +28,14 @@
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include "int_types.h" #include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "stream_control.h"
#include "input_ext-dec.h"
#include "ac3_decoder.h" #include "ac3_decoder.h"
#include "ac3_internal.h" #include "ac3_internal.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_mantissa.c: ac3 mantissa computation * ac3_mantissa.c: ac3 mantissa computation
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: ac3_mantissa.c,v 1.22 2001/04/06 09:15:47 sam Exp $ * $Id: ac3_mantissa.c,v 1.23 2001/04/20 12:14:34 reno Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Aaron Holtzman <aholtzma@engr.uvic.ca> * Aaron Holtzman <aholtzma@engr.uvic.ca>
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include "defs.h" #include "defs.h"
#include <string.h> /* memcpy(), memset() */
#include "config.h" #include "config.h"
#include "common.h" #include "common.h"
#include "threads.h" #include "threads.h"
...@@ -41,7 +39,6 @@ ...@@ -41,7 +39,6 @@
#include "ac3_decoder_thread.h" #include "ac3_decoder_thread.h"
#include "ac3_internal.h" #include "ac3_internal.h"
#include "ac3_bit_stream.h"
#include "intf_msg.h" #include "intf_msg.h"
...@@ -267,7 +264,8 @@ static __inline__ u16 dither_gen (mantissa_t * p_mantissa) ...@@ -267,7 +264,8 @@ static __inline__ u16 dither_gen (mantissa_t * p_mantissa)
/* Fetch an unpacked, left justified, and properly biased/dithered mantissa value */ /* Fetch an unpacked, left justified, and properly biased/dithered mantissa value */
static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp) static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 dithflag,
u16 exp)
{ {
u32 group_code; u32 group_code;
...@@ -275,7 +273,7 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp) ...@@ -275,7 +273,7 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp)
switch (bap) switch (bap)
{ {
case 0: case 0:
if (p_ac3dec->audblk.dithflag[exp]) if (dithflag)
{ {
return ( dither_gen(&p_ac3dec->mantissa) * exp_lut[exp] ); return ( dither_gen(&p_ac3dec->mantissa) * exp_lut[exp] );
} }
...@@ -284,13 +282,15 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp) ...@@ -284,13 +282,15 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp)
case 1: case 1:
if (p_ac3dec->mantissa.q_1_pointer >= 0) if (p_ac3dec->mantissa.q_1_pointer >= 0)
{ {
return (p_ac3dec->mantissa.q_1[p_ac3dec->mantissa.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) if ((group_code = GetBits (&p_ac3dec->bit_stream,5)) >= 27)
{ {
intf_WarnMsg ( 1, "ac3dec error: invalid mantissa (1)" ); intf_WarnMsg ( 1, "ac3dec error: invalid mantissa (1)" );
} }
p_ac3dec->total_bits_read += 5;
p_ac3dec->mantissa.q_1[ 1 ] = q_1_1[ group_code ]; p_ac3dec->mantissa.q_1[ 1 ] = q_1_1[ group_code ];
p_ac3dec->mantissa.q_1[ 0 ] = q_1_2[ group_code ]; p_ac3dec->mantissa.q_1[ 0 ] = q_1_2[ group_code ];
...@@ -302,13 +302,15 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp) ...@@ -302,13 +302,15 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp)
case 2: case 2:
if (p_ac3dec->mantissa.q_2_pointer >= 0) if (p_ac3dec->mantissa.q_2_pointer >= 0)
{ {
return (p_ac3dec->mantissa.q_2[p_ac3dec->mantissa.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) if ((group_code = GetBits (&p_ac3dec->bit_stream,7)) >= 125)
{ {
intf_WarnMsg ( 1, "ac3dec error: invalid mantissa (2)" ); intf_WarnMsg ( 1, "ac3dec error: invalid mantissa (2)" );
} }
p_ac3dec->total_bits_read += 7;
p_ac3dec->mantissa.q_2[ 1 ] = q_2_1[ group_code ]; p_ac3dec->mantissa.q_2[ 1 ] = q_2_1[ group_code ];
p_ac3dec->mantissa.q_2[ 0 ] = q_2_2[ group_code ]; p_ac3dec->mantissa.q_2[ 0 ] = q_2_2[ group_code ];
...@@ -318,23 +320,26 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp) ...@@ -318,23 +320,26 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp)
return (q_2_0[ group_code ] * exp_lut[exp]); return (q_2_0[ group_code ] * exp_lut[exp]);
case 3: case 3:
if ((group_code = bitstream_get(&(p_ac3dec->bit_stream),3)) >= 7) if ((group_code = GetBits (&p_ac3dec->bit_stream,3)) >= 7)
{ {
intf_WarnMsg ( 1, "ac3dec error: invalid mantissa (3)" ); intf_WarnMsg ( 1, "ac3dec error: invalid mantissa (3)" );
} }
p_ac3dec->total_bits_read += 7;
return (q_3[group_code] * exp_lut[exp]); return (q_3[group_code] * exp_lut[exp]);
case 4: case 4:
if (p_ac3dec->mantissa.q_4_pointer >= 0) if (p_ac3dec->mantissa.q_4_pointer >= 0)
{ {
return (p_ac3dec->mantissa.q_4[p_ac3dec->mantissa.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) if ((group_code = GetBits (&p_ac3dec->bit_stream,7)) >= 121)
{ {
intf_WarnMsg ( 1, "ac3dec error: invalid mantissa (4)" ); intf_WarnMsg ( 1, "ac3dec error: invalid mantissa (4)" );
} }
p_ac3dec->total_bits_read += 7;
p_ac3dec->mantissa.q_4[ 0 ] = q_4_1[ group_code ]; p_ac3dec->mantissa.q_4[ 0 ] = q_4_1[ group_code ];
...@@ -343,16 +348,18 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp) ...@@ -343,16 +348,18 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp)
return (q_4_0[ group_code ] * exp_lut[exp]); return (q_4_0[ group_code ] * exp_lut[exp]);
case 5: case 5:
if ((group_code = bitstream_get(&(p_ac3dec->bit_stream),4)) >= 15) if ((group_code = GetBits (&p_ac3dec->bit_stream,4)) >= 15)
{ {
intf_WarnMsg ( 1, "ac3dec error: invalid mantissa (5)" ); intf_WarnMsg ( 1, "ac3dec error: invalid mantissa (5)" );
} }
p_ac3dec->total_bits_read += 4;
return (q_5[group_code] * exp_lut[exp]); return (q_5[group_code] * exp_lut[exp]);
default: default:
group_code = bitstream_get(&(p_ac3dec->bit_stream),qnttztab[bap]); group_code = GetBits (&p_ac3dec->bit_stream,qnttztab[bap]);
group_code <<= 16 - qnttztab[bap]; group_code <<= 16 - qnttztab[bap];
p_ac3dec->total_bits_read += qnttztab[bap];
return ((s16)(group_code) * exp_lut[exp]); return ((s16)(group_code) * exp_lut[exp]);
} }
...@@ -371,7 +378,8 @@ static __inline__ void uncouple_channel (ac3dec_t * p_ac3dec, u32 ch) ...@@ -371,7 +378,8 @@ static __inline__ void uncouple_channel (ac3dec_t * p_ac3dec, u32 ch)
{ {
if (!p_ac3dec->audblk.cplbndstrc[sub_bnd++]) if (!p_ac3dec->audblk.cplbndstrc[sub_bnd++])
{ {
cpl_exp_tmp = p_ac3dec->audblk.cplcoexp[ch][bnd] + 3 * p_ac3dec->audblk.mstrcplco[ch]; cpl_exp_tmp = p_ac3dec->audblk.cplcoexp[ch][bnd] +
3 * p_ac3dec->audblk.mstrcplco[ch];
if (p_ac3dec->audblk.cplcoexp[ch][bnd] == 15) if (p_ac3dec->audblk.cplcoexp[ch][bnd] == 15)
{ {
cpl_mant_tmp = (p_ac3dec->audblk.cplcomant[ch][bnd]) << 11; cpl_mant_tmp = (p_ac3dec->audblk.cplcomant[ch][bnd]) << 11;
...@@ -422,18 +430,21 @@ void mantissa_unpack (ac3dec_t * p_ac3dec) ...@@ -422,18 +430,21 @@ void mantissa_unpack (ac3dec_t * p_ac3dec)
{ {
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++) for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++)
{ {
p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j]); p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j],
p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j]);
} }
} }
/* 2 */ /* 2 */
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++) for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++)
{ {
p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j]); p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j],
p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j]);
} }
for (j = p_ac3dec->audblk.cplstrtmant; j < p_ac3dec->audblk.cplendmant; j++) for (j = p_ac3dec->audblk.cplstrtmant; j < p_ac3dec->audblk.cplendmant; j++)
{ {
p_ac3dec->audblk.cplfbw[j] = float_get (p_ac3dec, p_ac3dec->audblk.cpl_bap[j], p_ac3dec->audblk.cpl_exp[j]); p_ac3dec->audblk.cplfbw[j] = float_get (p_ac3dec, p_ac3dec->audblk.cpl_bap[j], 0,
p_ac3dec->audblk.cpl_exp[j]);
} }
uncouple_channel (p_ac3dec, i); uncouple_channel (p_ac3dec, i);
...@@ -442,7 +453,8 @@ void mantissa_unpack (ac3dec_t * p_ac3dec) ...@@ -442,7 +453,8 @@ void mantissa_unpack (ac3dec_t * p_ac3dec)
{ {
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++) for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++)
{ {
p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j]); p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j],
p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j]);
} }
if (p_ac3dec->audblk.chincpl[i]) if (p_ac3dec->audblk.chincpl[i])
{ {
...@@ -456,7 +468,8 @@ void mantissa_unpack (ac3dec_t * p_ac3dec) ...@@ -456,7 +468,8 @@ void mantissa_unpack (ac3dec_t * p_ac3dec)
{ {
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++) for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++)
{ {
p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j]); p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j],
p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j]);
} }
} }
} }
...@@ -466,7 +479,8 @@ void mantissa_unpack (ac3dec_t * p_ac3dec) ...@@ -466,7 +479,8 @@ void mantissa_unpack (ac3dec_t * p_ac3dec)
/* There are always 7 mantissas for lfe, no dither for lfe */ /* There are always 7 mantissas for lfe, no dither for lfe */
for (j = 0; j < 7; j++) for (j = 0; j < 7; j++)
{ {
p_ac3dec->coeffs.lfe[j] = float_get (p_ac3dec, p_ac3dec->audblk.lfe_bap[j], p_ac3dec->audblk.lfe_exp[j]); p_ac3dec->coeffs.lfe[j] = float_get (p_ac3dec, p_ac3dec->audblk.lfe_bap[j], 0,
p_ac3dec->audblk.lfe_exp[j]);
} }
} }
} }
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_rematrix.c: ac3 audio rematrixing * ac3_rematrix.c: ac3 audio rematrixing
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_rematrix.c,v 1.12 2001/03/21 13:42:34 sam Exp $ * $Id: ac3_rematrix.c,v 1.13 2001/04/20 12:14:34 reno Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Aaron Holtzman <aholtzma@engr.uvic.ca> * Aaron Holtzman <aholtzma@engr.uvic.ca>
...@@ -23,7 +23,14 @@ ...@@ -23,7 +23,14 @@
*****************************************************************************/ *****************************************************************************/
#include "defs.h" #include "defs.h"
#include "int_types.h" #include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "stream_control.h"
#include "input_ext-dec.h"
#include "ac3_decoder.h" #include "ac3_decoder.h"
#include "ac3_internal.h" #include "ac3_internal.h"
......
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