ext/vorbis/vorbisenc.c: If a buffer arrives with a timestamp before the timestamp+duration of the previous buffer cli...

Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_chain):
If a buffer arrives with a timestamp before the timestamp+duration
of the previous buffer clip it instead of dropping it completely.
Slight improvement for the unfixable bug #548913.
This commit is contained in:
Sebastian Dröge 2008-08-22 07:24:13 +00:00
parent 58584b9b0b
commit aea2a11136
2 changed files with 27 additions and 3 deletions

View file

@ -1,3 +1,10 @@
2008-08-22 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_chain):
If a buffer arrives with a timestamp before the timestamp+duration
of the previous buffer clip it instead of dropping it completely.
Slight improvement for the unfixable bug #548913.
2008-08-21 Sebastian Dröge <sebastian.droege@collabora.co.uk> 2008-08-21 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* ext/vorbis/vorbisdec.c: (vorbis_handle_data_packet): * ext/vorbis/vorbisdec.c: (vorbis_handle_data_packet):

View file

@ -284,6 +284,7 @@ static const GstAudioChannelPosition vorbischannelpositions[][8] = {
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
}, },
}; };
static GstCaps * static GstCaps *
gst_vorbis_enc_generate_sink_caps (void) gst_vorbis_enc_generate_sink_caps (void)
{ {
@ -1161,14 +1162,30 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
if (vorbisenc->expected_ts != GST_CLOCK_TIME_NONE && if (vorbisenc->expected_ts != GST_CLOCK_TIME_NONE &&
GST_BUFFER_TIMESTAMP (buffer) < vorbisenc->expected_ts) { GST_BUFFER_TIMESTAMP (buffer) < vorbisenc->expected_ts) {
guint64 diff = vorbisenc->expected_ts - GST_BUFFER_TIMESTAMP (buffer);
guint64 diff_bytes;
GST_WARNING_OBJECT (vorbisenc, "Buffer is older than previous " GST_WARNING_OBJECT (vorbisenc, "Buffer is older than previous "
"timestamp + duration (%" GST_TIME_FORMAT "< %" GST_TIME_FORMAT "timestamp + duration (%" GST_TIME_FORMAT "< %" GST_TIME_FORMAT
"), cannot handle. Dropping buffer.", "), cannot handle. Clipping buffer.",
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
GST_TIME_ARGS (vorbisenc->expected_ts)); GST_TIME_ARGS (vorbisenc->expected_ts));
diff_bytes =
GST_CLOCK_TIME_TO_FRAMES (diff,
vorbisenc->frequency) * vorbisenc->channels * sizeof (gfloat);
if (diff_bytes >= GST_BUFFER_SIZE (buffer)) {
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
buffer = gst_buffer_make_metadata_writable (buffer);
GST_BUFFER_DATA (buffer) += diff_bytes;
GST_BUFFER_SIZE (buffer) -= diff_bytes;
GST_BUFFER_TIMESTAMP (buffer) += diff;
if (GST_BUFFER_DURATION_IS_VALID (buffer))
GST_BUFFER_DURATION (buffer) -= diff;
}
if (gst_vorbis_enc_buffer_check_discontinuous (vorbisenc, buffer) && !first) { if (gst_vorbis_enc_buffer_check_discontinuous (vorbisenc, buffer) && !first) {
GST_WARNING_OBJECT (vorbisenc, "Buffer is discontinuous, flushing encoder " GST_WARNING_OBJECT (vorbisenc, "Buffer is discontinuous, flushing encoder "