mpeg2: fix GOP timestamps when incorrect data is received.

Some streams have incorrect GOP timestamps, or nothing set at all.
i.e. GOP time is 00:00:00 for all GOPs. Try to recover in this case
from demuxer timestamps, which are monotonic.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
Wind Yuan 2012-03-13 20:33:41 -04:00 committed by Gwenole Beauchesne
parent fc3edde05c
commit baa80d9753

View file

@ -490,6 +490,12 @@ decode_gop(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size)
pts = GST_SECOND * (gop.hour * 3600 + gop.minute * 60 + gop.second);
pts += gst_util_uint64_scale(gop.frame, GST_SECOND * priv->fps_d, priv->fps_n);
if (priv->gop_pts != GST_CLOCK_TIME_NONE && pts <= priv->gop_pts) {
/* Try to fix GOP timestamps, based on demux timestamps */
pts = gst_adapter_prev_timestamp(priv->adapter, NULL);
if (pts != GST_CLOCK_TIME_NONE)
pts -= priv->pts_diff;
}
priv->gop_pts = pts;
if (!priv->pts_diff)
priv->pts_diff = priv->seq_pts - priv->gop_pts;