h264/h265parse: Fix handling of very last frame
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 22 Apr 2020 21:53:39 +0000 (17:53 -0400)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 23 Apr 2020 12:28:54 +0000 (12:28 +0000)
Baseparse will never call us back on draining, so going into more: label will
cause the current frame to be discarded. So if we have a complete NAL, but not
a complete AU, make sure to terminate the frame properly.

This is a gression introduce by commit e88d8480709581a2e54b7954c47193b729b23c79 and
a194a87b2600a21f1b47b8c89b1c930d5f30de42.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1275

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1208>

gst/videoparsers/gsth264parse.c
gst/videoparsers/gsth265parse.c

index f825500..6a2c3d3 100644 (file)
@@ -1546,8 +1546,13 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
     /* expect at least 3 bytes start_code, and 1 bytes NALU header.
      * the length of the NALU payload can be zero.
      * (e.g. EOS/EOB placed at the end of an AU.) */
-    if (size - current_off < 4)
+    if (size - current_off < 4) {
+      /* Finish the frame if there is no more data in the stream */
+      if (drain)
+        break;
+
       goto more;
+    }
   }
 
 end:
index 26be12d..33cb962 100644 (file)
@@ -1341,8 +1341,13 @@ gst_h265_parse_handle_frame (GstBaseParse * parse,
     /* expect at least 3 bytes start_code, and 2 bytes NALU header.
      * the length of the NALU payload can be zero.
      * (e.g. EOS/EOB placed at the end of an AU.) */
-    if (G_UNLIKELY (size - current_off < 5))
+    if (G_UNLIKELY (size - current_off < 5)) {
+      /* Finish the frame if there is no more data in the stream */
+      if (drain)
+        break;
+
       goto more;
+    }
   }
 
 end: