mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
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.
This commit is contained in:
parent
29c31ba645
commit
f4949f91d5
2 changed files with 23 additions and 6 deletions
|
@ -1,3 +1,10 @@
|
|||
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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue