videotestsrc: Fix buffer duration in reverse playback

In reverse playback, buffers have to be displayed at buffer.stop running
time, meaning:

    buffer.pts + buffer.duration = prev_buffer.pts
    =>
    buffer.duration = prev_buffer.pts - buffer.pts

We were setting buffer.duration = next_buffer.pts - buffer.pts which
is not correct.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/646>
This commit is contained in:
Thibault Saunier 2020-04-23 20:35:39 -04:00 committed by GStreamer Merge Bot
parent a0258e3e6b
commit 9ce93abb29

View file

@ -1179,7 +1179,11 @@ gst_video_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer)
next_time = gst_util_uint64_scale (src->n_frames,
src->info.fps_d * GST_SECOND, src->info.fps_n);
if (src->reverse) {
GST_BUFFER_DURATION (buffer) = src->running_time - next_time;
/* We already decremented to next frame */
GstClockTime prev_pts = gst_util_uint64_scale (src->n_frames + 2,
src->info.fps_d * GST_SECOND, src->info.fps_n);
GST_BUFFER_DURATION (buffer) = prev_pts - GST_BUFFER_PTS (buffer);
} else {
GST_BUFFER_DURATION (buffer) = next_time - src->running_time;
}