From 0b745f67db940ff486e2f26078982c4071e50623 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sat, 10 May 2025 20:39:42 -0400 Subject: [PATCH] videorate: Convert input ts to output scale to close segment Otherwise we compare values that are in two different time scales. Part-of: --- .../gst/videorate/gstvideorate.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/videorate/gstvideorate.c b/subprojects/gst-plugins-base/gst/videorate/gstvideorate.c index 846ad85c29..252d5c5048 100644 --- a/subprojects/gst-plugins-base/gst/videorate/gstvideorate.c +++ b/subprojects/gst-plugins-base/gst/videorate/gstvideorate.c @@ -996,9 +996,11 @@ gst_video_rate_check_duplicate_to_close_segment (GstVideoRate * videorate, GstClockTime next_stream_time = videorate->next_output_ts; GstClockTime max_closing_segment_duplication_duration = videorate->max_closing_segment_duplication_duration; + GstClockTime last_input_ts_in_output_scale = last_input_ts / videorate->rate; - if (!GST_CLOCK_TIME_IS_VALID (videorate->next_output_ts)) + if (!GST_CLOCK_TIME_IS_VALID (videorate->next_output_ts)) { return FALSE; + } if (videorate->segment.rate > 0.0) { @@ -1007,14 +1009,16 @@ gst_video_rate_check_duplicate_to_close_segment (GstVideoRate * videorate, return is_first; } - if (next_stream_time >= videorate->segment.stop) + if (next_stream_time >= videorate->segment.stop) { return FALSE; + } if (GST_CLOCK_TIME_IS_VALID (max_closing_segment_duplication_duration)) { - if (last_input_ts > videorate->next_output_ts) + if (last_input_ts_in_output_scale > videorate->next_output_ts) { return TRUE; + } - return (videorate->next_output_ts - last_input_ts < + return (videorate->next_output_ts - last_input_ts_in_output_scale < max_closing_segment_duplication_duration); } @@ -1032,10 +1036,10 @@ gst_video_rate_check_duplicate_to_close_segment (GstVideoRate * videorate, return FALSE; if (GST_CLOCK_TIME_IS_VALID (max_closing_segment_duplication_duration)) { - if (last_input_ts < videorate->next_output_ts) + if (last_input_ts_in_output_scale < videorate->next_output_ts) return TRUE; - return (last_input_ts - videorate->next_output_ts < + return (last_input_ts_in_output_scale - videorate->next_output_ts < max_closing_segment_duplication_duration); }