ffmpeg: properly integrate timestamp handling

The patch from Bug #580796 hacked around existing infrastructure to handle
timestamps as DTS (as in all AVI files) causing the logic to be disabled.

Properly hook the timestamp handling into the existing infrastructure to handle
these cases too, partially reverting a26b94d92c
and moving some stuff around.

Refixes #580796.
This commit is contained in:
Wim Taymans 2009-06-05 12:32:25 +02:00
parent 5917098edf
commit 686aadaf01

View file

@ -1587,10 +1587,6 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
ffmpegdec->picture, &have_data, data, size); ffmpegdec->picture, &have_data, data, size);
gst_ts_handler_consume (ffmpegdec, len); gst_ts_handler_consume (ffmpegdec, len);
if (have_data) {
/* recuperate the reordered timestamp */
in_timestamp = ffmpegdec->picture->reordered_opaque;
}
/* restore previous state */ /* restore previous state */
if (!decode) if (!decode)
@ -1608,10 +1604,12 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
if (len < 0 || have_data <= 0) if (len < 0 || have_data <= 0)
goto beach; goto beach;
/* get pts */ /* recuperate the reordered timestamp */
out_pts = ffmpegdec->picture->pts; out_pts = ffmpegdec->picture->reordered_opaque;
GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %" G_GUINT64_FORMAT, out_pts); GST_DEBUG_OBJECT (ffmpegdec, "ts-handler: pts %" G_GUINT64_FORMAT, out_pts);
GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %" G_GUINT64_FORMAT,
ffmpegdec->picture->pts);
GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d", GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d",
ffmpegdec->picture->coded_picture_number); ffmpegdec->picture->coded_picture_number);
GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d", GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d",
@ -1694,20 +1692,22 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
* 3) else copy input timestamp * 3) else copy input timestamp
*/ */
out_timestamp = -1; out_timestamp = -1;
if (GST_CLOCK_TIME_IS_VALID (in_timestamp)) { if (out_pts != -1) {
out_timestamp = in_timestamp;
GST_LOG_OBJECT (ffmpegdec, "using in timestamp %" GST_TIME_FORMAT,
GST_TIME_ARGS (out_timestamp));
} else if (GST_CLOCK_TIME_IS_VALID (ffmpegdec->next_ts)) {
out_timestamp = ffmpegdec->next_ts;
GST_LOG_OBJECT (ffmpegdec, "using next timestamp %" GST_TIME_FORMAT,
GST_TIME_ARGS (out_timestamp));
} else if (out_pts != -1) {
/* Get (interpolated) timestamp from FFMPEG */ /* Get (interpolated) timestamp from FFMPEG */
out_timestamp = (GstClockTime) out_pts; out_timestamp = (GstClockTime) out_pts;
GST_LOG_OBJECT (ffmpegdec, "using timestamp %" GST_TIME_FORMAT GST_LOG_OBJECT (ffmpegdec, "using timestamp %" GST_TIME_FORMAT
" returned by ffmpeg", GST_TIME_ARGS (out_timestamp)); " returned by ffmpeg", GST_TIME_ARGS (out_timestamp));
} }
if (!GST_CLOCK_TIME_IS_VALID (out_timestamp) && ffmpegdec->next_ts != -1) {
out_timestamp = ffmpegdec->next_ts;
GST_LOG_OBJECT (ffmpegdec, "using next timestamp %" GST_TIME_FORMAT,
GST_TIME_ARGS (out_timestamp));
}
if (!GST_CLOCK_TIME_IS_VALID (out_timestamp)) {
out_timestamp = in_timestamp;
GST_LOG_OBJECT (ffmpegdec, "using in timestamp %" GST_TIME_FORMAT,
GST_TIME_ARGS (out_timestamp));
}
GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp; GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
/* /*
@ -1768,8 +1768,6 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
if (out_timestamp != -1 && out_duration != -1) if (out_timestamp != -1 && out_duration != -1)
ffmpegdec->next_ts = out_timestamp + out_duration; ffmpegdec->next_ts = out_timestamp + out_duration;
else
ffmpegdec->next_ts = GST_CLOCK_TIME_NONE;
/* palette is not part of raw video frame in gst and the size /* palette is not part of raw video frame in gst and the size
* of the outgoing buffer needs to be adjusted accordingly */ * of the outgoing buffer needs to be adjusted accordingly */