Commit 4b504cfc authored by Michel Kaempf's avatar Michel Kaempf

* ac3_decoder/ac3_decoder.c :

- suppression des `#ifdef AC3_SIGSEGV' ;
- correction d'un bug de la fonction `InitThread()' (scotchage �
l'initialisation du d�codeur AC3 dans certaines conditions tr�s
particuli�res) ;
- support du bool�en `b_invalid' permettant de d�tecter des frames
suppos�es invalides ;

* ac3_decoder/ac3_exponent.c :
- suppression des `#ifdef AC3_SIGSEGV' ;
- d�tection des frames invalides et support du bool�en `b_invalid' ;

* ac3_decoder/ac3_mantissa.c :
- suppression des `#ifdef AC3_SIGSEGV' ;
- d�tection des frames invalides et support du bool�en `b_invalid' ;
- optimisation de la fonction `mantissa_unpack()' ;

* audio_decoder/audio_decoder.c :
- correction d'un bug de la fonction `InitThread()' (scotchage �
l'initialisation du d�codeur MPEG2 dans certaines conditions tr�s
particuli�res) ;

* include/ac3_decoder.h :
- suppression du `#define AC3_SIGSEGV' ;

* include/vpar_synchro.h :
- d�claration explicite de la fonction `vpar_SynchroKludge()' lorsque
`SAM_SYNCHRO' n'est pas activ�e ;

* interface/intf_ctrl.c :
- initialisation � `-1' des variables `i_input' et `i_pid' de la
fonction `SelectPID()' ;

