From 7b107f64f33108658f2883d74de3303c07f3a154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branko=20=C4=8Cibej?= Date: Thu, 17 Dec 2009 17:37:03 +0100 Subject: [PATCH] rganalysis: fix timestamp rounding Use scaling function to round and avoid overflows. Fixes #604352 --- gst/replaygain/rganalysis.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gst/replaygain/rganalysis.c b/gst/replaygain/rganalysis.c index 9787c6884e..25535363ec 100644 --- a/gst/replaygain/rganalysis.c +++ b/gst/replaygain/rganalysis.c @@ -710,9 +710,11 @@ rg_analysis_analyze (RgAnalysisCtx * ctx, const gfloat * samples_l, (gint) G_N_ELEMENTS (ctx->track.histogram) - 1); /* Compute the per-window gain */ const gdouble gain = PINK_REF - (gdouble) ival / STEPS_PER_DB; - const GstClockTime timestamp = (ctx->buffer_timestamp - + ctx->buffer_n_samples_done * GST_SECOND / ctx->sample_rate - - RMS_WINDOW_MSECS * GST_MSECOND); + const GstClockTime timestamp = ctx->buffer_timestamp + + gst_util_uint64_scale_int_ceil (GST_SECOND, + ctx->buffer_n_samples_done, + ctx->sample_rate) + - RMS_WINDOW_MSECS * GST_MSECOND; ctx->post_message (ctx->analysis, timestamp, RMS_WINDOW_MSECS * GST_MSECOND, -gain);