mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 07:28:53 +00:00
ext/vorbis/vorbisdec.c: Use scale functions to avoid overflow when calculating duration of vorbis buffers.
Original commit message from CVS: * ext/vorbis/vorbisdec.c: (vorbis_handle_data_packet): Use scale functions to avoid overflow when calculating duration of vorbis buffers.
This commit is contained in:
parent
a208469078
commit
cda0d2dc94
2 changed files with 11 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2007-04-12 Michael Smith <msmith@fluendo.com>
|
||||||
|
|
||||||
|
* ext/vorbis/vorbisdec.c: (vorbis_handle_data_packet):
|
||||||
|
Use scale functions to avoid overflow when calculating duration of
|
||||||
|
vorbis buffers.
|
||||||
|
|
||||||
2007-04-12 Tim-Philipp Müller <tim at centricular dot net>
|
2007-04-12 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* docs/libs/gst-plugins-base-libs-sections.txt:
|
* docs/libs/gst-plugins-base-libs-sections.txt:
|
||||||
|
|
|
@ -947,7 +947,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;
|
GstClockTime timestamp = -1, nextts;
|
||||||
gint size;
|
gint size;
|
||||||
|
|
||||||
if (!vd->initialized)
|
if (!vd->initialized)
|
||||||
|
@ -1026,11 +1026,13 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet)
|
||||||
GST_BUFFER_OFFSET_END (out) = vd->granulepos + sample_count;
|
GST_BUFFER_OFFSET_END (out) = vd->granulepos + sample_count;
|
||||||
timestamp =
|
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);
|
||||||
|
nextts =
|
||||||
|
gst_util_uint64_scale_int (vd->granulepos + sample_count,
|
||||||
|
GST_SECOND, vd->vi.rate);
|
||||||
GST_DEBUG_OBJECT (vd, "corresponding timestamp %" GST_TIME_FORMAT,
|
GST_DEBUG_OBJECT (vd, "corresponding timestamp %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (timestamp));
|
GST_TIME_ARGS (timestamp));
|
||||||
/* calculate a nano-second accurate duration */
|
/* calculate a nano-second accurate duration */
|
||||||
GST_BUFFER_DURATION (out) = GST_CLOCK_DIFF (timestamp,
|
GST_BUFFER_DURATION (out) = GST_CLOCK_DIFF (timestamp, nextts);
|
||||||
(vd->granulepos + sample_count) * GST_SECOND / vd->vi.rate);
|
|
||||||
GST_DEBUG_OBJECT (vd, "set duration %" GST_TIME_FORMAT,
|
GST_DEBUG_OBJECT (vd, "set duration %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (out)));
|
GST_TIME_ARGS (GST_BUFFER_DURATION (out)));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue