[vlc-commits] codecs: fix discontinuity handling

Francois Cartegnie git at videolan.org
Sat Feb 18 20:30:06 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Feb 18 18:25:39 2017 +0100| [477abfabd5fc9b566f04a1edf58938c546ae478e] | committer: Francois Cartegnie

codecs: fix discontinuity handling

corrupted block is implicitely a discontinuity
fixup of ce6db7865c0f3c34624d385c9aeace49fa10b3d1

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=477abfabd5fc9b566f04a1edf58938c546ae478e
---

 modules/codec/adpcm.c        |  9 +++++----
 modules/codec/aes3.c         | 13 +++++++------
 modules/codec/araw.c         |  9 +++++----
 modules/codec/g711.c         | 13 +++++++------
 modules/codec/lpcm.c         | 14 ++++++++------
 modules/codec/opus.c         | 13 +++++++------
 modules/codec/rawvideo.c     |  9 ++++++++-
 modules/codec/schroedinger.c | 11 +++++++----
 modules/codec/speex.c        | 13 ++++++++++---
 modules/codec/theora.c       | 19 ++++++++++---------
 modules/codec/vorbis.c       | 13 +++++++------
 11 files changed, 81 insertions(+), 55 deletions(-)

diff --git a/modules/codec/adpcm.c b/modules/codec/adpcm.c
index 457f2fc..f61bd54 100644
--- a/modules/codec/adpcm.c
+++ b/modules/codec/adpcm.c
@@ -318,11 +318,12 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     p_block = *pp_block;
 
-    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
-        goto drop;
-
-    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+    if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    {
         Flush( p_dec );
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+            goto drop;
+    }
 
     if( p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
diff --git a/modules/codec/aes3.c b/modules/codec/aes3.c
index 019e242..daee35e 100644
--- a/modules/codec/aes3.c
+++ b/modules/codec/aes3.c
@@ -330,14 +330,15 @@ static block_t * Parse( decoder_t *p_dec, int *pi_frame_length, int *pi_bits,
     if( !p_block ) /* No drain */
         return NULL;
 
-    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED|BLOCK_FLAG_DISCONTINUITY) )
     {
-        block_Release( p_block );
-        return NULL;
-    }
-
-    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
         Flush( p_dec );
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        {
+            block_Release( p_block );
+            return NULL;
+        }
+    }
 
     /* Date management */
     if( p_block->i_pts > VLC_TS_INVALID &&
diff --git a/modules/codec/araw.c b/modules/codec/araw.c
index 50f8e85..6430e26 100644
--- a/modules/codec/araw.c
+++ b/modules/codec/araw.c
@@ -321,11 +321,12 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
     if( p_block == NULL ) /* No Drain */
         return VLCDEC_SUCCESS;
 
-    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
-        goto skip;
-
-    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+    if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED|BLOCK_FLAG_DISCONTINUITY) )
+    {
         Flush( p_dec );
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+            goto skip;
+    }
 
     if( p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
diff --git a/modules/codec/g711.c b/modules/codec/g711.c
index 13e7562..95483e8 100644
--- a/modules/codec/g711.c
+++ b/modules/codec/g711.c
@@ -228,14 +228,15 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
     if( p_block == NULL ) /* No Drain */
         return VLCDEC_SUCCESS;
 
-    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED|BLOCK_FLAG_DISCONTINUITY) )
     {
-        block_Release( p_block);
-        return VLCDEC_SUCCESS;
-    }
-
-    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
         Flush( p_dec );
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        {
+            block_Release( p_block );
+            return VLCDEC_SUCCESS;
+        }
+    }
 
     if( p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
diff --git a/modules/codec/lpcm.c b/modules/codec/lpcm.c
index c48d10d..a3df204 100644
--- a/modules/codec/lpcm.c
+++ b/modules/codec/lpcm.c
@@ -340,13 +340,15 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
     p_block = *pp_block;
     *pp_block = NULL; /* So the packet doesn't get re-sent */
 
-    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
-        Flush( p_dec );
-
-    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED|BLOCK_FLAG_DISCONTINUITY) )
     {
-        block_Release( p_block );
-        return NULL;
+        Flush( p_dec );
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        {
+            block_Release( p_block );
+            *pp_block = NULL;
+            return NULL;
+        }
     }
 
     /* Date management */
