av1parse: Don't immediatly reset timestamp in presence of TD
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Mon, 2 Dec 2024 16:32:13 +0000 (11:32 -0500)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 20 Dec 2024 01:26:12 +0000 (01:26 +0000)
When a TD is being processed, it is not always pushed immediatly. Resetting
the time information lead to lost of timestamp in TU to Frame conversion. The
TU would be formed by buffer of [TD][Frame], and the timestamp taken from
the TU buffer was lost then the TD was handled.

The handling of TS should be entirely done by the 3 functions:

- gst_av1_parse_handle_obu_to_obu() (direct input to output)
- gst_av1_parse_handle_to_big_align() Reset DTS on detected TU or TD
- gst_av1_parse_handle_to_small_and_equal_align() PTS on show frame, flat DTS

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/79312357a6ab8ebc4cfc1ed2243bdbc0660c39d5
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8026>

subprojects/gst-plugins-bad/gst/videoparsers/gstav1parse.c

index 9831357bf10103035340bd76b79ad4152ef67830..032dbd7c60b733d3cfb39d5c8c3dffe38e4f341a 100644 (file)
@@ -1593,7 +1593,6 @@ gst_av1_parse_handle_one_obu (GstAV1Parse * self, GstAV1OBU * obu,
      start a TU. We only check TD here. */
   if (obu->obu_type == GST_AV1_OBU_TEMPORAL_DELIMITER) {
     gst_av1_parse_reset_obu_data_state (self);
-    gst_av1_parse_reset_tu_timestamp (self);
 
     if (check_new_tu) {
       *check_new_tu = TRUE;
@@ -1950,21 +1949,16 @@ again:
     if (res != GST_AV1_PARSER_OK)
       break;
 
-    /* Take the DTS from the first OBU of the TU */
-    if (!GST_CLOCK_TIME_IS_VALID (self->buffer_dts))
-      self->buffer_dts = GST_BUFFER_DTS (buffer);
-
     check_new_tu = FALSE;
-    if (self->align == GST_AV1_PARSE_ALIGN_TEMPORAL_UNIT
-        || self->align == GST_AV1_PARSE_ALIGN_TEMPORAL_UNIT_ANNEX_B) {
-      res = gst_av1_parse_handle_one_obu (self, &obu, &frame_complete,
-          &check_new_tu);
-    } else {
-      res = gst_av1_parse_handle_one_obu (self, &obu, &frame_complete, NULL);
-    }
+    res = gst_av1_parse_handle_one_obu (self, &obu, &frame_complete,
+        &check_new_tu);
     if (res != GST_AV1_PARSER_OK)
       break;
 
+    /* Take the DTS from the first OBU of the TU */
+    if (!GST_CLOCK_TIME_IS_VALID (self->buffer_dts) || check_new_tu)
+      self->buffer_dts = GST_BUFFER_DTS (buffer);
+
     if (check_new_tu && (gst_adapter_available (self->cache_out) ||
             gst_adapter_available (self->frame_cache))) {
       complete = TRUE;