mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-03 04:52:28 +00:00
ext/vorbis/vorbisdec.c: Small cleanups.
Original commit message from CVS: * ext/vorbis/vorbisdec.c: (vorbis_dec_push_forward), (vorbis_handle_data_packet), (vorbis_dec_decode_buffer), (vorbis_dec_flush_decode): Small cleanups. Don't try to add invalid timestamps. Clipping will unref the buffer.
This commit is contained in:
parent
fae581d596
commit
22411eeb35
2 changed files with 22 additions and 6 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2006-11-24 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* ext/vorbis/vorbisdec.c: (vorbis_dec_push_forward),
|
||||||
|
(vorbis_handle_data_packet), (vorbis_dec_decode_buffer),
|
||||||
|
(vorbis_dec_flush_decode):
|
||||||
|
Small cleanups.
|
||||||
|
Don't try to add invalid timestamps.
|
||||||
|
Clipping will unref the buffer.
|
||||||
|
|
||||||
2006-11-24 Stefan Kost <ensonic@users.sf.net>
|
2006-11-24 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
* gst/adder/gstadder.h:
|
* gst/adder/gstadder.h:
|
||||||
|
|
|
@ -914,6 +914,7 @@ vorbis_dec_push_forward (GstVorbisDec * dec, GstBuffer * buf)
|
||||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
|
||||||
dec->discont = FALSE;
|
dec->discont = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = gst_pad_push (dec->srcpad, buf);
|
result = gst_pad_push (dec->srcpad, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -937,6 +938,7 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet)
|
||||||
guint sample_count;
|
guint sample_count;
|
||||||
GstBuffer *out;
|
GstBuffer *out;
|
||||||
GstFlowReturn result;
|
GstFlowReturn result;
|
||||||
|
GstClockTime timestamp = -1;
|
||||||
gint size;
|
gint size;
|
||||||
|
|
||||||
if (!vd->initialized)
|
if (!vd->initialized)
|
||||||
|
@ -991,9 +993,12 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet)
|
||||||
/* this should not overflow */
|
/* this should not overflow */
|
||||||
GST_BUFFER_DURATION (out) = sample_count * GST_SECOND / vd->vi.rate;
|
GST_BUFFER_DURATION (out) = sample_count * GST_SECOND / vd->vi.rate;
|
||||||
|
|
||||||
|
if (packet->granulepos != -1)
|
||||||
|
vd->granulepos = packet->granulepos - sample_count;
|
||||||
|
|
||||||
if (vd->cur_timestamp != GST_CLOCK_TIME_NONE) {
|
if (vd->cur_timestamp != GST_CLOCK_TIME_NONE) {
|
||||||
/* we have incomming timestamps */
|
/* we have incomming timestamps */
|
||||||
GST_BUFFER_TIMESTAMP (out) = vd->cur_timestamp;
|
timestamp = vd->cur_timestamp;
|
||||||
GST_DEBUG_OBJECT (vd,
|
GST_DEBUG_OBJECT (vd,
|
||||||
"cur_timestamp: %" GST_TIME_FORMAT " + %" GST_TIME_FORMAT " = %"
|
"cur_timestamp: %" GST_TIME_FORMAT " + %" GST_TIME_FORMAT " = %"
|
||||||
GST_TIME_FORMAT, GST_TIME_ARGS (vd->cur_timestamp),
|
GST_TIME_FORMAT, GST_TIME_ARGS (vd->cur_timestamp),
|
||||||
|
@ -1008,12 +1013,13 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet)
|
||||||
GST_BUFFER_OFFSET (out) = vd->granulepos;
|
GST_BUFFER_OFFSET (out) = vd->granulepos;
|
||||||
if (vd->granulepos != -1) {
|
if (vd->granulepos != -1) {
|
||||||
GST_BUFFER_OFFSET_END (out) = vd->granulepos + sample_count;
|
GST_BUFFER_OFFSET_END (out) = vd->granulepos + sample_count;
|
||||||
GST_BUFFER_TIMESTAMP (out) =
|
timestamp =
|
||||||
gst_util_uint64_scale_int (vd->granulepos, GST_SECOND, vd->vi.rate);
|
gst_util_uint64_scale_int (vd->granulepos, GST_SECOND, vd->vi.rate);
|
||||||
} else {
|
} else {
|
||||||
GST_BUFFER_TIMESTAMP (out) = -1;
|
timestamp = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GST_BUFFER_TIMESTAMP (out) = timestamp;
|
||||||
|
|
||||||
if (vd->granulepos != -1)
|
if (vd->granulepos != -1)
|
||||||
vd->granulepos += sample_count;
|
vd->granulepos += sample_count;
|
||||||
|
@ -1026,6 +1032,10 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet)
|
||||||
done:
|
done:
|
||||||
vorbis_synthesis_read (&vd->vd, sample_count);
|
vorbis_synthesis_read (&vd->vd, sample_count);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (vd,
|
||||||
|
"decoded %d bytes into %d samples, ts %" GST_TIME_FORMAT, packet->bytes,
|
||||||
|
sample_count, GST_TIME_ARGS (timestamp));
|
||||||
|
|
||||||
/* granulepos is the last sample in the packet */
|
/* granulepos is the last sample in the packet */
|
||||||
if (packet->granulepos != -1)
|
if (packet->granulepos != -1)
|
||||||
vd->granulepos = packet->granulepos;
|
vd->granulepos = packet->granulepos;
|
||||||
|
@ -1114,8 +1124,6 @@ vorbis_dec_decode_buffer (GstVorbisDec * vd, GstBuffer * buffer, gboolean eos)
|
||||||
result = vorbis_handle_data_packet (vd, &packet);
|
result = vorbis_handle_data_packet (vd, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (vd, "offset end: %" G_GUINT64_FORMAT, offset_end);
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -1255,7 +1263,6 @@ vorbis_dec_flush_decode (GstVorbisDec * dec)
|
||||||
/* clip, this will unref the buffer in case of clipping */
|
/* clip, this will unref the buffer in case of clipping */
|
||||||
if (vorbis_do_clip (dec, buf)) {
|
if (vorbis_do_clip (dec, buf)) {
|
||||||
GST_DEBUG_OBJECT (dec, "clipped buffer %p", buf);
|
GST_DEBUG_OBJECT (dec, "clipped buffer %p", buf);
|
||||||
gst_buffer_unref (buf);
|
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue