Skip to content
Snippets Groups Projects
Commit 47aaf6af authored by François Cartegnie's avatar François Cartegnie :fingers_crossed: Committed by Steve Lhomme
Browse files

codec: mad: discard glitch on seek

decoder never really resets
parent 405346f2
No related branches found
No related tags found
1 merge request!2362codec: mad: discard glitch on seek
Pipeline #251219 canceled with stage
in 18 minutes and 22 seconds
......@@ -78,6 +78,16 @@ vlc_module_begin ()
set_callbacks( Open, Close )
vlc_module_end ()
/*****************************************************************************
*
*****************************************************************************/
static void PrepareDecoderDiscontinuityGlitch( decoder_sys_t *p_sys )
{
mad_frame_mute( &p_sys->mad_frame );
mad_synth_mute( &p_sys->mad_synth );
p_sys->i_reject_count = 3;
}
/*****************************************************************************
* DecodeBlock: decode an MPEG audio frame.
*****************************************************************************/
......@@ -133,25 +143,30 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
mad_stream_buffer( &p_sys->mad_stream, p_last_buf->p_buffer,
p_last_buf->i_buffer );
/* Do the actual decoding now (ignore EOF error when draining). */
if ( mad_frame_decode( &p_sys->mad_frame, &p_sys->mad_stream ) == -1
&& p_sys->i_reject_count == 0
&& ( pp_block != NULL || p_sys->mad_stream.error != MAD_ERROR_BUFLEN ) )
{
msg_Err( p_dec, "libmad error: %s",
mad_stream_errorstr( &p_sys->mad_stream ) );
if( !MAD_RECOVERABLE( p_sys->mad_stream.error ) )
p_sys->i_reject_count = 3;
PrepareDecoderDiscontinuityGlitch( p_sys );
}
else if( p_last_buf->i_flags & BLOCK_FLAG_DISCONTINUITY )
{
p_sys->i_reject_count = 3;
PrepareDecoderDiscontinuityGlitch( p_sys );
}
if( p_sys->i_reject_count > 0 )
if( p_sys->i_reject_count > 1 )
goto reject;
mad_synth_frame( &p_sys->mad_synth, &p_sys->mad_frame );
if( p_sys->i_reject_count > 0 )
goto reject;
struct mad_pcm * p_pcm = &p_sys->mad_synth.pcm;
unsigned int i_samples = p_pcm->length;
mad_fixed_t const * p_left = p_pcm->samples[0];
......@@ -168,7 +183,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
{
msg_Err( p_dec, "wrong channels count (corrupt stream?): %u > %u",
p_pcm->channels, p_dec->fmt_out.audio.i_channels);
p_sys->i_reject_count = 3;
PrepareDecoderDiscontinuityGlitch( p_sys );
goto reject;
}
......@@ -176,7 +191,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
{
msg_Err( p_dec, "unexpected samples count (corrupt stream?): "
"%u / %u", i_samples, p_out_buf->i_nb_samples );
p_sys->i_reject_count = 3;
PrepareDecoderDiscontinuityGlitch( p_sys );
goto reject;
}
......@@ -232,6 +247,8 @@ static void DecodeFlush( decoder_t *p_dec )
if( p_sys->p_last_buf )
block_Release( p_sys->p_last_buf );
p_sys->p_last_buf = NULL;
PrepareDecoderDiscontinuityGlitch( p_sys );
}
/*****************************************************************************
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment