deinterlace: improve framerate transform
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 12 Sep 2012 11:28:07 +0000 (13:28 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 12 Sep 2012 11:28:07 +0000 (13:28 +0200)
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

gst/deinterlace/gstdeinterlace.c

index adda975..61ea701 100644 (file)
@@ -2071,28 +2071,28 @@ gst_fraction_double (gint * n_out, gint * d_out, gboolean half)
   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;
     }
   }