From cda0d2dc94ff177f53f807002480eb8e507f23d4 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Thu, 12 Apr 2007 12:57:33 +0000 Subject: [PATCH] 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. --- ChangeLog | 6 ++++++ ext/vorbis/vorbisdec.c | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e203eb6092..569faffe6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-04-12 Michael Smith + + * 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 * docs/libs/gst-plugins-base-libs-sections.txt: diff --git a/ext/vorbis/vorbisdec.c b/ext/vorbis/vorbisdec.c index 58c3fd90ab..35a84f2c3c 100644 --- a/ext/vorbis/vorbisdec.c +++ b/ext/vorbis/vorbisdec.c @@ -947,7 +947,7 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet) guint sample_count; GstBuffer *out; GstFlowReturn result; - GstClockTime timestamp = -1; + GstClockTime timestamp = -1, nextts; gint size; 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; timestamp = 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_TIME_ARGS (timestamp)); /* calculate a nano-second accurate duration */ - GST_BUFFER_DURATION (out) = GST_CLOCK_DIFF (timestamp, - (vd->granulepos + sample_count) * GST_SECOND / vd->vi.rate); + GST_BUFFER_DURATION (out) = GST_CLOCK_DIFF (timestamp, nextts); GST_DEBUG_OBJECT (vd, "set duration %" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DURATION (out))); } else {