]> git.sesse.net Git - vlc/blobdiff - modules/packetizer/h264.c
Removes trailing spaces. Removes tabs.
[vlc] / modules / packetizer / h264.c
index efb0e2c7e22124e80dd6eeb632b5dd68f18d76d1..23e1720c656450a0d2cbdb5d432127a94b4476a6 100644 (file)
@@ -27,7 +27,6 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
 
 #include <vlc/vlc.h>
 #include <vlc_sout.h>
@@ -246,7 +245,7 @@ static int Open( vlc_object_t *p_this )
         /* FIXME: FFMPEG isn't happy at all if you leave this */
         if( p_dec->fmt_out.i_extra ) free( p_dec->fmt_out.p_extra );
         p_dec->fmt_out.i_extra = 0; p_dec->fmt_out.p_extra = NULL;
-        
         /* Set the new extradata */
         p_dec->fmt_out.i_extra = p_sys->p_pps->i_buffer + p_sys->p_sps->i_buffer;
         p_dec->fmt_out.p_extra = (uint8_t*)malloc( p_dec->fmt_out.i_extra );
@@ -259,10 +258,10 @@ static int Open( vlc_object_t *p_this )
     }
     else
     {
-        /* This type of stream contains data with 3 of 4 byte startcodes 
+        /* This type of stream contains data with 3 of 4 byte startcodes
          * The fmt_in.p_extra MAY contain SPS/PPS with 4 byte startcodes
          * The fmt_out.p_extra should be the same */
-         
         /* Set callback */
         p_dec->pf_packetize = Packetize;
 
@@ -311,7 +310,25 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
     decoder_sys_t *p_sys = p_dec->p_sys;
     block_t       *p_pic;
 
-    if( !pp_block || !*pp_block ) return NULL;
+    if( !pp_block || !*pp_block )
+        return NULL;
+
+    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    {
+        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamFlush( &p_sys->bytestream );
+
+            if( p_sys->p_frame )
+                block_ChainRelease( p_sys->p_frame );
+            p_sys->p_frame = NULL;
+            p_sys->slice.i_frame_type = 0;
+            p_sys->b_slice = VLC_FALSE;
+        }
+        block_Release( *pp_block );
+        return NULL;
+    }
 
     block_BytestreamPush( &p_sys->bytestream, *pp_block );
 
@@ -400,7 +417,13 @@ static block_t *PacketizeAVC1( decoder_t *p_dec, block_t **pp_block )
     block_t       *p_ret = NULL;
     uint8_t       *p;
 
-    if( !pp_block || !*pp_block ) return NULL;
+    if( !pp_block || !*pp_block )
+        return NULL;
+    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    {
+        block_Release( *pp_block );
+        return NULL;
+    }
 
     p_block = *pp_block;
     *pp_block = NULL;
@@ -500,7 +523,7 @@ static inline int bs_read_se( bs_t *s )
 
 /*****************************************************************************
  * ParseNALBlock: parses annexB type NALs
- * All p_frag blocks are required to start with 0 0 0 1 4-byte startcode 
+ * All p_frag blocks are required to start with 0 0 0 1 4-byte startcode
  *****************************************************************************/
 static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
 {