From efc07f6bb1873704458d3a5f6432dfc1871ec661 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Tue, 26 May 2015 13:28:32 +0200 Subject: [PATCH] mpeg2: fix PTS cache for GOP start. If the GOP temporal sequence number (TSN) is interpolated from a valid PTS, then we need to compensate that PTS corresponding to the start of GOP with the next picture to be decoded, which shall be an I-frame, based on its sequence number. https://bugzilla.gnome.org/show_bug.cgi?id=748676 --- gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c index db11b96fd7..6dc9f0cf92 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c @@ -128,11 +128,16 @@ pts_eval(PTSGenerator *tsg, GstClockTime pic_pts, guint pic_tsn) GstClockTime pts; if (!GST_CLOCK_TIME_IS_VALID(tsg->gop_pts)) - tsg->gop_pts = 0; + tsg->gop_pts = pts_get_duration(tsg, pic_tsn); pts = pic_pts; if (!GST_CLOCK_TIME_IS_VALID (pts)) pts = tsg->gop_pts + pts_get_duration(tsg, tsg->ovl_tsn * 1024 + pic_tsn); + else if (pts == tsg->gop_pts) { + /* The picture following the GOP header shall be an I-frame. + So we can compensate for the GOP start time from here */ + tsg->gop_pts -= pts_get_duration(tsg, pic_tsn); + } if (!GST_CLOCK_TIME_IS_VALID(tsg->max_pts) || tsg->max_pts < pts) tsg->max_pts = pts;