h264parse: fix regression in output buffer timestamping
Specifically, properly mark a buffer (NALU or AU) to start a frame or not.
diff --git a/gst/h264parse/gsth264parse.c b/gst/h264parse/gsth264parse.c
index 43696da..42a10cb 100644
--- a/gst/h264parse/gsth264parse.c
+++ b/gst/h264parse/gsth264parse.c
@@ -1453,7 +1453,7 @@
guint8 *data;
GstBuffer *outbuf = NULL;
guint outsize, size, nal_length = h264parse->nal_length_size;
- gboolean start = h264parse->picture_start;
+ gboolean start;
gboolean complete;
data = GST_BUFFER_DATA (nal);
@@ -1466,6 +1466,8 @@
nal_type = data[nal_length] & 0x1f;
GST_LOG_OBJECT (h264parse, "nal type: %d", nal_type);
h264parse->picture_start |= (nal_type == 1 || nal_type == 2 || nal_type == 5);
+ /* first_mb_in_slice == 0 considered start of frame */
+ start = h264parse->picture_start && (data[nal_length + 1] & 0x80);
if (G_UNLIKELY (!next_nal)) {
complete = TRUE;
} else {
@@ -1545,13 +1547,16 @@
outbuf = gst_adapter_take_buffer (h264parse->picture_adapter, outsize);
outbuf = gst_buffer_make_metadata_writable (outbuf);
GST_BUFFER_TIMESTAMP (outbuf) = ts;
+
+ /* AU always starts a frame */
+ start = TRUE;
}
} else {
outbuf = gst_h264parse_write_nal_prefix (h264parse, nal);
}
if (_start)
- *_start = (h264parse->picture_start != start);
+ *_start = start;
return outbuf;
}
@@ -1740,9 +1745,6 @@
if (!outbuf) {
/* no complete unit yet, go for next round */
continue;
- } else {
- if (h264parse->merge)
- start = TRUE;
}
/* Ignore upstream dts that stalls or goes backward. Upstream elements