From ada8b07be20351d509f6bac71dbe2fc6154ce9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Mon, 19 Apr 2021 13:28:39 +0200 Subject: [PATCH] videodecoder: use DTS if PTS unknown The buffer should be set according to DTS if exists when we are guessin the PTS instead of segment start. The decoder can receive buffers which are before the segment in case of seek for example. Part-of: --- gst-libs/gst/video/gstvideodecoder.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index d0e89829f..5df6f9ca7 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -2950,11 +2950,17 @@ gst_video_decoder_prepare_finish_frame (GstVideoDecoder * if (frame->duration != GST_CLOCK_TIME_NONE) { if (GST_CLOCK_TIME_IS_VALID (priv->last_timestamp_out)) frame->pts = priv->last_timestamp_out + frame->duration; - else if (decoder->output_segment.rate > 0.0) + else if (frame->dts != GST_CLOCK_TIME_NONE) { + frame->pts = frame->dts; + GST_LOG_OBJECT (decoder, + "Setting DTS as PTS %" GST_TIME_FORMAT " for frame...", + GST_TIME_ARGS (frame->pts)); + } else if (decoder->output_segment.rate > 0.0) frame->pts = decoder->output_segment.start; - GST_LOG_OBJECT (decoder, - "Guessing timestamp %" GST_TIME_FORMAT " for frame...", - GST_TIME_ARGS (frame->pts)); + GST_INFO_OBJECT (decoder, + "Guessing PTS=%" GST_TIME_FORMAT " for frame... DTS=%" + GST_TIME_FORMAT, GST_TIME_ARGS (frame->pts), + GST_TIME_ARGS (frame->dts)); } else if (sync && frame->dts != GST_CLOCK_TIME_NONE) { frame->pts = frame->dts; GST_LOG_OBJECT (decoder,