From 0d637c14c5233ebbba7d11b988b69e935f00e82f Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 22 Apr 2020 17:53:39 -0400 Subject: [PATCH] h264/h265parse: Fix handling of very last frame 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: --- gst/videoparsers/gsth264parse.c | 7 ++++++- gst/videoparsers/gsth265parse.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index f825500..6a2c3d3 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -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: diff --git a/gst/videoparsers/gsth265parse.c b/gst/videoparsers/gsth265parse.c index 26be12d..33cb962 100644 --- a/gst/videoparsers/gsth265parse.c +++ b/gst/videoparsers/gsth265parse.c @@ -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: -- 2.7.4