summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2020-05-06 22:28:34 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2020-05-07 12:08:36 -0400
commitdc4c470d7518ceba69a501f149952cfa00052256 (patch)
treeb472f6fcc97f8e061b02b2065792d47e74522b5b /gst
parent9029631f752d004912a02b775002579f414a2b33 (diff)
downloadgstreamer-plugins-bad-dc4c470d7518ceba69a501f149952cfa00052256.tar.gz
h264parse: Properly handle 4 bytes start code
This will stop stripping four bytes start code. This was fixed and broken again as it was causing the a timestamp shift. We now call gst_base_parse_set_ts_at_offset() with the offset of the first NAL to ensure that fixing a moderatly broken input stream won't affect the timestamps. We also fixes the unit test, removing a comment about the stripping behaviour not being correct. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1251>
Diffstat (limited to 'gst')
-rw-r--r--gst/videoparsers/gsth264parse.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c
index 6a2c3d388..8f1215196 100644
--- a/gst/videoparsers/gsth264parse.c
+++ b/gst/videoparsers/gsth264parse.c
@@ -1315,7 +1315,6 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
GstH264NalUnit nalu;
GstH264ParserResult pres;
gint framesize;
- GstFlowReturn ret;
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (frame->buffer,
GST_BUFFER_FLAG_DISCONT))) {
@@ -1380,22 +1379,6 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
switch (pres) {
case GST_H264_PARSER_OK:
if (nalu.sc_offset > 0) {
- int i;
- gboolean is_filler_data = TRUE;
- /* Handle filler data */
- for (i = 0; i < nalu.sc_offset; i++) {
- if (data[i] != 0x00) {
- is_filler_data = FALSE;
- break;
- }
- }
- if (is_filler_data) {
- GST_DEBUG_OBJECT (parse, "Dropping filler data %d", nalu.sc_offset);
- frame->flags |= GST_BASE_PARSE_FRAME_FLAG_DROP;
- gst_buffer_unmap (buffer, &map);
- ret = gst_base_parse_finish_frame (parse, frame, nalu.sc_offset);
- goto drop;
- }
*skipsize = nalu.sc_offset;
goto skip;
}
@@ -1410,6 +1393,10 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
("Error parsing H.264 stream"), ("Invalid H.264 stream"));
goto invalid_stream;
}
+
+ /* Ensure we use the TS of the first NAL. This avoids broken timestamp in
+ * the case of a miss-placed filler byte. */
+ gst_base_parse_set_ts_at_offset (parse, nalu.offset);
}
while (TRUE) {
@@ -1576,10 +1563,6 @@ out:
gst_buffer_unmap (buffer, &map);
return GST_FLOW_OK;
-drop:
- GST_DEBUG_OBJECT (h264parse, "Dropped data");
- return ret;
-
skip:
GST_DEBUG_OBJECT (h264parse, "skipping %d", *skipsize);
/* If we are collecting access units, we need to preserve the initial