From 66087b62766d0fb1362baab494930144d5985305 Mon Sep 17 00:00:00 2001 From: "Ma, Mingyang" Date: Tue, 22 Nov 2022 17:01:37 +0800 Subject: [PATCH] msdkdec: Update decoding pts Update frame pts before calling gst_video_decoder_finish_frame, or frames may be lost when transcoding in specific stream Part-of: --- subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c index ba9c444c21..bc7fb52884 100644 --- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c +++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c @@ -58,6 +58,9 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", #define GST_TO_MFX_TIME(time) ((time) == GST_CLOCK_TIME_NONE ? \ MFX_TIMESTAMP_UNKNOWN : gst_util_uint64_scale_round ((time), 9, 100000)) +#define MFX_TO_GST_TIME(time) ((time) == MFX_TIMESTAMP_UNKNOWN ? \ + GST_CLOCK_TIME_NONE : gst_util_uint64_scale_round ((time), 100000, 9)) + #define MFX_TIME_IS_VALID(time) ((time) != MFX_TIMESTAMP_UNKNOWN) #define gst_msdkdec_parent_class parent_class @@ -944,6 +947,8 @@ gst_msdkdec_finish_task (GstMsdkDec * thiz, MsdkDecTask * task) if (decode_only) GST_VIDEO_CODEC_FRAME_SET_DECODE_ONLY (frame); + + frame->pts = MFX_TO_GST_TIME (pts); flow = gst_video_decoder_finish_frame (decoder, frame); if (flow == GST_FLOW_ERROR) GST_ERROR_OBJECT (thiz, "Failed to finish frame");