From 98d40251d8aa649c024ae71fa2e7bab37bcb7999 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Mon, 2 Dec 2024 11:32:13 -0500 Subject: [PATCH] av1parse: Don't immediatly reset timestamp in presence of TD 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: --- .../gst/videoparsers/gstav1parse.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/videoparsers/gstav1parse.c b/subprojects/gst-plugins-bad/gst/videoparsers/gstav1parse.c index 9831357bf1..032dbd7c60 100644 --- a/subprojects/gst-plugins-bad/gst/videoparsers/gstav1parse.c +++ b/subprojects/gst-plugins-bad/gst/videoparsers/gstav1parse.c @@ -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;