summaryrefslogtreecommitdiffstats
path: root/gtk/src/hb-backend.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-02-21 00:23:37 +0000
committerjstebbins <[email protected]>2014-02-21 00:23:37 +0000
commitd206a74fb8500b64310b75be8db08ec9e0a972f5 (patch)
tree15941705a5f17d83f29e2b28fc1d548fe5aab9e3 /gtk/src/hb-backend.c
parentcc82c19b2f52a7527615ccbae34154e0085b6708 (diff)
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
Diffstat (limited to 'gtk/src/hb-backend.c')
-rw-r--r--gtk/src/hb-backend.c89
1 files changed, 46 insertions, 43 deletions
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