Commit f4949f91 authored by Ronald S. Bultje's avatar Ronald S. Bultje

ext/ffmpeg/gstffmpegdec.c: Update timestamp for every new buffer that we...

ext/ffmpeg/gstffmpegdec.c: Update timestamp for every new buffer that we output. Improves audio playback for several ...

Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_chain):
Update timestamp for every new buffer that we output. Improves
audio playback for several files that have multiple audio chunks
per buffer.
parent 29c31ba6
2004-09-23 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_chain):
Update timestamp for every new buffer that we output. Improves
audio playback for several files that have multiple audio chunks
per buffer.
2004-09-22 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_register):
......
......@@ -368,6 +368,7 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data)
guchar *data;
gint size, len = 0;
gint have_data;
guint64 expected_ts = GST_BUFFER_TIMESTAMP (inbuf);
if (!ffmpegdec->opened) {
GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
......@@ -443,8 +444,14 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data)
}
}
/* this isn't necessarily true, but it's better than nothing */
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
/* note that ffmpeg sometimes gets the FPS wrong */
if (GST_CLOCK_TIME_IS_VALID (expected_ts)) {
GST_BUFFER_TIMESTAMP (outbuf) = expected_ts;
GST_BUFFER_DURATION (outbuf) = GST_SECOND *
ffmpegdec->context->frame_rate_base /
ffmpegdec->context->frame_rate;
expected_ts += GST_BUFFER_DURATION (outbuf);
}
}
break;
......@@ -462,8 +469,13 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data)
if (have_data) {
GST_BUFFER_SIZE (outbuf) = have_data;
GST_BUFFER_DURATION (outbuf) = (have_data * GST_SECOND) /
(ffmpegdec->context->channels * ffmpegdec->context->sample_rate);
if (GST_CLOCK_TIME_IS_VALID (expected_ts)) {
GST_BUFFER_TIMESTAMP (outbuf) = expected_ts;
GST_BUFFER_DURATION (outbuf) = (have_data * GST_SECOND) /
(2 * ffmpegdec->context->channels *
ffmpegdec->context->sample_rate);
expected_ts += GST_BUFFER_DURATION (outbuf);
}
} else {
gst_buffer_unref (outbuf);
}
......@@ -511,8 +523,6 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data)
gst_caps_free (caps);
}
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
gst_pad_push (ffmpegdec->srcpad, GST_DATA (outbuf));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment