Handle G_MAXINT in the framerates better. If we cannot double or divide the
framerate, clamp to the smallest/largest possible value we can express instead
of failing.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=683861
if (d == 0)
return FALSE;
- if (n == 0 || (n == G_MAXINT && d == 1))
+ if (n == 0)
return TRUE;
gcd = gst_util_greatest_common_divisor (n, d);
n /= gcd;
d /= gcd;
- if (!half) {
- if (G_MAXINT / 2 >= ABS (n)) {
- n *= 2;
- } else if (d >= 2) {
- d /= 2;
- } else {
- return FALSE;
- }
- } else {
+ if (half) {
if (G_MAXINT / 2 >= ABS (d)) {
d *= 2;
- } else if (n >= 2) {
+ } else if (n >= 2 && n != G_MAXINT) {
n /= 2;
} else {
- return FALSE;
+ d = G_MAXINT;
+ }
+ } else {
+ if (G_MAXINT / 2 >= ABS (n)) {
+ n *= 2;
+ } else if (d >= 2 && d != G_MAXINT) {
+ d /= 2;
+ } else {
+ n = G_MAXINT;
}
}