h264parse: mind to-be-skipped data in subsequent re-used offsets
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Fri, 18 Nov 2011 14:12:46 +0000 (15:12 +0100)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Fri, 18 Nov 2011 16:20:06 +0000 (17:20 +0100)
gst/videoparsers/gsth264parse.c

index 1685087..d813127 100644 (file)
@@ -653,7 +653,7 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse,
           *skipsize = nalu.offset;
 
           GST_DEBUG_OBJECT (h264parse, "skipping broken nal");
-          return FALSE;
+          goto invalid;
         } else {
           nalu.size = 0;
           goto end;
@@ -675,7 +675,7 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse,
           /*  Can't parse the nalu */
           if (size - h264parse->nalu.offset < 2) {
             *skipsize = nalu.offset;
-            return FALSE;
+            goto invalid;
           }
 
           /* We parse it anyway */
@@ -715,6 +715,10 @@ more:
   if (!h264parse->nalu.size) {
     /* skip up to initial startcode */
     *skipsize = h264parse->nalu.sc_offset;
+    /* but mind some stuff will have been skipped */
+    g_assert (current_off >= *skipsize);
+    current_off -= *skipsize;
+    h264parse->nalu.sc_offset = 0;
   } else {
     *skipsize = 0;
   }
@@ -723,6 +727,10 @@ more:
   h264parse->current_off = current_off;
 
   return FALSE;
+
+invalid:
+  gst_h264_parse_reset_frame (h264parse);
+  return FALSE;
 }
 
 /* byte together avc codec data based on collected pps and sps so far */