Commit c6313a9b authored by Michel Lespinasse's avatar Michel Lespinasse

Separation du decodeur ac3 et de la partie specifique a videolan

Les interfaces du deco ac3 ne sont pas encore bien propres et documentees
mais ca viendra dans un second temps. Les fichiers ac3 ne dependent plus
d'includes videolan. C'est deja une bonne premiere etape.

Au niveau du bitstream compresse, l'interface avec le decodeur ac3 ne se fait
plus par le fichier decoder_fifo.h. En effet, le decodeur ac3 a besoin de
connaitre la structure exact d'un bitstream_t, donc cette interface n'etait
pas la plus propre. La nouvelle interface se compose d'une fonction
ac3_byte_stream_next (ac3_byte_stream_t * p_byte_stream) que le decodeur
ac3 appelle lorsqu'il a besoin d'un nouveau buffer de donnees compressees.

ac3_byte_stream_t est une structure comprenant les champs
u8 * p_byte (pointeur sur le debut du buffer),
u8 * p_end (pointeur sur la fin du buffer),
void * info (utilisation libre pour implementer ac3_byte_stream_next)

L'implementation actuelle de ac3_byte_stream_next () dans ac3_decoder_thread.c
fait un peu double emploi avec misc/decoder_fifo.c mais je reglerai tout ca
plus tard.
parent 7373cdfb
......@@ -324,25 +324,37 @@ typedef struct stream_samples_s
*****************************************************************************/
typedef s16 ac3dec_frame_t[ AC3DEC_FRAME_SIZE ];
typedef struct ac3_byte_stream_s
{
u8 * p_byte;
u8 * p_end;
void * info;
} ac3_byte_stream_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;
/*****************************************************************************
* ac3dec_t : ac3 decoder descriptor
*****************************************************************************/
typedef struct ac3dec_s
{
boolean_t b_invalid; /* `invalid' flag */
/*
* Input properties
*/
/* The bit stream structure handles the PES stream at the bit level */
bit_stream_t bit_stream;
ac3_bit_stream_t bit_stream;
/*
* Decoder properties
*/
unsigned int total_bits_read;
syncinfo_t syncinfo;
bsi_t bsi;
audblk_t audblk;
......@@ -353,3 +365,5 @@ typedef struct ac3dec_s
} ac3dec_t;
int ac3_audio_block (ac3dec_t * p_ac3dec, s16 * buffer);
void ac3_byte_stream_next (ac3_byte_stream_t * p_byte_stream);
......@@ -19,6 +19,8 @@ typedef struct ac3dec_thread_s
* Input properties
*/
decoder_fifo_t fifo; /* stores the PES stream data */
input_thread_t * p_input;
ts_packet_t * p_ts;
/*
* Decoder properties
......
......@@ -12,15 +12,7 @@
* Basic types definitions
*****************************************************************************/
/* Basic types definitions */
typedef signed char s8;
typedef signed short s16;
typedef signed int s32;
typedef signed long long s64;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
#include "int_types.h"
typedef u8 byte_t;
......
/* Basic types definitions */
typedef unsigned char u8;
typedef signed char s8;
typedef unsigned short u16;
typedef signed short s16;
typedef unsigned int u32;
typedef signed int s32;
typedef unsigned long long u64;
typedef signed long long s64;
#include <unistd.h> /* getpid() */
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* malloc(), free() */
#include <sys/soundcard.h> /* "audio_output.h" */
#include <sys/types.h>
#include <sys/uio.h> /* "input.h" */
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h" /* "input_netlist.h" */
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "input.h" /* pes_packet_t */
#include "input_netlist.h" /* input_NetlistFreePES() */
#include "decoder_fifo.h" /* DECODER_FIFO_(ISEMPTY|START|INCSTART)() */
#include "audio_output.h"
#include "int_types.h"
#include "ac3_decoder.h"
#include "ac3_bit_allocate.h"
......@@ -29,6 +8,7 @@ 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[]);
......@@ -53,16 +33,16 @@ static s16 fastgain[] = { 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400
static 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 };
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,
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 };
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,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 28, 29,
......
static __inline__ u8 GetByte (ac3_byte_stream_t * p_byte_stream)
{
/* Are there some bytes left in the current buffer ? */
if (p_byte_stream->p_byte >= p_byte_stream->p_end) {
/* no, switch to next buffer */
ac3_byte_stream_next (p_byte_stream);
}
return *(p_byte_stream->p_byte++);
}
/*****************************************************************************
* NeedBits : reads i_bits new bits in the bit stream and stores them in the
* bit buffer
*****************************************************************************
* - i_bits must be less or equal 32 !
* - There is something important to notice with that function : if the number
* of bits available in the bit buffer when calling NeedBits() is greater than
* 24 (i_available > 24) but less than the number of needed bits
* (i_available < i_bits), the byte returned by GetByte() will be shifted with
* a negative value and the number of bits available in the bit buffer will be
* set to more than 32 !
*****************************************************************************/
static __inline__ void NeedBits (ac3_bit_stream_t * p_bit_stream, int i_bits)
{
while (p_bit_stream->i_available < i_bits) {
p_bit_stream->buffer |=
((u32)GetByte (&p_bit_stream->byte_stream)) << (24 - p_bit_stream->i_available);
p_bit_stream->i_available += 8;
}
}
/*****************************************************************************
* DumpBits : removes i_bits bits from the bit buffer
*****************************************************************************
* - i_bits <= i_available
* - i_bits < 32 (because (u32 << 32) <=> (u32 = u32))
*****************************************************************************/
static __inline__ void DumpBits (ac3_bit_stream_t * p_bit_stream, int i_bits)
{
p_bit_stream->buffer <<= i_bits;
p_bit_stream->i_available -= i_bits;
p_bit_stream->total_bits_read += i_bits;
}
#include <math.h>
#include <sys/uio.h> /* "input.h" */
#include "common.h"
#include "config.h"
#include "vlc_thread.h"
#include "mtime.h"
#include "input.h"
#include "decoder_fifo.h"
#include "audio_output.h"
#include "int_types.h"
#include "ac3_decoder.h"
#include "ac3_parse.h"
#include "ac3_exponent.h"
......@@ -21,13 +11,10 @@
int ac3_audio_block (ac3dec_t * p_ac3dec, s16 * buffer)
{
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
if (exponent_unpack( p_ac3dec ))
return 1;
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
return 1;
if ( p_ac3dec->bsi.acmod == 0x2 )
rematrix( p_ac3dec );
imdct( p_ac3dec );
......
......@@ -85,10 +85,9 @@ ac3dec_thread_t * ac3dec_CreateThread( input_thread_t * p_input )
p_ac3dec->fifo.i_start = 0;
p_ac3dec->fifo.i_end = 0;
/* Initialize the bit stream structure */
p_ac3dec->ac3_decoder.bit_stream.p_input = p_input;
p_ac3dec->ac3_decoder.bit_stream.p_decoder_fifo = &p_ac3dec->fifo;
p_ac3dec->ac3_decoder.bit_stream.fifo.buffer = 0;
p_ac3dec->ac3_decoder.bit_stream.fifo.i_available = 0;
p_ac3dec->p_input = p_input;
p_ac3dec->ac3_decoder.bit_stream.buffer = 0;
p_ac3dec->ac3_decoder.bit_stream.i_available = 0;
/*
* Initialize the output properties
......@@ -139,14 +138,8 @@ static __inline__ int decode_find_sync( ac3dec_thread_t * p_ac3dec )
{
while ( (!p_ac3dec->b_die) && (!p_ac3dec->b_error) )
{
NeedBits( &(p_ac3dec->ac3_decoder.bit_stream), 16 );
if ( (p_ac3dec->ac3_decoder.bit_stream.fifo.buffer >> (32 - 16)) == 0x0b77 )
{
DumpBits( &(p_ac3dec->ac3_decoder.bit_stream), 16 );
p_ac3dec->ac3_decoder.total_bits_read = 16;
return( 0 );
}
DumpBits( &(p_ac3dec->ac3_decoder.bit_stream), 1 ); /* XXX?? */
if (! (ac3_test_sync (&p_ac3dec->ac3_decoder)))
return 0;
}
return( -1 );
}
......@@ -172,9 +165,12 @@ static int InitThread( ac3dec_thread_t * p_ac3dec )
}
vlc_cond_wait( &p_ac3dec->fifo.data_wait, &p_ac3dec->fifo.data_lock );
}
p_ac3dec->ac3_decoder.bit_stream.p_ts = DECODER_FIFO_START( p_ac3dec->fifo )->p_first_ts;
p_ac3dec->ac3_decoder.bit_stream.p_byte = p_ac3dec->ac3_decoder.bit_stream.p_ts->buffer + p_ac3dec->ac3_decoder.bit_stream.p_ts->i_payload_start;
p_ac3dec->ac3_decoder.bit_stream.p_end = p_ac3dec->ac3_decoder.bit_stream.p_ts->buffer + p_ac3dec->ac3_decoder.bit_stream.p_ts->i_payload_end;
p_ac3dec->p_ts = DECODER_FIFO_START( p_ac3dec->fifo )->p_first_ts;
p_ac3dec->ac3_decoder.bit_stream.byte_stream.p_byte =
p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_start;
p_ac3dec->ac3_decoder.bit_stream.byte_stream.p_end =
p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_end;
p_ac3dec->ac3_decoder.bit_stream.byte_stream.info = p_ac3dec;
vlc_mutex_unlock( &p_ac3dec->fifo.data_lock );
aout_fifo.i_type = AOUT_ADEC_STEREO_FIFO;
......@@ -214,8 +210,6 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
{
int i;
p_ac3dec->ac3_decoder.b_invalid = 0;
decode_find_sync( p_ac3dec );
if ( DECODER_FIFO_START(p_ac3dec->fifo)->b_has_pts )
......@@ -245,12 +239,7 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
default: /* XXX?? */
fprintf( stderr, "ac3dec debug: invalid fscod\n" );
p_ac3dec->ac3_decoder.b_invalid = 1;
break;
}
if ( p_ac3dec->ac3_decoder.b_invalid ) /* XXX?? */
{
continue;
continue;
}
parse_bsi( &p_ac3dec->ac3_decoder );
......@@ -301,7 +290,7 @@ static void ErrorThread( ac3dec_thread_t * p_ac3dec )
/* Trash all received PES packets */
while( !DECODER_FIFO_ISEMPTY(p_ac3dec->fifo) )
{
input_NetlistFreePES( p_ac3dec->ac3_decoder.bit_stream.p_input, DECODER_FIFO_START(p_ac3dec->fifo) );
input_NetlistFreePES( p_ac3dec->p_input, DECODER_FIFO_START(p_ac3dec->fifo) );
DECODER_FIFO_INCSTART( p_ac3dec->fifo );
}
......@@ -336,3 +325,61 @@ static void EndThread( ac3dec_thread_t * p_ac3dec )
intf_DbgMsg( "ac3dec debug: ac3 decoder thread %p destroyed\n", 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 {
/* We were reading the last TS packet of this PES packet... It's
* time to jump to the next PES packet */
if (p_ac3dec->p_ts->p_next_ts == NULL) {
/* We are going to read/write the start and end indexes of the
* decoder fifo and to use the fifo's conditional variable,
* that's why we need to take the lock before */
vlc_mutex_lock (&p_ac3dec->fifo.data_lock);
/* Is the input thread dying ? */
if (p_ac3dec->p_input->b_die) {
vlc_mutex_unlock (&(p_ac3dec->fifo.data_lock));
return;
}
/* We should increase the start index of the decoder fifo, but
* if we do this now, the input thread could overwrite the
* pointer to the current PES packet, and we weren't able to
* give it back to the netlist. That's why we free the PES
* packet first. */
input_NetlistFreePES (p_ac3dec->p_input, DECODER_FIFO_START(p_ac3dec->fifo) );
DECODER_FIFO_INCSTART (p_ac3dec->fifo);
while (DECODER_FIFO_ISEMPTY(p_ac3dec->fifo)) {
vlc_cond_wait (&p_ac3dec->fifo.data_wait, &p_ac3dec->fifo.data_lock );
if (p_ac3dec->p_input->b_die) {
vlc_mutex_unlock (&(p_ac3dec->fifo.data_lock));
return;
}
}
/* The next byte could be found in the next PES packet */
p_ac3dec->p_ts = DECODER_FIFO_START (p_ac3dec->fifo)->p_first_ts;
/* We can release the fifo's data lock */
vlc_mutex_unlock (&p_ac3dec->fifo.data_lock);
}
/* Perhaps the next TS packet of the current PES packet contains
* real data (ie its payload's size is greater than 0) */
else {
p_ac3dec->p_ts = p_ac3dec->p_ts->p_next_ts;
}
} while (p_ac3dec->p_ts->i_payload_start == p_ac3dec->p_ts->i_payload_end);
p_byte_stream->p_byte =
p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_start;
p_byte_stream->p_end =
p_ac3dec->p_ts->buffer + p_ac3dec->p_ts->i_payload_end;
}
#include <unistd.h> /* getpid() */
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* malloc(), free() */
#include <sys/soundcard.h> /* "audio_output.h" */
#include <sys/types.h>
#include <sys/uio.h> /* "input.h" */
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h" /* "input_netlist.h" */
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "input.h" /* pes_packet_t */
#include "input_netlist.h" /* input_NetlistFreePES() */
#include "decoder_fifo.h" /* DECODER_FIFO_(ISEMPTY|START|INCSTART)() */
#include "audio_output.h"
#include "int_types.h"
#include "ac3_decoder.h"
#include "ac3_downmix.h"
......@@ -29,7 +8,6 @@ typedef struct prefs_s
{
u16 use_dolby_surround;
u16 dual_mono_channel_select;
} prefs_t;
prefs_t global_prefs = {0,0};
......
#include <unistd.h> /* getpid() */
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* malloc(), free() */
#include <sys/soundcard.h> /* "audio_output.h" */
#include <sys/types.h>
#include <sys/uio.h> /* "input.h" */
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h" /* "input_netlist.h" */
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "input.h" /* pes_packet_t */
#include "input_netlist.h" /* input_NetlistFreePES() */
#include "decoder_fifo.h" /* DECODER_FIFO_(ISEMPTY|START|INCSTART)() */
#include "audio_output.h"
#include "int_types.h"
#include "ac3_decoder.h"
#include "ac3_bit_stream.h"
#include "ac3_exponent.h"
static const s16 exps_1[128] = { -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3 };
static const s16 exps_2[128] = { -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, -2, -2, -2 };
static const s16 exps_3[128] = { -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0 };
static __inline__ void exp_unpack_ch( ac3dec_t * p_ac3dec, u16 type, u16 expstr, u16 ngrps, u16 initial_exp, u16 exps[], u16 * dest )
static const s16 exps_1[128] =
{ -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,
-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,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
0, 0, 0 };
static const s16 exps_2[128] =
{ -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
0, 0, 0 };
static const s16 exps_3[128] =
{ -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
0, 0, 0 };
#define UNPACK_FBW 1
#define UNPACK_CPL 2
#define UNPACK_LFE 4
static __inline__ int exp_unpack_ch( ac3dec_t * p_ac3dec, u16 type, u16 expstr, u16 ngrps, u16 initial_exp, u16 exps[], u16 * dest )
{
u16 i,j;
s16 exp_acc;
if ( expstr == EXP_REUSE )
{
return;
return 0;
}
/* Handle the initial absolute exponent */
......@@ -53,87 +57,105 @@ static __inline__ void exp_unpack_ch( ac3dec_t * p_ac3dec, u16 type, u16 expstr,
/* Loop through the groups and fill the dest array appropriately */
switch ( expstr )
{
case EXP_D45:
for ( i = 0; i < ngrps; i++ )
{
if ( exps[i] > 124 )
{
fprintf( stderr, "ac3dec debug: invalid exponent\n" );
p_ac3dec->b_invalid = 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
}
break;
case EXP_D25:
for ( i = 0; i < ngrps; i++ )
{
if ( exps[i] > 124 )
{
fprintf( stderr, "ac3dec debug: invalid exponent\n" );
p_ac3dec->b_invalid = 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
}
break;
case EXP_D15:
for ( i = 0; i < ngrps; i++ )
{
if ( exps[i] > 124 )
{
fprintf( stderr, "ac3dec debug: invalid exponent\n" );
p_ac3dec->b_invalid = 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
}
break;
case EXP_D15: /* 1 */
for ( i = 0; i < ngrps; i++ )
{
if ( exps[i] > 124 )
{
fprintf( stderr, "ac3dec debug: invalid exponent\n" );
return 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
}
break;
case EXP_D25: /* 2 */
for ( i = 0; i < ngrps; i++ )
{
if ( exps[i] > 124 )
{
fprintf( stderr, "ac3dec debug: invalid exponent\n" );
return 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
}
break;
case EXP_D45: /* 3 */
for ( i = 0; i < ngrps; i++ )
{
if ( exps[i] > 124 )
{
fprintf( stderr, "ac3dec debug: invalid exponent\n" );
return 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
}
break;
}
return 0;
}
void exponent_unpack( ac3dec_t * p_ac3dec )
int exponent_unpack( ac3dec_t * p_ac3dec )
{
u16 i;
for ( i = 0; i < p_ac3dec->bsi.nfchans; i++ )
{
exp_unpack_ch( p_ac3dec, UNPACK_FBW, p_ac3dec->audblk.chexpstr[i], p_ac3dec->audblk.nchgrps[i], p_ac3dec->audblk.exps[i][0], &p_ac3dec->audblk.exps[i][1], p_ac3dec->audblk.fbw_exp[i] );
if (exp_unpack_ch( p_ac3dec, UNPACK_FBW, p_ac3dec->audblk.chexpstr[i],
p_ac3dec->audblk.nchgrps[i],
p_ac3dec->audblk.exps[i][0],
&p_ac3dec->audblk.exps[i][1],
p_ac3dec->audblk.fbw_exp[i] ))
return 1;
}
if ( p_ac3dec->audblk.cplinu )
{
exp_unpack_ch( p_ac3dec, UNPACK_CPL, p_ac3dec->audblk.cplexpstr, p_ac3dec->audblk.ncplgrps, p_ac3dec->audblk.cplabsexp << 1, p_ac3dec->audblk.cplexps, &p_ac3dec->audblk.cpl_exp[p_ac3dec->audblk.cplstrtmant] );
if (exp_unpack_ch( p_ac3dec, UNPACK_CPL, p_ac3dec->audblk.cplexpstr,
p_ac3dec->audblk.ncplgrps,
p_ac3dec->audblk.cplabsexp << 1,
p_ac3dec->audblk.cplexps,
&p_ac3dec->audblk.cpl_exp[p_ac3dec->audblk.cplstrtmant] ))
return 1;
}
if ( p_ac3dec->bsi.lfeon )
{
exp_unpack_ch( p_ac3dec, UNPACK_LFE, p_ac3dec->audblk.lfeexpstr, 2, p_ac3dec->audblk.lfeexps[0], &p_ac3dec->audblk.lfeexps[1], p_ac3dec->audblk.lfe_exp );
if (exp_unpack_ch( p_ac3dec, UNPACK_LFE, p_ac3dec->audblk.lfeexpstr,
2, p_ac3dec->audblk.lfeexps[0],
&p_ac3dec->audblk.lfeexps[1],
p_ac3dec->audblk.lfe_exp ))
return 1;
}
return 0;
}
#define UNPACK_FBW 1
#define UNPACK_CPL 2
#define UNPACK_LFE 4
void exponent_unpack( ac3dec_t * );
int exponent_unpack( ac3dec_t * );
#include <math.h>
#include <sys/uio.h> /* "input.h" */
#include "common.h"
#include "config.h"
#include "vlc_thread.h"
#include "mtime.h"
#include "input.h"
#include "decoder_fifo.h"
#include "audio_output.h"
#include "int_types.h"
#include "ac3_decoder.h"
#include "ac3_imdct.h"
......
#include <unistd.h> /* getpid() */
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* malloc(), free() */
#include <sys/soundcard.h> /* "audio_output.h" */
#include <sys/types.h>
#include <sys/uio.h> /* "input.h" */
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h" /* "input_netlist.h" */
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "input.h" /* pes_packet_t */
#include "input_netlist.h" /* input_NetlistFreePES() */
#include "decoder_fifo.h" /* DECODER_FIFO_(ISEMPTY|START|INCSTART)() */
#include "audio_output.h"
#include "int_types.h"
#include "ac3_decoder.h"
#include "ac3_mantissa.h"
static float q_1_0[ 32 ] = { (-2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, (2 << 15) / 3, (2 << 15) / 3, (2 << 15) / 3, (2 << 15) / 3, (2 << 15) / 3, (2 << 15) / 3, (2 << 15) / 3, (2 << 15) / 3, (2 << 15) / 3, 0, 0, 0, 0, 0 };
static float q_1_1[ 32 ] = { (-2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, 0, 0, 0, (2 << 15) / 3, (2 << 15) / 3, (2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, 0, 0, 0, (2 << 15) / 3, (2 << 15) / 3, (2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, (-2 << 15) / 3, 0, 0, 0, (2 << 15) / 3, (2 << 15) / 3, (2 << 15) / 3, 0, 0, 0, 0, 0 };
static float q_1_2[ 32 ] = { (-2 << 15) / 3, 0, (2 << 15) / 3, (-2 << 15) / 3, 0, (2 << 15) / 3, (-2 << 15) / 3, 0, (2 << 15) / 3, (-2 << 15) / 3, 0, (2 << 15) / 3, (-2 << 15) / 3, 0, (2 << 15) / 3, (-2 << 15) / 3, 0, (2 << 15) / 3, (-2 << 15) / 3, 0, (2 << 15) / 3, (-2 << 15) / 3, 0, (2 << 15) / 3, (-2 << 15) / 3, 0, (2 << 15) / 3, 0, 0, 0, 0, 0 };
static float q_2_0[ 128 ] = { (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, 0, 0, 0 };
static float q_2_1[ 128 ] = { (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, 0, 0, 0, 0, 0, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, 0, 0, 0, 0, 0, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, 0, 0, 0, 0, 0, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, 0, 0, 0, 0, 0, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, (-2 << 15) / 5, 0, 0, 0, 0, 0, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (2 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, (4 << 15) / 5, 0, 0, 0 };
static float q_2_2[ 128 ] = { (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, (-4 << 15) / 5, (-2 << 15) / 5, 0, (2 << 15) / 5, (4 << 15) / 5, 0, 0, 0 };
static float q_4_0[ 128 ] = { (-10 << 15) / 11, (-10 << 15) / 11, (-10 << 15) / 11, (-10 << 15) / 11, (-10 << 15) / 11, (-10 << 15) / 11, (-10 << 15) / 11, (-10 << 15) / 11, (-10 << 15) / 11, (-10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-8 << 15) / 11, (-8 << 15) / 11, (-8 << 15) / 11, (-8 << 15) / 11, (-8 << 15) / 11, (-8 << 15) / 11, (-8 << 15) / 11, (-8 << 15) / 11, (-8 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-6 << 15) / 11, (-6 << 15) / 11, (-6 << 15) / 11, (-6 << 15) / 11, (-6 << 15) / 11, (-6 << 15) / 11, (-6 << 15) / 11, (-6 << 15) / 11, (-6 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-4 << 15) / 11, (-4 << 15) / 11, (-4 << 15) / 11, (-4 << 15) / 11, (-4 << 15) / 11, (-4 << 15) / 11, (-4 << 15) / 11, (-4 << 15) / 11, (-4 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, (-2 << 15) / 11, (-2 << 15) / 11, (-2 << 15) / 11, (-2 << 15) / 11, (-2 << 15) / 11, (-2 << 15) / 11, (-2 << 15) / 11, (-2 << 15) / 11, (-2 << 15) / 11, (-2 << 15) / 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (2 << 15) / 11, (2 << 15) / 11, (2 << 15) / 11, (2 << 15) / 11, (2 << 15) / 11, (2 << 15) / 11, (2 << 15) / 11, (2 << 15) / 11, (2 << 15) / 11, (2 << 15) / 11, (2 << 15) / 11, (4 << 15) / 11, (4 << 15) / 11, (4 << 15) / 11, (4 << 15) / 11, (4 << 15) / 11, (4 << 15) / 11, (4 << 15) / 11, (4 << 15) / 11, (4 << 15) / 11, (4 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (6 << 15) / 11, (6 << 15) / 11, (6 << 15) / 11, (6 << 15) / 11, (6 << 15) / 11, (6 << 15) / 11, (6 << 15) / 11, (6 << 15) / 11, (6 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (8 << 15) / 11, (8 << 15) / 11, (8 << 15) / 11, (8 << 15) / 11, (8 << 15) / 11, (8 << 15) / 11, (8 << 15) / 11, (8 << 15) / 11, (8 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (10 << 15) / 11, (10 << 15) / 11, (10 << 15) / 11, (10 << 15) / 11, (10 << 15) / 11, (10 << 15) / 11, (10 << 15) / 11, (10 << 15) / 11, (10 << 15) / 11, (10 << 15) / 11, 0, 0, 0, 0, 0, 0, 0 };
static float q_4_1[ 128 ] = { (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, (-10 << 15) / 11, (-8 << 15) / 11, (-6 << 15) / 11, (-4 << 15) / 11, (-2 << 15) / 11, 0, (2 << 15) / 11, (4 << 15) / 11, (6 << 15) / 11, (8 << 15) / 11, (10 << 15) / 11, 0, 0, 0, 0, 0, 0, 0 };
#include "ac3_bit_stream.h"
#define Q0 ((-2 << 15) / 3)
#define Q1 (0)
#define Q2 ((2 << 15) / 3)
static 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 ] = { 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 ] = { Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
0, 0, 0, 0, 0 };
#undef Q0
#undef Q1
#undef Q2
#define Q0 ((-4 << 15) / 5)
#define Q1 ((-2 << 15) / 5)
#define Q2 (0)
#define Q3 ((2 << 15) / 5)
#define Q4 ((4 << 15) / 5)
static 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,
Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,
Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,
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 ] =
{ 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,
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,
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 ] =
{ 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,
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,
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,
0, 0, 0 };
#undef Q0
#undef Q1
#undef Q2
#undef Q3
#undef Q4
#define Q0 ((-10 << 15) / 11)
#define Q1 ((-8 << 15) / 11)
#define Q2 ((-6 << 15) / 11)
#define Q3 ((-4 << 15) / 11)
#define Q4 ((-2 << 15) / 11)
#define Q5 (0)
#define Q6 ((2 << 15) / 11)
#define Q7 ((4 << 15) / 11)
#define Q8 ((6 << 15) / 11)
#define Q9 ((8 << 15) / 11)
#define QA ((10 << 15) / 11)
static 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,
Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3,
Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4,
Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5,
Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6,
Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7,
Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8,
Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9,
QA, QA, QA, QA, QA, QA, QA, QA, QA, QA, QA,
0, 0, 0, 0, 0, 0, 0};
static 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,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
0, 0, 0, 0, 0, 0, 0};
#undef Q0
#undef Q1
#undef Q2
#undef Q3
#undef Q4
#undef Q5
#undef Q6
#undef Q7
#undef Q8
#undef Q9
#undef QA
/* Lookup tables of 0.16 two's complement quantization values */
/*
s32 q_1[3] = {( -2 << 15)/3, 0 ,( 2 << 15)/3 };
s32 q_2[5] = {( -4 << 15)/5,( -2 << 15)/5, 0 ,
( 2 << 15)/5,( 4 << 15)/5};
*/
static float q_3[7] = {( -6 << 15)/7,( -4 << 15)/7,( -2 << 15)/7,
0 ,( 2 << 15)/7,( 4 << 15)/7,
( 6 << 15)/7};
/*
s32 q_4[11] = {(-10 << 15)/11,(-8 << 15)/11,(-6 << 15)/11,
( -4 << 15)/11,(-2 << 15)/11, 0 ,
( 2 << 15)/11,( 4 << 15)/11,( 6 << 15)/11,
( 8 << 15)/11,(10 << 15)/11};
*/
static float q_5[15] = {(-14 << 15)/15,(-12 << 15)/15,(-10 << 15)/15,
( -8 << 15)/15,( -6 << 15)/15,( -4 << 15)/15,
( -2 << 15)/15, 0 ,( 2 << 15)/15,
( 4 << 15)/15,( 6 << 15)/15,( 8 << 15)/15,
( 10 << 15)/15,( 12 << 15)/15,( 14 << 15)/15};
static float q_3[7] = { (-6 << 15)/7, (-4 << 15)/7, (-2 << 15)/7,
0 , ( 2 << 15)/7, ( 4 << 15)/7,
( 6 << 15)/7};
static float q_5[15] = { (-14 << 15)/15, (-12 << 15)/15, (-10 << 15)/15,
( -8 << 15)/15, ( -6 << 15)/15, ( -4 << 15)/15,
( -2 << 15)/15, 0 , ( 2 << 15)/15,
( 4 << 15)/15, ( 6 << 15)/15, ( 8 << 15)/15,
( 10 << 15)/15, ( 12 << 15)/15, ( 14 << 15)/15};
/* These store the persistent state of the packed mantissas */
static float q_1[2];
......@@ -69,7 +125,7 @@ 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] = { 0, 0, 0, 3, 0 , 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16};
static u16 qnttztab[16] = { 0, 0, 0, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16};
static float exp_lut[ 25 ] =
{
......@@ -117,14 +173,12 @@ static __inline__ float float_get( ac3dec_t * p_ac3dec, u16 bap, u16 exp )
return( q_1[q_1_pointer--] * exp_lut[exp] );
}
NeedBits( &(p_ac3dec->bit_stream), 5 );
group_code = p_ac3dec->bit_stream.fifo.buffer >> (32 - 5);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 5);
DumpBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->total_bits_read += 5;
if ( group_code > 26 )
{
fprintf( stderr, "ac3dec debug: invalid mantissa\n" );
p_ac3dec->b_invalid = 1;
}
q_1[ 1 ] = q_1_1[ group_code ];
......@@ -140,14 +194,12 @@ static __inline__ float float_get( ac3dec_t * p_ac3dec, u16 bap, u16 exp )
return( q_2[q_2_pointer--] * exp_lut[exp] );
}
NeedBits( &(p_ac3dec->bit_stream), 7 );
group_code = p_ac3dec->bit_stream.fifo.buffer >> (32 - 7);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 7);
DumpBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->total_bits_read += 7;
if ( group_code > 124 )
{
fprintf( stderr, "ac3dec debug: invalid mantissa\n" );
p_ac3dec->b_invalid = 1;
}
q_2[ 1 ] = q_2_1[ group_code ];
......@@ -159,14 +211,12 @@ static __inline__ float float_get( ac3dec_t * p_ac3dec, u16 bap, u16 exp )
case 3:
NeedBits( &(p_ac3dec->bit_stream), 3 );
group_code = p_ac3dec->bit_stream.fifo.buffer >> (32 - 3);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 3);
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
if ( group_code > 6 )
{
fprintf( stderr, "ac3dec debug: invalid mantissa\n" );
p_ac3dec->b_invalid = 1;
}
return( q_3[group_code] * exp_lut[exp] );
......@@ -177,14 +227,12 @@ static __inline__ float float_get( ac3dec_t * p_ac3dec, u16 bap, u16 exp )
return( q_4[q_4_pointer--] * exp_lut[exp] );
}
NeedBits( &(p_ac3dec->bit_stream), 7 );
group_code = p_ac3dec->bit_stream.fifo.buffer >> (32 - 7);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 7);
DumpBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->total_bits_read += 7;
if ( group_code > 120 )
{
fprintf( stderr, "ac3dec debug: invalid mantissa\n" );
p_ac3dec->b_invalid = 1;
}
q_4[ 0 ] = q_4_1[ group_code ];
......@@ -195,23 +243,20 @@ static __inline__ float float_get( ac3dec_t * p_ac3dec, u16 bap, u16 exp )
case 5:
NeedBits( &(p_ac3dec->bit_stream), 4 );
group_code = p_ac3dec->bit_stream.fifo.buffer >> (32 - 4);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 4);
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
if ( group_code > 14 )
{
fprintf( stderr, "ac3dec debug: invalid mantissa\n" );
p_ac3dec->b_invalid = 1;
}
return( q_5[group_code] * exp_lut[exp] );
default:
NeedBits( &(p_ac3dec->bit_stream), qnttztab[bap] );
group_code = (((s32)(p_ac3dec->bit_stream.fifo.buffer)) >> (32 - qnttztab[bap])) << (16 - qnttztab[bap]);
group_code = (((s32)(p_ac3dec->bit_stream.buffer)) >> (32 - qnttztab[bap])) << (16 - qnttztab[bap]);
DumpBits( &(p_ac3dec->bit_stream), qnttztab[bap] );
p_ac3dec->total_bits_read += qnttztab[bap];
return( ((s32)group_code) * exp_lut[exp] );
}
......
#include <stdio.h> /* "intf_msg.h" */
#include <sys/soundcard.h> /* "audio_output.h" */
#include <sys/types.h>
#include <sys/uio.h> /* "input.h" */
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h" /* "input_netlist.h" */
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "input.h" /* pes_packet_t */
#include "input_netlist.h" /* input_NetlistFreePES() */
#include "decoder_fifo.h" /* DECODER_FIFO_(ISEMPTY|START|INCSTART)() */
#include "audio_output.h"
#include "int_types.h"
#include "ac3_decoder.h"
#include "ac3_parse.h"
#include "ac3_bit_stream.h"
/* Misc LUT */
static u16 nfchans[] = { 2, 1, 2, 3, 3, 4, 4, 5 };
......@@ -69,27 +52,38 @@ static struct frmsize_s frmsizecod_tbl[] = {
{ 640 ,{1280 ,1393 ,1920 } },
{ 640 ,{1280 ,1394 ,1920 } }};
/* Look for a sync word */
int ac3_test_sync (ac3dec_t * p_ac3dec)
{
NeedBits( &(p_ac3dec->bit_stream), 16 );
if ( (p_ac3dec->bit_stream.buffer >> (32 - 16)) == 0x0b77 )
{
p_ac3dec->bit_stream.total_bits_read = 0;
DumpBits( &(p_ac3dec->bit_stream), 16 );
return 0;
}
DumpBits( &(p_ac3dec->bit_stream), 1 );
return 1;
}
/* Parse a syncinfo structure, minus the sync word */
void parse_syncinfo( ac3dec_t * p_ac3dec )
{
/* Get crc1 - we don't actually use this data though */
NeedBits( &(p_ac3dec->bit_stream), 16 );
DumpBits( &(p_ac3dec->bit_stream), 16 );
p_ac3dec->total_bits_read += 16;
/* Get the sampling rate */
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->syncinfo.fscod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->syncinfo.fscod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
// fprintf( stderr, "parse debug: fscod == %i\n", p_ac3dec->syncinfo.fscod );
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
/* Get the frame size code */
NeedBits( &(p_ac3dec->bit_stream), 6 );
p_ac3dec->syncinfo.frmsizecod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 6));
p_ac3dec->syncinfo.frmsizecod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 6));
// fprintf( stderr, "parse debug: frmsizecod == %i\n", p_ac3dec->syncinfo.frmsizecod );
DumpBits( &(p_ac3dec->bit_stream), 6 );
p_ac3dec->total_bits_read += 6;
p_ac3dec->syncinfo.bit_rate = frmsizecod_tbl[p_ac3dec->syncinfo.frmsizecod].bit_rate;
// fprintf( stderr, "parse debug: bit_rate == %i\n", p_ac3dec->syncinfo.bit_rate );
......@@ -106,21 +100,18 @@ void parse_bsi( ac3dec_t * p_ac3dec )
/* Check the AC-3 version number */
NeedBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->bsi.bsid = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 5));
p_ac3dec->bsi.bsid = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
DumpBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->total_bits_read += 5;
/* Get the audio service provided by the steram */
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->bsi.bsmod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->bsi.bsmod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
/* Get the audio coding mode (ie how many channels)*/
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->bsi.acmod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->bsi.acmod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
/* Predecode the number of full bandwidth channels as we use this
* number a lot */
p_ac3dec->bsi.nfchans = nfchans[p_ac3dec->bsi.acmod];
......@@ -129,87 +120,75 @@ void parse_bsi( ac3dec_t * p_ac3dec )
if ((p_ac3dec->bsi.acmod & 0x1) && (p_ac3dec->bsi.acmod != 0x1))
{
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->bsi.cmixlev = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->bsi.cmixlev = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
}
/* If it is in use, get the surround channel mix level */
if (p_ac3dec->bsi.acmod & 0x4)
{
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->bsi.surmixlev = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->bsi.surmixlev = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
}
/* Get the dolby surround mode if in 2/0 mode */
if(p_ac3dec->bsi.acmod == 0x2)
{
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->bsi.dsurmod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->bsi.dsurmod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
}
/* Is the low frequency effects channel on? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.lfeon = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.lfeon = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
/* Get the dialogue normalization level */
NeedBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->bsi.dialnorm = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 5));
p_ac3dec->bsi.dialnorm = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
DumpBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->total_bits_read += 5;
/* Does compression gain exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.compre = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.compre = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if (p_ac3dec->bsi.compre)
{
/* Get compression gain */
NeedBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->bsi.compr = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 8));
p_ac3dec->bsi.compr = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
DumpBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->total_bits_read += 8;
}
/* Does language code exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.langcode = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.langcode = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if (p_ac3dec->bsi.langcode)
{
/* Get langauge code */
NeedBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->bsi.langcod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 8));
p_ac3dec->bsi.langcod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
DumpBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->total_bits_read += 8;
}
/* Does audio production info exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.audprodie = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.audprodie = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if (p_ac3dec->bsi.audprodie)
{
/* Get mix level */
NeedBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->bsi.mixlevel = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 5));
p_ac3dec->bsi.mixlevel = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
DumpBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->total_bits_read += 5;
/* Get room type */
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->bsi.roomtyp = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->bsi.roomtyp = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
}
/* If we're in dual mono mode then get some extra info */
......@@ -217,120 +196,103 @@ void parse_bsi( ac3dec_t * p_ac3dec )
{
/* Get the dialogue normalization level two */
NeedBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->bsi.dialnorm2 = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 5));
p_ac3dec->bsi.dialnorm2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
DumpBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->total_bits_read += 5;
/* Does compression gain two exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.compr2e = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.compr2e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if (p_ac3dec->bsi.compr2e)
{
/* Get compression gain two */
NeedBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->bsi.compr2 = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 8));
p_ac3dec->bsi.compr2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
DumpBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->total_bits_read += 8;
}
/* Does language code two exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.langcod2e = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.langcod2e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if (p_ac3dec->bsi.langcod2e)
{
/* Get langauge code two */
NeedBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->bsi.langcod2 = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 8));
p_ac3dec->bsi.langcod2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
DumpBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->total_bits_read += 8;
}
/* Does audio production info two exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.audprodi2e = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.audprodi2e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if (p_ac3dec->bsi.audprodi2e)
{
/* Get mix level two */
NeedBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->bsi.mixlevel2 = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 5));
p_ac3dec->bsi.mixlevel2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
DumpBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->total_bits_read += 5;
/* Get room type two */
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->bsi.roomtyp2 = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->bsi.roomtyp2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
}
}
/* Get the copyright bit */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.copyrightb = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.copyrightb = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
/* Get the original bit */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.origbs = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.origbs = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
/* Does timecode one exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.timecod1e = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.timecod1e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if(p_ac3dec->bsi.timecod1e)
{
NeedBits( &(p_ac3dec->bit_stream), 14 );
p_ac3dec->bsi.timecod1 = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 14));
p_ac3dec->bsi.timecod1 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 14));
DumpBits( &(p_ac3dec->bit_stream), 14 );
p_ac3dec->total_bits_read += 14;
}
/* Does timecode two exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.timecod2e = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.timecod2e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if(p_ac3dec->bsi.timecod2e)
{
NeedBits( &(p_ac3dec->bit_stream), 14 );
p_ac3dec->bsi.timecod2 = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 14));
p_ac3dec->bsi.timecod2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 14));
DumpBits( &(p_ac3dec->bit_stream), 14 );
p_ac3dec->total_bits_read += 14;
}
/* Does addition info exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->bsi.addbsie = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->bsi.addbsie = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if(p_ac3dec->bsi.addbsie)
{
/* Get how much info is there */
NeedBits( &(p_ac3dec->bit_stream), 6 );
p_ac3dec->bsi.addbsil = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 6));
p_ac3dec->bsi.addbsil = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 6));
DumpBits( &(p_ac3dec->bit_stream), 6 );
p_ac3dec->total_bits_read += 6;
/* Get the additional info */
for(i=0;i<(p_ac3dec->bsi.addbsil + 1);i++)
{
NeedBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->bsi.addbsi[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 8));
p_ac3dec->bsi.addbsi[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
DumpBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->total_bits_read += 8;
}
}
}
......@@ -344,32 +306,28 @@ void parse_audblk( ac3dec_t * p_ac3dec )
{
/* Is this channel an interleaved 256 + 256 block ? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.blksw[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.blksw[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
for (i=0;i < p_ac3dec->bsi.nfchans; i++)
{
/* Should we dither this channel? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.dithflag[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.dithflag[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
/* Does dynamic range control exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.dynrnge = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.dynrnge = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if (p_ac3dec->audblk.dynrnge)
{
/* Get dynamic range info */
NeedBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->audblk.dynrng = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 8));
p_ac3dec->audblk.dynrng = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
DumpBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->total_bits_read += 8;
}
/* If we're in dual mono mode then get the second channel DR info */
......@@ -377,55 +335,47 @@ void parse_audblk( ac3dec_t * p_ac3dec )
{
/* Does dynamic range control two exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.dynrng2e = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.dynrng2e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if (p_ac3dec->audblk.dynrng2e)
{
/* Get dynamic range info */
NeedBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->audblk.dynrng2 = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 8));
p_ac3dec->audblk.dynrng2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
DumpBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->total_bits_read += 8;
}
}
/* Does coupling strategy exist? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.cplstre = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.cplstre = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if (p_ac3dec->audblk.cplstre)
{
/* Is coupling turned on? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.cplinu = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.cplinu = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if(p_ac3dec->audblk.cplinu)
{
for(i=0;i < p_ac3dec->bsi.nfchans; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.chincpl[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.chincpl[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
if(p_ac3dec->bsi.acmod == 0x2)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.phsflginu = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.phsflginu = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.cplbegf = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.cplbegf = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.cplendf = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.cplendf = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
p_ac3dec->audblk.ncplsubnd = (p_ac3dec->audblk.cplendf + 2) - p_ac3dec->audblk.cplbegf + 1;
/* Calculate the start and end bins of the coupling channel */
......@@ -439,9 +389,8 @@ void parse_audblk( ac3dec_t * p_ac3dec )
for(i=1; i< p_ac3dec->audblk.ncplsubnd; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.cplbndstrc[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.cplbndstrc[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
p_ac3dec->audblk.ncplbnd -= p_ac3dec->audblk.cplbndstrc[i];
}
}
......@@ -457,26 +406,22 @@ void parse_audblk( ac3dec_t * p_ac3dec )
/* Is there new coupling co-ordinate info? */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.cplcoe[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.cplcoe[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if(p_ac3dec->audblk.cplcoe[i])
{
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->audblk.mstrcplco[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->audblk.mstrcplco[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
for(j=0;j < p_ac3dec->audblk.ncplbnd; j++)
{
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.cplcoexp[i][j] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.cplcoexp[i][j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.cplcomant[i][j] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.cplcomant[i][j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
}
}
}
......@@ -488,9 +433,8 @@ void parse_audblk( ac3dec_t * p_ac3dec )
for(j=0;j < p_ac3dec->audblk.ncplbnd; j++)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.phsflg[j] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.phsflg[j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
}
......@@ -500,9 +444,8 @@ void parse_audblk( ac3dec_t * p_ac3dec )
if(p_ac3dec->bsi.acmod == 0x2)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.rematstr = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.rematstr = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if(p_ac3dec->audblk.rematstr)
{
if (p_ac3dec->audblk.cplinu == 0)
......@@ -510,9 +453,8 @@ void parse_audblk( ac3dec_t * p_ac3dec )
for(i = 0; i < 4; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
}
if((p_ac3dec->audblk.cplbegf > 2) && p_ac3dec->audblk.cplinu)
......@@ -520,9 +462,8 @@ void parse_audblk( ac3dec_t * p_ac3dec )
for(i = 0; i < 4; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
}
if((p_ac3dec->audblk.cplbegf <= 2) && p_ac3dec->audblk.cplinu)
......@@ -530,18 +471,16 @@ void parse_audblk( ac3dec_t * p_ac3dec )
for(i = 0; i < 3; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
}
if((p_ac3dec->audblk.cplbegf == 0) && p_ac3dec->audblk.cplinu)
for(i = 0; i < 2; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
}
......@@ -551,9 +490,8 @@ void parse_audblk( ac3dec_t * p_ac3dec )
{
/* Get the coupling channel exponent strategy */
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->audblk.cplexpstr = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->audblk.cplexpstr = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
if(p_ac3dec->audblk.cplexpstr==0)
p_ac3dec->audblk.ncplgrps = 0;
......@@ -566,18 +504,16 @@ void parse_audblk( ac3dec_t * p_ac3dec )
for(i = 0; i < p_ac3dec->bsi.nfchans; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->audblk.chexpstr[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->audblk.chexpstr[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
}
/* Get the exponent strategy for lfe channel */
if(p_ac3dec->bsi.lfeon)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.lfeexpstr = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.lfeexpstr = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
/* Determine the bandwidths of all the fbw channels */
......@@ -594,9 +530,8 @@ void parse_audblk( ac3dec_t * p_ac3dec )
else
{
NeedBits( &(p_ac3dec->bit_stream), 6 );
p_ac3dec->audblk.chbwcod[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 6));
p_ac3dec->audblk.chbwcod[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 6));
DumpBits( &(p_ac3dec->bit_stream), 6 );
p_ac3dec->total_bits_read += 6;
p_ac3dec->audblk.endmant[i] = ((p_ac3dec->audblk.chbwcod[i] + 12) * 3) + 37;
}
......@@ -610,15 +545,13 @@ void parse_audblk( ac3dec_t * p_ac3dec )
if(p_ac3dec->audblk.cplinu && (p_ac3dec->audblk.cplexpstr != EXP_REUSE))
{
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.cplabsexp = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.cplabsexp = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
for(i=0;i< p_ac3dec->audblk.ncplgrps;i++)
{
NeedBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->audblk.cplexps[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 7));
p_ac3dec->audblk.cplexps[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 7));
DumpBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->total_bits_read += 7;
}
}
......@@ -628,20 +561,17 @@ void parse_audblk( ac3dec_t * p_ac3dec )
if(p_ac3dec->audblk.chexpstr[i] != EXP_REUSE)
{
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.exps[i][0] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.exps[i][0] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
for(j=1;j<=p_ac3dec->audblk.nchgrps[i];j++)
{
NeedBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->audblk.exps[i][j] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 7));
p_ac3dec->audblk.exps[i][j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 7));
DumpBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->total_bits_read += 7;
}
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->audblk.gainrng[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->audblk.gainrng[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
}
}
......@@ -649,96 +579,79 @@ void parse_audblk( ac3dec_t * p_ac3dec )
if(p_ac3dec->bsi.lfeon && (p_ac3dec->audblk.lfeexpstr != EXP_REUSE))
{
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.lfeexps[0] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.lfeexps[0] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
NeedBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->audblk.lfeexps[1] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 7));
p_ac3dec->audblk.lfeexps[1] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 7));
DumpBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->total_bits_read += 7;
NeedBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->audblk.lfeexps[2] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 7));
p_ac3dec->audblk.lfeexps[2] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 7));
DumpBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->total_bits_read += 7;
}
/* Get the parametric bit allocation parameters */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.baie = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.baie = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if(p_ac3dec->audblk.baie)
{
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->audblk.sdcycod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->audblk.sdcycod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->audblk.fdcycod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->audblk.fdcycod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->audblk.sgaincod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->audblk.sgaincod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->audblk.dbpbcod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->audblk.dbpbcod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->audblk.floorcod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->audblk.floorcod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
}
/* Get the SNR off set info if it exists */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.snroffste = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.snroffste = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if(p_ac3dec->audblk.snroffste)
{
NeedBits( &(p_ac3dec->bit_stream), 6 );
p_ac3dec->audblk.csnroffst = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 6));
p_ac3dec->audblk.csnroffst = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 6));
DumpBits( &(p_ac3dec->bit_stream), 6 );
p_ac3dec->total_bits_read += 6;
if(p_ac3dec->audblk.cplinu)
{
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.cplfsnroffst = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.cplfsnroffst = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->audblk.cplfgaincod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->audblk.cplfgaincod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
}
for(i = 0;i < p_ac3dec->bsi.nfchans; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.fsnroffst[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.fsnroffst[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->audblk.fgaincod[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->audblk.fgaincod[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
}
if(p_ac3dec->bsi.lfeon)
{
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.lfefsnroffst = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.lfefsnroffst = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->audblk.lfefgaincod = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->audblk.lfefgaincod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
}
}
......@@ -746,67 +659,57 @@ void parse_audblk( ac3dec_t * p_ac3dec )
if(p_ac3dec->audblk.cplinu)
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.cplleake = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.cplleake = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if(p_ac3dec->audblk.cplleake)
{
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->audblk.cplfleak = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->audblk.cplfleak = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->audblk.cplsleak = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->audblk.cplsleak = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
}
}
/* Get the delta bit alloaction info */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.deltbaie = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.deltbaie = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if(p_ac3dec->audblk.deltbaie)
{
if(p_ac3dec->audblk.cplinu)
{
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->audblk.cpldeltbae = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->audblk.cpldeltbae = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
}
for(i = 0;i < p_ac3dec->bsi.nfchans; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->audblk.deltbae[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 2));
p_ac3dec->audblk.deltbae[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits( &(p_ac3dec->bit_stream), 2 );
p_ac3dec->total_bits_read += 2;
}
if (p_ac3dec->audblk.cplinu && (p_ac3dec->audblk.cpldeltbae == DELTA_BIT_NEW))
{
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->audblk.cpldeltnseg = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->audblk.cpldeltnseg = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
for(i = 0;i < p_ac3dec->audblk.cpldeltnseg + 1; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->audblk.cpldeltoffst[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 5));
p_ac3dec->audblk.cpldeltoffst[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
DumpBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->total_bits_read += 5;
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.cpldeltlen[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.cpldeltlen[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->audblk.cpldeltba[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->audblk.cpldeltba[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
}
}
......@@ -815,25 +718,21 @@ void parse_audblk( ac3dec_t * p_ac3dec )
if (p_ac3dec->audblk.deltbae[i] == DELTA_BIT_NEW)
{
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->audblk.deltnseg[i] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->audblk.deltnseg[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
// if ( p_ac3dec->audblk.deltnseg[i] >= 8 )
// fprintf( stderr, "parse debug: p_ac3dec->audblk.deltnseg[%i] == %i\n", i, p_ac3dec->audblk.deltnseg[i] );
for(j = 0; j < p_ac3dec->audblk.deltnseg[i] + 1; j++)
{
NeedBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->audblk.deltoffst[i][j] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 5));
p_ac3dec->audblk.deltoffst[i][j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
DumpBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->total_bits_read += 5;
NeedBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->audblk.deltlen[i][j] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 4));
p_ac3dec->audblk.deltlen[i][j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
NeedBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->audblk.deltba[i][j] = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 3));
p_ac3dec->audblk.deltba[i][j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
}
}
}
......@@ -841,22 +740,19 @@ void parse_audblk( ac3dec_t * p_ac3dec )
/* Check to see if there's any dummy info to get */
NeedBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->audblk.skiple = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 1));
p_ac3dec->audblk.skiple = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
if ( p_ac3dec->audblk.skiple )
{
NeedBits( &(p_ac3dec->bit_stream), 9 );
p_ac3dec->audblk.skipl = (u16)(p_ac3dec->bit_stream.fifo.buffer >> (32 - 9));
p_ac3dec->audblk.skipl = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 9));
DumpBits( &(p_ac3dec->bit_stream), 9 );
p_ac3dec->total_bits_read += 9;
for(i = 0; i < p_ac3dec->audblk.skipl ; i++)
{
NeedBits( &(p_ac3dec->bit_stream), 8 );
DumpBits( &(p_ac3dec->bit_stream), 8 );
p_ac3dec->total_bits_read += 8;
}
}
}
......@@ -866,28 +762,24 @@ void parse_auxdata( ac3dec_t * p_ac3dec )
int i;
int skip_length;
skip_length = (p_ac3dec->syncinfo.frame_size * 16) - p_ac3dec->total_bits_read - 17 - 1;
skip_length = (p_ac3dec->syncinfo.frame_size * 16) - p_ac3dec->bit_stream.total_bits_read - 17 - 1;
// fprintf( stderr, "parse debug: skip_length == %i\n", skip_length );
for ( i = 0; i < skip_length; i++ )
{
NeedBits( &(p_ac3dec->bit_stream), 1 );
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
}
/* get the auxdata exists bit */
NeedBits( &(p_ac3dec->bit_stream), 1 );
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
/* Skip the CRC reserved bit */
NeedBits( &(p_ac3dec->bit_stream), 1 );
DumpBits( &(p_ac3dec->bit_stream), 1 );
p_ac3dec->total_bits_read += 1;
/* Get the crc */
NeedBits( &(p_ac3dec->bit_stream), 16 );
DumpBits( &(p_ac3dec->bit_stream), 16 );
p_ac3dec->total_bits_read += 16;
}
int ac3_test_sync (ac3dec_t *);
void parse_syncinfo( ac3dec_t * );
void parse_bsi( ac3dec_t * );
void parse_audblk( ac3dec_t * );
......
#include <unistd.h> /* getpid() */
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* malloc(), free() */
#include <sys/soundcard.h> /* "audio_output.h" */
#include <sys/types.h>
#include <sys/uio.h> /* "input.h" */
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h" /* "input_netlist.h" */
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "input.h" /* pes_packet_t */
#include "input_netlist.h" /* input_NetlistFreePES() */
#include "decoder_fifo.h" /* DECODER_FIFO_(ISEMPTY|START|INCSTART)() */
#include "audio_output.h"
#include "int_types.h"
#include "ac3_decoder.h"
#include "ac3_parse.h"
#include "ac3_exponent.h"
#include "ac3_bit_allocate.h"
#include "ac3_mantissa.h"
#include "ac3_rematrix.h"
struct rematrix_band_s
......
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