From 3cfec4de73be0825410498f9538552cd5a2ffc0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Fri, 22 Feb 2013 13:20:21 -0500 Subject: [PATCH] rtsprange: Avoid going through fractions for large numbers If the number of seconds exceeds 2^31, then it will be truncated if the conversion is done using fractions, so multiply it directly. --- gst-libs/gst/rtsp/gstrtsprange.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gst-libs/gst/rtsp/gstrtsprange.c b/gst-libs/gst/rtsp/gstrtsprange.c index f19e7a9213..94f3c016fd 100644 --- a/gst-libs/gst/rtsp/gstrtsprange.c +++ b/gst-libs/gst/rtsp/gstrtsprange.c @@ -439,11 +439,17 @@ gst_rtsp_range_free (GstRTSPTimeRange * range) static GstClockTime get_seconds (const GstRTSPTime * t) { - gint num, denom; - /* don't do direct multiply with GST_SECOND to avoid rounding - * errors */ - gst_util_double_to_fraction (t->seconds, &num, &denom); - return gst_util_uint64_scale_int (GST_SECOND, num, denom); + if (t->seconds < G_MAXINT) { + gint num, denom; + /* Don't do direct multiply with GST_SECOND to avoid rounding + * errors. + * This only works for "small" numbers, because num is limited to 32-bit + */ + gst_util_double_to_fraction (t->seconds, &num, &denom); + return gst_util_uint64_scale_int (GST_SECOND, num, denom); + } else { + return t->seconds * GST_SECOND; + } } static GstClockTime