From d206a74fb8500b64310b75be8db08ec9e0a972f5 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Fri, 21 Feb 2014 00:23:37 +0000 Subject: LinGui: fix range update issues and plug memory leaks Updating the range of GtkScale and GtkSpinButtons causes the current value to update inappropriately under some conditions. So update the range and value concurrently. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6051 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- gtk/src/hb-backend.c | 89 +++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 43 deletions(-) (limited to 'gtk/src/hb-backend.c') diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 5dff6898d..ae09f6dc4 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -696,59 +696,62 @@ ghb_version() return hb_get_version(NULL); } +float +ghb_vquality_default(signal_user_data_t *ud) +{ + float quality; + gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder"); + + switch (vcodec) + { + case HB_VCODEC_X264: + return 20; + case HB_VCODEC_THEORA: + return 45; + case HB_VCODEC_FFMPEG_MPEG2: + case HB_VCODEC_FFMPEG_MPEG4: + return 3; + default: + { + float min, max, step; + int direction; + + hb_video_quality_get_limits(vcodec, &min, &max, &step, &direction); + // Pick something that is 70% of max + // Probably too low for some and too high for others... + quality = (max - min) * 0.7; + if (direction) + quality = max - quality; + } + } + return quality; +} + void ghb_vquality_range( signal_user_data_t *ud, - gdouble *min, - gdouble *max, - gdouble *step, - gdouble *page, + float *min, + float *max, + float *step, + float *page, gint *digits, - gboolean *inverted) + int *direction) { + float min_step; gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder"); + *page = 10; *digits = 0; - switch (vcodec) - { - case HB_VCODEC_X264: - { - *min = 0; - *max = 51; - *step = ghb_settings_combo_double(ud->prefs, - "VideoQualityGranularity"); - if (*step == 0.2 || *step == 0.5) - *digits = 1; - else if (*step == 0.25) - *digits = 2; - *inverted = TRUE; - } break; - - case HB_VCODEC_FFMPEG_MPEG2: - case HB_VCODEC_FFMPEG_MPEG4: - { - *min = 1; - *max = 31; - *step = 1; - *inverted = TRUE; - } break; + hb_video_quality_get_limits(vcodec, min, max, &min_step, direction); + *step = ghb_settings_combo_double(ud->prefs, "VideoQualityGranularity"); - case HB_VCODEC_THEORA: - { - *min = 0; - *max = 63; - *step = 1; - *inverted = FALSE; - } break; + if (*step < min_step) + *step = min_step; - default: - { - *min = 0; - *max = 100; - *step = 1; - *inverted = FALSE; - } break; - } + if ((int)(*step * 100) % 10 != 0) + *digits = 2; + else if ((int)(*step * 10) % 10 != 0) + *digits = 1; } gint -- cgit v1.2.3