Revert "videorate: Only "close" the segment if it is discontinous"

This reverts commit 6f7922b4db.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2186

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2254>
This commit is contained in:
Sebastian Dröge 2022-04-21 11:41:25 +03:00 committed by GStreamer Marge Bot
parent 98112a3ddc
commit 2599cf573a
2 changed files with 40 additions and 60 deletions

View file

@ -794,35 +794,12 @@ gst_video_rate_sink_event (GstBaseTransform * trans, GstEvent * event)
{ {
GstSegment segment; GstSegment segment;
gint seqnum; gint seqnum;
GstClockTime base_ts, next_ts;
gboolean reset_base_ts = FALSE;
gst_event_copy_segment (event, &segment); gst_event_copy_segment (event, &segment);
if (segment.format != GST_FORMAT_TIME) if (segment.format != GST_FORMAT_TIME)
goto format_error; goto format_error;
GST_DEBUG_OBJECT (videorate, "handle SEGMENT event"); GST_DEBUG_OBJECT (videorate, "handle NEWSEGMENT");
/* We just want to update the accumulated stream_time */
segment.start = (gint64) (segment.start / videorate->rate);
segment.position = (gint64) (segment.position / videorate->rate);
if (GST_CLOCK_TIME_IS_VALID (segment.stop))
segment.stop = (gint64) (segment.stop / videorate->rate);
segment.time = (gint64) (segment.time / videorate->rate);
base_ts = gst_segment_position_from_running_time (&segment,
GST_FORMAT_TIME,
gst_segment_to_running_time (&videorate->segment, GST_FORMAT_TIME,
videorate->base_ts));
next_ts = gst_segment_position_from_running_time (&segment,
GST_FORMAT_TIME,
gst_segment_to_running_time (&videorate->segment, GST_FORMAT_TIME,
videorate->next_ts));
/* Reset if the segment is discontinuous */
if (next_ts == GST_CLOCK_TIME_NONE) {
reset_base_ts = TRUE;
/* close up the previous segment, if appropriate */ /* close up the previous segment, if appropriate */
if (videorate->prevbuf) { if (videorate->prevbuf) {
@ -858,21 +835,30 @@ gst_video_rate_sink_event (GstBaseTransform * trans, GstEvent * event)
/* clean up for the new one; _chain will resume from the new start */ /* clean up for the new one; _chain will resume from the new start */
gst_video_rate_swap_prev (videorate, NULL, 0); gst_video_rate_swap_prev (videorate, NULL, 0);
} }
} else if (base_ts == GST_CLOCK_TIME_NONE) {
reset_base_ts = TRUE;
}
if (reset_base_ts) {
base_ts = 0; /* We just want to update the accumulated stream_time */
videorate->out_frame_count = 0;
} segment.start = (gint64) (segment.start / videorate->rate);
videorate->next_ts = next_ts; segment.position = (gint64) (segment.position / videorate->rate);
videorate->base_ts = base_ts; if (GST_CLOCK_TIME_IS_VALID (segment.stop))
segment.stop = (gint64) (segment.stop / videorate->rate);
segment.time = (gint64) (segment.time / videorate->rate);
videorate->base_ts = gst_segment_position_from_running_time (&segment,
GST_FORMAT_TIME,
gst_segment_to_running_time (&videorate->segment, GST_FORMAT_TIME,
videorate->base_ts));
videorate->next_ts = gst_segment_position_from_running_time (&segment,
GST_FORMAT_TIME,
gst_segment_to_running_time (&videorate->segment, GST_FORMAT_TIME,
videorate->next_ts));
gst_segment_copy_into (&segment, &videorate->segment); gst_segment_copy_into (&segment, &videorate->segment);
GST_DEBUG_OBJECT (videorate, "updated segment: %" GST_SEGMENT_FORMAT, GST_DEBUG_OBJECT (videorate, "updated segment: %" GST_SEGMENT_FORMAT,
&videorate->segment); &videorate->segment);
seqnum = gst_event_get_seqnum (event); seqnum = gst_event_get_seqnum (event);
gst_event_unref (event); gst_event_unref (event);
event = gst_event_new_segment (&segment); event = gst_event_new_segment (&segment);

View file

@ -1645,17 +1645,12 @@ GST_START_TEST (test_segment_update)
next_ts += GST_SECOND / 25; next_ts += GST_SECOND / 25;
} }
gst_check_drop_buffers (); gst_check_drop_buffers ();
fail_unless_equals_uint64 (next_ts, 1 * GST_SECOND + (GST_SECOND / 25));
/* Send a pointless segment update, shouldn't change anything */ /* Send a pointless segment update, shouldn't change anything */
gst_segment_init (&segment, GST_FORMAT_TIME); gst_segment_init (&segment, GST_FORMAT_TIME);
segment.position = 5 * GST_SECOND; segment.position = 5 * GST_SECOND;
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment))); fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));
/* Shouldnt push anything, rest is same as above */
fail_unless_equals_int (g_list_length (buffers), 0);
assert_videorate_stats (videorate, "second", 2, 26, 0, 25);
/* third buffer */ /* third buffer */
third = gst_buffer_new_and_alloc (4); third = gst_buffer_new_and_alloc (4);
GST_BUFFER_TIMESTAMP (third) = 3 * GST_SECOND; GST_BUFFER_TIMESTAMP (third) = 3 * GST_SECOND;
@ -1676,7 +1671,6 @@ GST_START_TEST (test_segment_update)
next_ts += GST_SECOND / 25; next_ts += GST_SECOND / 25;
} }
fail_unless_equals_uint64 (next_ts, (25 + 25 + 13) * (GST_SECOND / 25));
/* cleanup */ /* cleanup */
gst_buffer_unref (first); gst_buffer_unref (first);