]> granicus.if.org Git - handbrake/commitdiff
LinGui: Fix PAR overflow issues.
authorjstebbins <jstebbins.hb@gmail.com>
Sat, 16 Apr 2011 01:17:13 +0000 (01:17 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Sat, 16 Apr 2011 01:17:13 +0000 (01:17 +0000)
PAR values were saturating the max values allowed in PAR widget controls.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3932 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/ghb.ui
gtk/src/hb-backend.c

index 823e66785eb189323114d9c8380d577cd9da3108..586806f3c25a50f170053e73e42a6036ebbc6562 100644 (file)
     <property name="value">1</property>
   </object>
   <object class="GtkAdjustment" id="adjustment25">
-    <property name="upper">2000</property>
+    <property name="upper">4096</property>
     <property name="lower">0</property>
     <property name="page_increment">16</property>
     <property name="step_increment">1</property>
     <property name="value">0</property>
   </object>
   <object class="GtkAdjustment" id="adjustment26">
-    <property name="upper">1200</property>
+    <property name="upper">4096</property>
     <property name="lower">0</property>
     <property name="page_increment">16</property>
     <property name="step_increment">1</property>
     <property name="value">0.0</property>
   </object>
   <object class="GtkAdjustment" id="adjustment29">
-    <property name="upper">2000</property>
+    <property name="upper">65535</property>
     <property name="lower">1</property>
     <property name="page_increment">16</property>
     <property name="step_increment">1</property>
     <property name="value">0</property>
   </object>
   <object class="GtkAdjustment" id="adjustment30">
-    <property name="upper">2000</property>
+    <property name="upper">65535</property>
     <property name="lower">1</property>
     <property name="page_increment">16</property>
     <property name="step_increment">1</property>
index f453f98d3f14688ec48cfc0cf03556fc95cb6df2..2d17a7c32a9913f110cc48707d9870b80624481d 100644 (file)
@@ -3517,6 +3517,26 @@ picture_settings_deps(signal_user_data_t *ud)
        gtk_widget_set_sensitive(widget, pic_par != 1);
 }
 
+void
+ghb_limit_rational( gint *num, gint *den, gint limit )
+{
+    if (*num < limit && *den < limit)
+        return;
+
+    if (*num > *den)
+    {
+        gdouble factor = (double)limit / *num;
+        *num = limit;
+        *den = factor * *den;
+    }
+    else
+    {
+        gdouble factor = (double)limit / *den;
+        *den = limit;
+        *num = factor * *num;
+    }
+}
+
 void
 ghb_set_scale(signal_user_data_t *ud, gint mode)
 {
@@ -3795,9 +3815,9 @@ ghb_set_scale(signal_user_data_t *ud, gint mode)
        gint disp_width, dar_width, dar_height;
        gchar *str;
 
-       disp_width = (gdouble)(width * par_width / par_height) + 0.5;
+       disp_width = ((gdouble)par_width / par_height) * width + 0.5;
        hb_reduce(&dar_width, &dar_height, disp_width, height);
-               
+    ghb_limit_rational(&par_width, &par_height, 65535);
        gint iaspect = dar_width * 9 / dar_height;
        if (dar_width > 2 * dar_height)
        {