Commit 66c97236 authored by Michel Kaempf's avatar Michel Kaempf

* ac3_downmix.c :

- suppression des gros scrountchs immondes (c) (qui sont �galement des
pouics parfois) ;

* ac3_bit_allocate.c, ac3_exponent.c, ac3_mantissa.c :
- suppression de tests et messages de debug ;

* ac3_decoder/ac3_decoder.c :
- impl�mentation de la synkro qui punix ;
parent d9e35782
......@@ -252,8 +252,6 @@ void bit_allocate( ac3dec_thread_t * p_ac3dec )
ba_compute_excitation(start, end , fgain, fastleak, slowleak, 0, bndpsd, excite);
// if ( p_ac3dec->audblk.deltnseg[i] >= 8 )
// fprintf( stderr, "ba debug: p_ac3dec->audblk.deltnseg[%i] == %i\n", i, p_ac3dec->audblk.deltnseg[i] );
ba_compute_mask(start, end, p_ac3dec->syncinfo.fscod, p_ac3dec->audblk.deltbae[i], p_ac3dec->audblk.deltnseg[i], p_ac3dec->audblk.deltoffst[i], p_ac3dec->audblk.deltba[i], p_ac3dec->audblk.deltlen[i], excite, mask);
ba_compute_bap(start, end, snroffset, psd, mask, p_ac3dec->audblk.fbw_bap[i]);
......@@ -333,7 +331,6 @@ static void ba_compute_excitation(s16 start, s16 end,s16 fgain,
s16 fastleak, s16 slowleak, s16 is_lfe, s16 bndpsd[],
s16 excite[])
{
#if 1
int bin;
s16 bndstrt;
s16 bndend;
......@@ -396,14 +393,12 @@ static void ba_compute_excitation(s16 start, s16 end,s16 fgain,
slowleak = max(slowleak, bndpsd[bin] - sgain);
excite[bin] = max(fastleak, slowleak) ;
}
#endif
}
static void ba_compute_mask(s16 start, s16 end, u16 fscod,
u16 deltbae, u16 deltnseg, u16 deltoffst[], u16 deltba[],
u16 deltlen[], s16 excite[], s16 mask[])
{
#if 1
int bin,k;
s16 bndstrt;
s16 bndend;
......@@ -446,13 +441,11 @@ static void ba_compute_mask(s16 start, s16 end, u16 fscod,
}
}
}
#endif
}
static void ba_compute_bap(s16 start, s16 end, s16 snroffset,
s16 psd[], s16 mask[], s16 bap[])
{
#if 1
int i,j,k;
s16 lastbin = 0;
s16 address = 0;
......@@ -481,5 +474,4 @@ static void ba_compute_bap(s16 start, s16 end, s16 snroffset,
}
j++;
} while (end > lastbin);
#endif
}
......@@ -145,7 +145,7 @@ static __inline__ int decode_find_sync( ac3dec_thread_t * p_ac3dec )
p_ac3dec->total_bits_read = 16;
return( 0 );
}
DumpBits( &(p_ac3dec->bit_stream), 1 );
DumpBits( &(p_ac3dec->bit_stream), 8 );
}
return( -1 );
}
......@@ -190,10 +190,6 @@ static int InitThread( ac3dec_thread_t * p_ac3dec )
*****************************************************************************/
static void RunThread( ac3dec_thread_t * p_ac3dec )
{
int i;
mtime_t mdate = 0;
// byte_t byte;
intf_DbgMsg( "ac3dec debug: running ac3 decoder thread (%p) (pid == %i)\n", p_ac3dec, getpid() );
/* Initializing the ac3 decoder thread */
......@@ -202,17 +198,56 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
p_ac3dec->b_error = 1;
}
// i = open( "/tmp/taxi.ac3", O_WRONLY|O_CREAT|O_TRUNC );
/* ac3 decoder thread's main loop */
while ( (!p_ac3dec->b_die) && (!p_ac3dec->b_error) )
{
// byte = GetByte( &(p_ac3dec->bit_stream) );
// write( i, &byte, 1 );
decode_find_sync( p_ac3dec );
if ( DECODER_FIFO_START(p_ac3dec->fifo)->b_has_pts )
{
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(p_ac3dec->fifo)->i_pts;
DECODER_FIFO_START(p_ac3dec->fifo)->b_has_pts = 0;
}
else
{
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
}
parse_syncinfo( p_ac3dec );
parse_bsi( p_ac3dec );
for ( i = 0; i < 6; i++ )
/* frame 1 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->bsi.acmod == 0x2 )
{
rematrix( p_ac3dec );
}
imdct( p_ac3dec );
downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
/* frame 2 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->bsi.acmod == 0x2 )
{
rematrix( p_ac3dec );
}
imdct( p_ac3dec );
downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
/* frame 3 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
bit_allocate( p_ac3dec );
......@@ -222,17 +257,62 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
rematrix( p_ac3dec );
}
imdct( p_ac3dec );
downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
/* frame 4 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->bsi.acmod == 0x2 )
{
rematrix( p_ac3dec );
}
imdct( p_ac3dec );
downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
/* frame 5 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->bsi.acmod == 0x2 )
{
rematrix( p_ac3dec );
}
imdct( p_ac3dec );
downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = mdate;
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
mdate += 5333;
/* frame 6 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->bsi.acmod == 0x2 )
{
rematrix( p_ac3dec );
}
imdct( p_ac3dec );
downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
parse_auxdata( p_ac3dec );
}
close( i );
/* If b_error is set, the ac3 decoder thread enters the error loop */
if ( p_ac3dec->b_error )
......
......@@ -22,6 +22,8 @@
#include "ac3_decoder.h"
#include "ac3_downmix.h"
#define NORM 16384
typedef struct prefs_s
{
u16 use_dolby_surround;
......@@ -72,8 +74,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
right_tmp += 0.3204f * *right++ + 0.2265f * *centre;
left_tmp += 0.3204f * *left++ + 0.2265f * *centre++;
*(out_buf++) = left_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = left_tmp;
......@@ -95,8 +97,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
right_tmp += 0.3204f * *right++;
left_tmp += 0.3204f * *left++ ;
*(out_buf++) = left_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = left_tmp;
......@@ -119,8 +121,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
right_tmp += 0.3204f * *right++ + 0.2265f * *centre;
left_tmp += 0.3204f * *left++ + 0.2265f * *centre++;
*(out_buf++) = left_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = left_tmp;
......@@ -142,8 +144,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
right_tmp += 0.3204f * *right++;
left_tmp += 0.3204f * *left++;
*(out_buf++) = left_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = left_tmp;
......@@ -162,8 +164,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
right_tmp = 0.3204f * *right++ + 0.2265f * *centre;
left_tmp = 0.3204f * *left++ + 0.2265f * *centre++;
*(out_buf++) = left_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = left_tmp;
......@@ -178,8 +180,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
for ( j = 0; j < 256; j++ )
{
*(out_buf++) = *(left++) * 32766;
*(out_buf++) = *(right++) * 32766;
*(out_buf++) = *(left++) * NORM;
*(out_buf++) = *(right++) * NORM;
}
break;
......@@ -192,8 +194,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
{
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = right_tmp;
......@@ -210,8 +212,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
{
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = right_tmp;
......@@ -241,8 +243,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
right_tmp= 0.4142f * *right++ + clev * *centre + slev * *right_sur++;
left_tmp = 0.4142f * *left++ + clev * *centre++ + slev * *left_sur++;
*(out_buf++) = left_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = left_tmp;
......@@ -264,8 +266,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
right_tmp= 0.4142f * *right++ + slev * *right_sur++;
left_tmp = 0.4142f * *left++ + slev * *left_sur++;
*(out_buf++) = left_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = left_tmp;
......@@ -289,8 +291,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
right_tmp= 0.4142f * *right++ + clev * *centre + slev * *right_sur;
left_tmp = 0.4142f * *left++ + clev * *centre++ + slev * *right_sur++;
*(out_buf++) = left_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = left_tmp;
......@@ -312,8 +314,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
right_tmp= 0.4142f * *right++ + slev * *right_sur;
left_tmp = 0.4142f * *left++ + slev * *right_sur++;
*(out_buf++) = left_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = left_tmp;
......@@ -334,8 +336,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
right_tmp= 0.4142f * *right++ + clev * *centre;
left_tmp = 0.4142f * *left++ + clev * *centre++;
*(out_buf++) = left_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = left_tmp;
......@@ -349,8 +351,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
for ( j = 0; j < 256; j++ )
{
*(out_buf++) = *(left++) * 32766;
*(out_buf++) = *(right++) * 32766;
*(out_buf++) = *(left++) * NORM;
*(out_buf++) = *(right++) * NORM;
}
break;
......@@ -363,8 +365,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
{
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = right_tmp;
......@@ -381,8 +383,8 @@ void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
{
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = right_tmp * 32766;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
/*
p_ac3dec->samples.channel[1][j] = right_tmp;
p_ac3dec->samples.channel[0][j] = right_tmp;
......
......@@ -53,8 +53,8 @@ static __inline__ void exp_unpack_ch( u16 type, u16 expstr, u16 ngrps, u16 initi
if ( exps[i] > 124 )
{
//FIXME set an error flag and mute the frame
printf( "\n!! Invalid exponent !!\n" );
exit( 1 );
fprintf( stderr, "!! Invalid exponent !!\n" );
// exit( 1 );
}
*/
......
......@@ -168,6 +168,7 @@ static int index = 0;
static __inline__ float dither_gen( u16 exp )
{
int tmp;
fprintf( stderr, "dither suxx\n" );
tmp = fuck[(index+3)%31];
tmp ^= fuck[index];
fuck[index] = tmp;
......@@ -210,7 +211,7 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
/*
if(group_code > 26)
//FIXME do proper block error handling
printf("\n!! Invalid mantissa !!\n");
fprintf( stderr, "!! Invalid mantissa !!\n" );
*/
//q_1[ 0 ] = q_1_0[ group_code ];
......@@ -234,7 +235,7 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
/*
if(group_code > 124)
//FIXME do proper block error handling
printf("\n!! Invalid mantissa !!\n");
fprintf( stderr, "!! Invalid mantissa !!\n" );
*/
//q_2[ 0 ] = q_2_0[ group_code ];
......@@ -254,7 +255,7 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
/*
if(group_code > 6)
//FIXME do proper block error handling
printf("\n!! Invalid mantissa !!\n");
fprintf( stderr, "!! Invalid mantissa !!\n" );
*/
return( q_3[group_code] * exp_lut[exp] );
......@@ -272,7 +273,7 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
/*
if(group_code > 120)
//FIXME do proper block error handling
printf("\n!! Invalid mantissa !!\n");
fprintf( stderr, "!! Invalid mantissa !!\n" );
*/
//q_4[ 0 ] = q_4_0[ group_code ];
......@@ -291,7 +292,7 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
/*
if(group_code > 14)
//FIXME do proper block error handling
printf("\n!! Invalid mantissa !!\n");
fprintf( stderr, "!! Invalid mantissa !!\n" );
*/
return( q_5[group_code] * exp_lut[exp] );
......
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