From 53655cbbc8f0cb49014ac9a5aade7acb76782d01 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Sat, 16 Apr 2011 01:17:13 +0000 Subject: LinGui: Fix PAR overflow issues. 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 | 8 ++++---- gtk/src/hb-backend.c | 24 ++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'gtk') diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 823e66785..586806f3c 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -178,7 +178,7 @@ 1 - 2000 + 4096 0 16 1 @@ -186,7 +186,7 @@ 0 - 1200 + 4096 0 16 1 @@ -210,7 +210,7 @@ 0.0 - 2000 + 65535 1 16 1 @@ -218,7 +218,7 @@ 0 - 2000 + 65535 1 16 1 diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index f453f98d3..2d17a7c32 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -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) { -- cgit v1.2.3