mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-27 08:26:39 +00:00
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.
This commit is contained in:
parent
203c27b42b
commit
3cfec4de73
1 changed files with 11 additions and 5 deletions
|
@ -439,11 +439,17 @@ gst_rtsp_range_free (GstRTSPTimeRange * range)
|
||||||
static GstClockTime
|
static GstClockTime
|
||||||
get_seconds (const GstRTSPTime * t)
|
get_seconds (const GstRTSPTime * t)
|
||||||
{
|
{
|
||||||
|
if (t->seconds < G_MAXINT) {
|
||||||
gint num, denom;
|
gint num, denom;
|
||||||
/* don't do direct multiply with GST_SECOND to avoid rounding
|
/* Don't do direct multiply with GST_SECOND to avoid rounding
|
||||||
* errors */
|
* errors.
|
||||||
|
* This only works for "small" numbers, because num is limited to 32-bit
|
||||||
|
*/
|
||||||
gst_util_double_to_fraction (t->seconds, &num, &denom);
|
gst_util_double_to_fraction (t->seconds, &num, &denom);
|
||||||
return gst_util_uint64_scale_int (GST_SECOND, num, denom);
|
return gst_util_uint64_scale_int (GST_SECOND, num, denom);
|
||||||
|
} else {
|
||||||
|
return t->seconds * GST_SECOND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstClockTime
|
static GstClockTime
|
||||||
|
|
Loading…
Reference in a new issue