identity,clocksync: Fix timestamping inside single segment in reverse playback

In reverse playback, buffers are played back from buffer.stop
(buffer.pts + buffer.duration) to buffer.pts running times which
mean that we need to use the buffer end running time as a buffer
timestsamp, not the buffer pts when using a single segment in reverse
playback.

This is now being tested in
`validate.test.identity.reverse_single_segment`

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/450>
This commit is contained in:
Thibault Saunier 2020-04-28 13:28:32 -04:00 committed by GStreamer Merge Bot
parent 39b9cc554c
commit b517b59171
2 changed files with 30 additions and 8 deletions

View file

@ -338,10 +338,21 @@ gst_clock_sync_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
GstClockTime runtimestamp = 0;
GstClockTime rundts, runpts;
if (clocksync->segment.rate > 0.0) {
rundts = gst_segment_to_running_time (&clocksync->segment,
GST_FORMAT_TIME, GST_BUFFER_DTS (buf));
runpts = gst_segment_to_running_time (&clocksync->segment,
GST_FORMAT_TIME, GST_BUFFER_PTS (buf));
} else {
runpts = gst_segment_to_running_time (&clocksync->segment,
GST_FORMAT_TIME, GST_CLOCK_TIME_IS_VALID (buf->duration)
&& GST_CLOCK_TIME_IS_VALID (buf->pts) ? buf->pts +
buf->duration : buf->pts);
rundts = gst_segment_to_running_time (&clocksync->segment,
GST_FORMAT_TIME, GST_CLOCK_TIME_IS_VALID (buf->duration)
&& GST_CLOCK_TIME_IS_VALID (buf->dts) ? buf->dts +
buf->duration : buf->dts);
}
if (GST_CLOCK_TIME_IS_VALID (rundts))
runtimestamp = rundts;

View file

@ -687,10 +687,21 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
g_signal_emit (identity, gst_identity_signals[SIGNAL_HANDOFF], 0, buf);
if (trans->segment.format == GST_FORMAT_TIME) {
rundts = gst_segment_to_running_time (&trans->segment,
GST_FORMAT_TIME, GST_BUFFER_DTS (buf));
if (trans->segment.rate > 0) {
runpts = gst_segment_to_running_time (&trans->segment,
GST_FORMAT_TIME, GST_BUFFER_PTS (buf));
rundts = gst_segment_to_running_time (&trans->segment,
GST_FORMAT_TIME, GST_BUFFER_DTS (buf));
} else {
runpts = gst_segment_to_running_time (&trans->segment,
GST_FORMAT_TIME, GST_CLOCK_TIME_IS_VALID (buf->duration)
&& GST_CLOCK_TIME_IS_VALID (buf->pts) ? buf->pts +
buf->duration : buf->pts);
rundts = gst_segment_to_running_time (&trans->segment,
GST_FORMAT_TIME, GST_CLOCK_TIME_IS_VALID (buf->duration)
&& GST_CLOCK_TIME_IS_VALID (buf->dts) ? buf->dts +
buf->duration : buf->dts);
}
}
if (GST_CLOCK_TIME_IS_VALID (rundts))