diff --git a/modules/codec/opus.c b/modules/codec/opus.c
index 68c479c..71b9b16 100644
--- a/modules/codec/opus.c
+++ b/modules/codec/opus.c
@@ -398,14 +398,15 @@ static block_t *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED|BLOCK_FLAG_DISCONTINUITY) )
     {
-        block_Release( p_block );
-        return NULL;
-    }
-
-    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
         Flush( p_dec );
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        {
+            block_Release( p_block );
+            return NULL;
+        }
+    }
 
     /* Date management */
     if( p_block->i_pts > VLC_TS_INVALID &&
diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c
index 09ef1ba..7500d7a 100644
--- a/modules/codec/rawvideo.c
+++ b/modules/codec/rawvideo.c
@@ -148,8 +148,15 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t *p_block )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+    if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED|BLOCK_FLAG_DISCONTINUITY) )
+    {
         date_Set( &p_sys->pts, p_block->i_dts );
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        {
+            block_Release( p_block );
+            return NULL;
+        }
+    }
 
     if( p_block->i_pts <= VLC_TS_INVALID && p_block->i_dts <= VLC_TS_INVALID &&
         !date_Get( &p_sys->pts ) )
diff --git a/modules/codec/schroedinger.c b/modules/codec/schroedinger.c
index 77d8ae5..e83240f 100644
--- a/modules/codec/schroedinger.c
+++ b/modules/codec/schroedinger.c
@@ -769,11 +769,14 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
 
         /* reset the decoder when seeking as the decode in progress is invalid */
         /* discard the block as it is just a null magic block */
-        if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED) ) {
+        if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED|BLOCK_FLAG_DISCONTINUITY) )
+        {
             Flush( p_dec );
-
-            block_Release( p_block );
-            return VLCDEC_SUCCESS;
+            if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+            {
+                block_Release( p_block );
+                return VLCDEC_SUCCESS;
+            }
         }
 
         SchroBuffer *p_schrobuffer;
diff --git a/modules/codec/speex.c b/modules/codec/speex.c
index 71fde34..6cec569 100644
--- a/modules/codec/speex.c
+++ b/modules/codec/speex.c
@@ -340,6 +340,16 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( block != NULL )
     {
+        if( block->i_flags & (BLOCK_FLAG_CORRUPTED|BLOCK_FLAG_DISCONTINUITY) )
+        {
+            Flush( p_dec );
+            if( block->i_flags & BLOCK_FLAG_CORRUPTED )
+            {
+                block_Release( block );
+                *pp_block = NULL;
+                return NULL;
+            }
+        }
         /* Block to Ogg packet */
         oggpacket.packet = block->p_buffer;
         oggpacket.bytes = block->i_buffer;
@@ -568,9 +578,6 @@ static block_t *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     decoder_sys_t *p_sys = p_dec->p_sys;
     block_t *p_block = *pp_block;
 
-    if( p_block && p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
-        Flush( p_dec );
-
     /* Date management */
     if( p_block && p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
diff --git a/modules/codec/theora.c b/modules/codec/theora.c
index 8f364fe..31dfd61 100644
--- a/modules/codec/theora.c
+++ b/modules/codec/theora.c
@@ -457,16 +457,17 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     decoder_sys_t *p_sys = p_dec->p_sys;
     void *p_buf;
 
-    if( ( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY ) != 0 )
-        p_sys->i_pts = p_block->i_pts;
-
-    if( ( p_block->i_flags & BLOCK_FLAG_CORRUPTED ) != 0 )
+    if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        /* Don't send the a corrupted packet to
-         * theora_decode, otherwise we get purple/green display artifacts
-         * appearing in the video output */
-        block_Release(p_block);
-        return NULL;
+        Flush( p_dec );
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        {
+            /* Don't send the a corrupted packet to
+             * theora_decode, otherwise we get purple/green display artifacts
+             * appearing in the video output */
+            block_Release(p_block);
+            return NULL;
+        }
     }
 
     /* Date management */
diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c
index a54b0ca..6f6ed8b 100644
--- a/modules/codec/vorbis.c
+++ b/modules/codec/vorbis.c
@@ -472,13 +472,14 @@ static block_t *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     if( !p_block )
         return NULL;
 
-    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
-        Flush( p_dec );
-
-    if( ( p_block->i_flags & BLOCK_FLAG_CORRUPTED ) != 0 )
+    if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        block_Release(p_block);
-        return NULL;
+        Flush( p_dec );
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        {
+            block_Release(p_block);
+            return NULL;
+        }
     }
 
     /* Date management */



More information about the vlc-commits mailing list