From 44d6ebc48f929cce52b3f187266ee9bf0327340c Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Thu, 22 Oct 2009 08:40:01 -0300 Subject: [PATCH] audiorate: be more accurate on offset math Replace gst_util_uint64_scale_int for its rounding version to improve accuracy and avoid inserting samples where they aren't needed. Fixes #499181 --- gst/audiorate/gstaudiorate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gst/audiorate/gstaudiorate.c b/gst/audiorate/gstaudiorate.c index af3ac71cf8..d3c0bbe6e7 100644 --- a/gst/audiorate/gstaudiorate.c +++ b/gst/audiorate/gstaudiorate.c @@ -175,6 +175,7 @@ gst_audio_rate_base_init (gpointer g_class) gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_audio_rate_src_template)); } + static void gst_audio_rate_class_init (GstAudioRateClass * klass) { @@ -520,14 +521,15 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf) in_samples = in_size / audiorate->bytes_per_sample; /* get duration from the size because we can and it's more accurate */ in_duration = - gst_util_uint64_scale_int (in_samples, GST_SECOND, audiorate->rate); + gst_util_uint64_scale_int_round (in_samples, GST_SECOND, audiorate->rate); in_stop = in_time + in_duration; /* Figure out the total accumulated segment time. */ run_time = in_time + audiorate->src_segment.accum; /* calculate the buffer offset */ - in_offset = gst_util_uint64_scale_int (run_time, audiorate->rate, GST_SECOND); + in_offset = gst_util_uint64_scale_int_round (run_time, audiorate->rate, + GST_SECOND); in_offset_end = in_offset + in_samples; GST_LOG_OBJECT (audiorate,