* video_output/video_yuv.c :
- mise en commentaire de la fonction inutilis�e `yuvToRgb24()' ;

* video_parser/video_parser.c :
- int�gration du patch propos� dans videolan-devel ;

* video_parser/vpar_blocks.c :
- int�gration du patch propos� dans videolan-devel ;

NdlR : apu warnings � la compilation :-)
parent 3b84e676
......@@ -3,8 +3,6 @@
* (c)1999 VideoLAN
*****************************************************************************/
#define AC3_SIGSEGV
/* Exponent strategy constants */
#define EXP_REUSE (0)
#define EXP_D15 (1)
......
......@@ -94,7 +94,7 @@ typedef struct video_synchro_s
/*****************************************************************************
* Prototypes
*****************************************************************************/
boolean_t vpar_SynchroChoose( struct vpar_thread_s * p_vpar, int i_coding_type,
boolean_t vpar_SynchroChoose( struct vpar_thread_s * p_vpar, int i_coding_type,
int i_structure );
void vpar_SynchroTrash( struct vpar_thread_s * p_vpar, int i_coding_type,
int i_structure );
......@@ -102,3 +102,7 @@ void vpar_SynchroDecode( struct vpar_thread_s * p_vpar, int i_coding_type,
int i_structure );
void vpar_SynchroEnd( struct vpar_thread_s * p_vpar );
mtime_t vpar_SynchroDate( struct vpar_thread_s * p_vpar );
#ifndef SAM_SYNCHRO
void vpar_SynchroKludge( struct vpar_thread_s *, mtime_t );
#endif
......@@ -141,10 +141,6 @@ void ac3dec_DestroyThread( ac3dec_thread_t * p_ac3dec )
*****************************************************************************/
static __inline__ int decode_find_sync( ac3dec_thread_t * p_ac3dec )
{
#ifdef AC3_SIGSEGV
int i = 0;
#endif
while ( (!p_ac3dec->b_die) && (!p_ac3dec->b_error) )
{
NeedBits( &(p_ac3dec->bit_stream), 16 );
......@@ -152,20 +148,9 @@ static __inline__ int decode_find_sync( ac3dec_thread_t * p_ac3dec )
{
DumpBits( &(p_ac3dec->bit_stream), 16 );
p_ac3dec->total_bits_read = 16;
#ifdef AC3_SIGSEGV
if ( i )
{
fprintf( stderr, "ac3dec debug: %i bit(s) skipped to synkronize\n", i );
}
#endif
return( 0 );
}
#ifdef AC3_SIGSEGV
DumpBits( &(p_ac3dec->bit_stream), 1 );
i += 1;
#else
DumpBits( &(p_ac3dec->bit_stream), 8 );
#endif
DumpBits( &(p_ac3dec->bit_stream), 1 ); /* XXX */
}
return( -1 );
}
......@@ -184,12 +169,12 @@ static int InitThread( ac3dec_thread_t * p_ac3dec )
vlc_mutex_lock( &p_ac3dec->fifo.data_lock );
while ( DECODER_FIFO_ISEMPTY(p_ac3dec->fifo) )
{
vlc_cond_wait( &p_ac3dec->fifo.data_wait, &p_ac3dec->fifo.data_lock );
if ( p_ac3dec->bit_stream.p_input->b_die )
if ( p_ac3dec->b_die )
{
vlc_mutex_unlock( &p_ac3dec->fifo.data_lock );
return( -1 );
}
vlc_cond_wait( &p_ac3dec->fifo.data_wait, &p_ac3dec->fifo.data_lock );
}
p_ac3dec->bit_stream.p_ts = DECODER_FIFO_START( p_ac3dec->fifo )->p_first_ts;
p_ac3dec->bit_stream.i_byte = p_ac3dec->bit_stream.p_ts->i_payload_start;
......@@ -220,7 +205,7 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
msleep( (3 * INPUT_PTS_DELAY) / 4 );
/* Initializing the ac3 decoder thread */
if ( InitThread(p_ac3dec) )
if ( InitThread(p_ac3dec) ) /* XXX */
{
p_ac3dec->b_error = 1;
}
......@@ -258,16 +243,25 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
p_ac3dec->p_aout_fifo->l_rate = 32000;
break;
default:
default: /* XXX */
fprintf( stderr, "ac3dec debug: invalid fscod\n" );
p_ac3dec->b_invalid = 1;
break;
}
if ( p_ac3dec->b_invalid ) /* XXX */
{
continue;
}
parse_bsi( p_ac3dec );
/* frame 1 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
{
continue;
}
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
......@@ -288,6 +282,10 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
/* frame 2 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
{
continue;
}
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
......@@ -309,6 +307,10 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
/* frame 3 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
{
continue;
}
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
......@@ -330,6 +332,10 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
/* frame 4 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
{
continue;
}
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
......@@ -351,6 +357,10 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
/* frame 5 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
{
continue;
}
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
......@@ -372,6 +382,10 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
/* frame 6 */
parse_audblk( p_ac3dec );
exponent_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
{
continue;
}
bit_allocate( p_ac3dec );
mantissa_unpack( p_ac3dec );
if ( p_ac3dec->b_invalid )
......
......@@ -29,19 +29,10 @@ static const s16 exps_2[128] = { -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 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, -2, -1, 0 };
/*
static const s16 exps_1[128] = { 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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5 };
static const s16 exps_2[128] = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 0, 0 };
static const s16 exps_3[128] = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2 };
*/
static __inline__ void exp_unpack_ch( u16 type, u16 expstr, u16 ngrps, u16 initial_exp, u16 exps[], u16 * dest )
static __inline__ void exp_unpack_ch( ac3dec_thread_t * p_ac3dec, u16 type, u16 expstr, u16 ngrps, u16 initial_exp, u16 exps[], u16 * dest )
{
u16 i,j;
s16 exp_acc;
/*
s16 exp_1,exp_2,exp_3;
*/
if ( expstr == EXP_REUSE )
{
......@@ -65,12 +56,11 @@ static __inline__ void exp_unpack_ch( u16 type, u16 expstr, u16 ngrps, u16 initi
case EXP_D45:
for ( i = 0; i < ngrps; i++ )
{
#ifdef AC3_SIGSEGV
if ( exps[i] > 127 )
if ( exps[i] > 124 )
{
fprintf( stderr, "ac3dec debug: invalid exponent\n" );
p_ac3dec->b_invalid = 1;
}
#endif
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
......@@ -92,12 +82,11 @@ static __inline__ void exp_unpack_ch( u16 type, u16 expstr, u16 ngrps, u16 initi
case EXP_D25:
for ( i = 0; i < ngrps; i++ )
{
#ifdef AC3_SIGSEGV
if ( exps[i] > 127 )
if ( exps[i] > 124 )
{
fprintf( stderr, "ac3dec debug: invalid exponent\n" );
p_ac3dec->b_invalid = 1;
}
#endif
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
......@@ -113,12 +102,11 @@ static __inline__ void exp_unpack_ch( u16 type, u16 expstr, u16 ngrps, u16 initi
case EXP_D15:
for ( i = 0; i < ngrps; i++ )
{
#ifdef AC3_SIGSEGV
if ( exps[i] > 127 )
if ( exps[i] > 124 )
{
fprintf( stderr, "ac3dec debug: invalid exponent\n" );
p_ac3dec->b_invalid = 1;
}
#endif
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
......@@ -127,72 +115,7 @@ static __inline__ void exp_unpack_ch( u16 type, u16 expstr, u16 ngrps, u16 initi
dest[j++] = exp_acc;
}
break;
default:
fprintf( stderr, "ac3dec debug: expstr == %i <maxx@via.ecp.fr>\n", expstr );
break;
}
#if 0
for ( i = 0; i < ngrps; i++ )
{
/*
if ( exps[i] > 124 )
{
//FIXME set an error flag and mute the frame
fprintf( stderr, "!! Invalid exponent !!\n" );
// exit( 1 );
}
*/
/*
exp_1 = exps[i] / 25;
exp_2 = (exps[i] - (exp_1 * 25)) / 5;
exp_3 = exps[i] - (exp_1 * 25) - (exp_2 * 5) ;
*/
switch ( expstr )
{
case EXP_D45:
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:
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:
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;
}
}
#endif
}
void exponent_unpack( ac3dec_thread_t * p_ac3dec )
......@@ -201,16 +124,16 @@ void exponent_unpack( ac3dec_thread_t * p_ac3dec )
for ( i = 0; i < p_ac3dec->bsi.nfchans; i++ )
{
exp_unpack_ch( 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] );
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 ( p_ac3dec->audblk.cplinu )
{
exp_unpack_ch( 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] );
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 ( p_ac3dec->bsi.lfeon )
{
exp_unpack_ch( UNPACK_LFE, p_ac3dec->audblk.lfeexpstr, 2, p_ac3dec->audblk.lfeexps[0], &p_ac3dec->audblk.lfeexps[1], p_ac3dec->audblk.lfe_exp );
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 );
}
}
......@@ -100,91 +100,8 @@ static float exp_lut[ 25 ] =
3.63797880709171295166015625e-12,
};
#ifdef DITHER
#if 0
static u32 lfsr_state = 1;
static __inline__ float dither_gen( u16 exp )
{
int i;
u32 state;
s16 mantissa;
//explicitly bring the state into a local var as gcc > 3.0?
//doesn't know how to optimize out the stores
state = lfsr_state;
//Generate eight pseudo random bits
for(i=0;i<8;i++)
{
state <<= 1;
if(state & 0x10000)
state ^= 0xa011;
}
lfsr_state = state;
mantissa = ((((s32)state<<8)>>8) * (s32) (0.707106f * 256.0f))>>16;
return( mantissa * exp_lut[exp] );
}
#else
static int fuck[31] =
{
0x00000001,
0x00000002,
0x00000004,
0x00000008,
0x00000010,
0x00000020,
0x00000040,
0x00000080,
0x00000100,
0x80000200,
0x00000400,
0x00000800,
0x00001000,
0x00002000,
0x00004000,
0x00008000,
0x80010000,
0x00020000,
0x00040000,
0x00080000,
0x00100000,
0x80200000,
0x00400000,
0x00800000,
0x01000000,
0x02000000,
0x04000000,
0x08000000,
0x10000000,
0x20000000,
0x40000000
};
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;
index = (index+1)%31;
return( tmp * 1.52587890625e-5f * 0.707106f * exp_lut[exp] );
}
#endif
#endif
/* Fetch an unpacked, left justified, and properly biased/dithered mantissa value */
#ifdef DITHER
static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 dithflag, u16 exp )
#else
static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp )
#endif
{
u32 group_code;
......@@ -192,12 +109,7 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
switch ( bap )
{
case 0:
#ifdef DITHER
if(dithflag)
return( dither_gen(exp) );
else
#endif
return( 0 );
return( 0 );
case 1:
if ( q_1_pointer >= 0 )
......@@ -209,16 +121,12 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
DumpBits( &(p_ac3dec->bit_stream), 5 );
p_ac3dec->total_bits_read += 5;
#ifdef AC3_SIGSEGV
if ( group_code > 26 )
{
//FIXME do proper block error handling
fprintf( stderr, "ac3dec debug: invalid mantissa\n" );
p_ac3dec->b_invalid = 1;
}
#endif
//q_1[ 0 ] = q_1_0[ group_code ];
q_1[ 1 ] = q_1_1[ group_code ];
q_1[ 0 ] = q_1_2[ group_code ];
......@@ -236,16 +144,12 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
DumpBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->total_bits_read += 7;
#ifdef AC3_SIGSEGV
if ( group_code > 124 )
{
//FIXME do proper block error handling
fprintf( stderr, "ac3dec debug: invalid mantissa\n" );
p_ac3dec->b_invalid = 1;
}
#endif
//q_2[ 0 ] = q_2_0[ group_code ];
q_2[ 1 ] = q_2_1[ group_code ];
q_2[ 0 ] = q_2_2[ group_code ];
......@@ -259,14 +163,11 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
DumpBits( &(p_ac3dec->bit_stream), 3 );
p_ac3dec->total_bits_read += 3;
#ifdef AC3_SIGSEGV
if ( group_code > 6 )
{
//FIXME do proper block error handling
fprintf( stderr, "ac3dec debug: invalid mantissa\n" );
p_ac3dec->b_invalid = 1;
}
#endif
return( q_3[group_code] * exp_lut[exp] );
......@@ -280,16 +181,12 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
DumpBits( &(p_ac3dec->bit_stream), 7 );
p_ac3dec->total_bits_read += 7;
#ifdef AC3_SIGSEGV
if ( group_code > 120 )
{
//FIXME do proper block error handling
fprintf( stderr, "ac3dec debug: invalid mantissa\n" );
p_ac3dec->b_invalid = 1;
}
#endif
//q_4[ 0 ] = q_4_0[ group_code ];
q_4[ 0 ] = q_4_1[ group_code ];
q_4_pointer = 0;
......@@ -302,14 +199,11 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
DumpBits( &(p_ac3dec->bit_stream), 4 );
p_ac3dec->total_bits_read += 4;
#ifdef AC3_SIGSEGV
if ( group_code > 14 )
{
//FIXME do proper block error handling
fprintf( stderr, "ac3dec debug: invalid mantissa\n" );
p_ac3dec->b_invalid = 1;
}
#endif
return( q_5[group_code] * exp_lut[exp] );
......@@ -328,7 +222,6 @@ static __inline__ void uncouple_channel( ac3dec_thread_t * p_ac3dec, u32 ch )
u32 bnd = 0;
u32 i,j;
float cpl_coord = 0;
//float coeff;
u32 cpl_exp_tmp;
u32 cpl_mant_tmp;
......@@ -348,59 +241,12 @@ static __inline__ void uncouple_channel( ac3dec_thread_t * p_ac3dec, u32 ch )
for(j=0;j < 12; j++)
{
//Get new dither values for each channel if necessary, so
//the channels are uncorrelated
#ifdef DITHER
if ( p_ac3dec->audblk.dithflag[ch] && p_ac3dec->audblk.cpl_bap[i] == 0 )
p_ac3dec->coeffs.fbw[ch][i] = cpl_coord * dither_gen( p_ac3dec->audblk.cpl_exp[i] );
else
#endif
p_ac3dec->coeffs.fbw[ch][i] = cpl_coord * p_ac3dec->audblk.cplfbw[i];
p_ac3dec->coeffs.fbw[ch][i] = cpl_coord * p_ac3dec->audblk.cplfbw[i];
i++;
}
}
}
#if 0
void
uncouple(bsi_t *bsi,audblk_t *audblk,stream_coeffs_t *coeffs)
{
int i,j;
for(i=0; i< bsi->nfchans; i++)
{
for(j=0; j < audblk->endmant[i]; j++)
convert_to_float(audblk->fbw_exp[i][j],audblk->chmant[i][j],
(u32*) &coeffs->fbw[i][j]);
}
if(audblk->cplinu)
{
for(i=0; i< bsi->nfchans; i++)
{
if(audblk->chincpl[i])
{
uncouple_channel(coeffs,audblk,i);
}
}
}
if(bsi->lfeon)
{
/* There are always 7 mantissas for lfe */
for(j=0; j < 7 ; j++)
convert_to_float(audblk->lfe_exp[j],audblk->lfemant[j],
(u32*) &coeffs->lfe[j]);
}
}
#endif
/*
void mantissa_unpack( bsi_t * bsi, audblk_t * audblk, bitstream_t * bs )
*/
void mantissa_unpack( ac3dec_thread_t * p_ac3dec )
{
int i, j;
......@@ -416,54 +262,30 @@ void mantissa_unpack( ac3dec_thread_t * p_ac3dec )
{
for ( j = 0; j < p_ac3dec->audblk.endmant[i]; j++ )
{
#ifdef DITHER
p_ac3dec->coeffs.fbw[i][j] = float_get( p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j] );
#else
p_ac3dec->coeffs.fbw[i][j] = float_get( p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j] );
#endif
}
}
/* 2 */
for ( j = 0; j < p_ac3dec->audblk.endmant[i]; j++ )
{
#ifdef DITHER
p_ac3dec->coeffs.fbw[i][j] = float_get( p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j] );
#else
p_ac3dec->coeffs.fbw[i][j] = float_get( p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j] );
#endif
}
for ( j = p_ac3dec->audblk.cplstrtmant; j < p_ac3dec->audblk.cplendmant; j++ )
{
#ifdef DITHER
p_ac3dec->audblk.cplfbw[j] = float_get( p_ac3dec, p_ac3dec->audblk.cpl_bap[j], 0, p_ac3dec->audblk.cpl_exp[j] );
#else
p_ac3dec->audblk.cplfbw[j] = float_get( p_ac3dec, p_ac3dec->audblk.cpl_bap[j], p_ac3dec->audblk.cpl_exp[j] );
#endif
}
// uncouple_channel( coeffs, audblk, i );
uncouple_channel( p_ac3dec, i );
/* 3 */
for ( i++; i < p_ac3dec->bsi.nfchans; i++ )
{
for ( j = 0; j < p_ac3dec->audblk.endmant[i]; j++ )
{
#ifdef DITHER
p_ac3dec->coeffs.fbw[i][j] = float_get( p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j] );
#else
p_ac3dec->coeffs.fbw[i][j] = float_get( p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j] );
#endif
}
if ( p_ac3dec->audblk.chincpl[i] )
{
// uncouple_channel( coeffs, audblk, i );
}
}
for ( i = 0; i < p_ac3dec->bsi.nfchans; i++ )
{
if ( p_ac3dec->audblk.chincpl[i] )
{
uncouple_channel( p_ac3dec, i );
}
}
......@@ -474,11 +296,7 @@ void mantissa_unpack( ac3dec_thread_t * p_ac3dec )
{
for ( j = 0; j < p_ac3dec->audblk.endmant[i]; j++ )
{
#ifdef DITHER
p_ac3dec->coeffs.fbw[i][j] = float_get( p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.dithflag[i], p_ac3dec->audblk.fbw_exp[i][j] );
#else
p_ac3dec->coeffs.fbw[i][j] = float_get( p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j] );
#endif
}
}
}
......@@ -488,11 +306,7 @@ void mantissa_unpack( ac3dec_thread_t * p_ac3dec )
/* There are always 7 mantissas for lfe, no dither for lfe */
for ( j = 0; j < 7; j++ )
{
#ifdef DITHER
p_ac3dec->coeffs.lfe[j] = float_get( p_ac3dec, p_ac3dec->audblk.lfe_bap[j], 0, p_ac3dec->audblk.lfe_exp[j] );
#else
p_ac3dec->coeffs.lfe[j] = float_get( p_ac3dec, p_ac3dec->audblk.lfe_bap[j], p_ac3dec->audblk.lfe_exp[j] );
#endif
}
}
}
......@@ -713,12 +713,12 @@ static int InitThread( adec_thread_t * p_adec )
vlc_mutex_lock( &p_adec->fifo.data_lock );
while ( DECODER_FIFO_ISEMPTY(p_adec->fifo) )
{
vlc_cond_wait( &p_adec->fifo.data_wait, &p_adec->fifo.data_lock );
if ( p_adec->bit_stream.p_input->b_die )
if ( p_adec->b_die )
{
vlc_mutex_unlock( &p_adec->fifo.data_lock );
return( -1 );
}
vlc_cond_wait( &p_adec->fifo.data_wait, &p_adec->fifo.data_lock );
}
p_adec->bit_stream.p_ts = DECODER_FIFO_START( p_adec->fifo )->p_first_ts;
p_adec->bit_stream.i_byte = p_adec->bit_stream.p_ts->i_payload_start;
......@@ -842,7 +842,7 @@ static void RunThread( adec_thread_t * p_adec )
* l_end_frame index would be incremented 6 times. But, if after
* this operation the audio output fifo contains less than 6 frames,
* it would mean that we had not enough room to store the 6 frames :-P */
while ( (((p_adec->p_aout_fifo->l_end_frame + 6) - p_adec->p_aout_fifo->l_start_frame) & AOUT_FIFO_SIZE) < 6 ) /* !! */
while ( (((p_adec->p_aout_fifo->l_end_frame + 6) - p_adec->p_aout_fifo->l_start_frame) & AOUT_FIFO_SIZE) < 6 ) /* XXX */
{
vlc_cond_wait( &p_adec->p_aout_fifo->data_wait, &p_adec->p_aout_fifo->data_lock );
}
......
......@@ -426,7 +426,7 @@ static int Quit( int i_argc, intf_arg_t *p_argv )
******************************************************************************/
static int SelectPID( int i_argc, intf_arg_t *p_argv )
{
int i_input, i_pid;
int i_input = -1, i_pid = -1;
int i_arg;
/* Parse parameters - see command list above */
......
......@@ -1270,6 +1270,7 @@ static void ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
* calculated to minimize the cache interactions of the 3 tables.
*/
#if 0
static void yuvToRgb24 (unsigned char * Y,
unsigned char * U, unsigned char * V,
char * dest, int table[1935], int width)
......@@ -1426,4 +1427,4 @@ static void yuvToRgb24 (unsigned char * Y,
*(dest++) = tmp24 >> 16;
}
}
#endif
......@@ -158,7 +158,13 @@ static int CheckConfiguration( video_cfg_t *p_cfg )
*******************************************************************************/
static int InitThread( vpar_thread_t *p_vpar )
{
int i_dummy;
#ifdef VDEC_SMP
int i_dummy;
#endif
#ifdef SAM_SYNCHRO
int i_dummy;
#endif
intf_DbgMsg("vpar debug: initializing video parser thread %p\n", p_vpar);
......@@ -167,6 +173,11 @@ static int InitThread( vpar_thread_t *p_vpar )
vlc_mutex_lock( &p_vpar->fifo.data_lock );
while ( DECODER_FIFO_ISEMPTY(p_vpar->fifo) )
{
if ( p_vpar->b_die )
{
vlc_mutex_unlock( &p_vpar->fifo.data_lock );
return( 1 );
}
vlc_cond_wait( &p_vpar->fifo.data_wait, &p_vpar->fifo.data_lock );
}
p_vpar->bit_stream.p_ts = DECODER_FIFO_START( p_vpar->fifo )->p_first_ts;
......@@ -308,10 +319,7 @@ static void RunThread( vpar_thread_t *p_vpar )
* Initialize thread
*/
p_vpar->b_error = InitThread( p_vpar );
if( p_vpar->b_error )
{
return;
}
p_vpar->b_run = 1;
/*
......@@ -346,9 +354,10 @@ static void RunThread( vpar_thread_t *p_vpar )
ErrorThread( p_vpar );
}
p_vpar->b_run = 0;
/* End of thread */
EndThread( p_vpar );
p_vpar->b_run = 0;
}
/*******************************************************************************
......@@ -360,25 +369,26 @@ static void RunThread( vpar_thread_t *p_vpar )
*******************************************************************************/
static void ErrorThread( vpar_thread_t *p_vpar )
{
/* Wait until a `die' order */
/* We take the lock, because we are going to read/write the start/end
* indexes of the decoder fifo */
vlc_mutex_lock( &p_vpar->fifo.data_lock );
/* Wait until a `die' order is sent */
while( !p_vpar->b_die )
{
/* We take the lock, because we are going to read/write the start/end
* indexes of the parser fifo */
vlc_mutex_lock( &p_vpar->fifo.data_lock );
/* ?? trash all trashable PES packets */
/* Trash all received PES packets */
while( !DECODER_FIFO_ISEMPTY(p_vpar->fifo) )
{
input_NetlistFreePES( p_vpar->bit_stream.p_input,
DECODER_FIFO_START(p_vpar->fifo) );
input_NetlistFreePES( p_vpar->bit_stream.p_input, DECODER_FIFO_START(p_vpar->fifo) );
DECODER_FIFO_INCSTART( p_vpar->fifo );
}
vlc_mutex_unlock( &p_vpar->fifo.data_lock );
/* Sleep a while */
msleep( VPAR_IDLE_SLEEP );
/* Waiting for the input thread to put new PES packets in the fifo */
vlc_cond_wait( &p_vpar->fifo.data_wait, &p_vpar->fifo.data_lock );
}
/* We can release the lock before leaving */
vlc_mutex_unlock( &p_vpar->fifo.data_lock );
}
/*******************************************************************************
......@@ -435,5 +445,7 @@ static void EndThread( vpar_thread_t *p_vpar )
free( p_vpar->pp_vdec[0] );
#endif
free( p_vpar );
intf_DbgMsg("vpar debug: EndThread(%p)\n", p_vpar);
}
......@@ -631,7 +631,7 @@ static __inline__ void DecodeMPEG2NonIntra( vpar_thread_t * p_vpar,
i_nc = 0;
i_coef = 0;
for( i_parse = 0; ; i_parse++ )
for( i_parse = 0; !p_vpar->b_die; i_parse++ )
{
i_code = ShowBits( &p_vpar->bit_stream, 16 );
if( i_code >= 16384 )
......@@ -832,7 +832,7 @@ static __inline__ void DecodeMPEG2Intra( vpar_thread_t * p_vpar,
i_coef = 0;
b_vlc_intra = p_vpar->picture.b_intra_vlc_format;
for( i_parse = 1; /*i_parse < 64*/; i_parse++ )
for( i_parse = 1; !p_vpar->b_die/*i_parse < 64*/; i_parse++ )
{
i_code = ShowBits( &p_vpar->bit_stream, 16 );
if( i_code >= 16384 )
......
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