[vlc-commits] [Git][videolan/vlc][master] codec: mad: discard glitch on seek

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Aug 12 05:23:23 UTC 2022



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
47aaf6af by Francois Cartegnie at 2022-08-12T05:11:40+00:00
codec: mad: discard glitch on seek

decoder never really resets

- - - - -


1 changed file:

- modules/codec/mad.c


Changes:

=====================================
modules/codec/mad.c
=====================================
@@ -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 );
 }
 
 /*****************************************************************************



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/47aaf6afd174324cc2935a23d4066c8e25e02162

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/47aaf6afd174324cc2935a23d4066c8e25e02162
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list