diff options
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/videohandler.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/gtk/src/videohandler.c b/gtk/src/videohandler.c index e93c34c88..13cbc0e7a 100644 --- a/gtk/src/videohandler.c +++ b/gtk/src/videohandler.c @@ -40,10 +40,10 @@ int ghb_get_video_encoder(GhbValue *settings) return hb_video_encoder_get_from_name(encoder); } -void ghb_set_video_preset(GhbValue *settings, int encoder, const char * preset) +int ghb_set_video_preset(GhbValue *settings, int encoder, const char * preset) { const char * const * videoPresets; - int ii; + int ii, result = 0; videoPresets = hb_video_encoder_get_presets(encoder); for (ii = 0; preset && videoPresets && videoPresets[ii]; ii++) @@ -51,6 +51,7 @@ void ghb_set_video_preset(GhbValue *settings, int encoder, const char * preset) if (!strcasecmp(preset, videoPresets[ii])) { ghb_dict_set_int(settings, "VideoPresetSlider", ii); + result = 1; break; } } @@ -58,6 +59,7 @@ void ghb_set_video_preset(GhbValue *settings, int encoder, const char * preset) { ghb_dict_set_string(settings, "VideoPreset", preset); } + return result; } G_MODULE_EXPORT void @@ -125,14 +127,33 @@ ghb_video_setting_changed(GtkWidget *widget, signal_user_data_t *ud) ghb_widget_to_setting(ud->settings, widget); int encoder = ghb_get_video_encoder(ud->settings); - int presetIndex = ghb_dict_get_int(ud->settings, "VideoPresetSlider"); - const char * const *video_presets; - const char *preset; + const char * const * video_presets; + video_presets = hb_video_encoder_get_presets(encoder); if (video_presets != NULL) { - preset = video_presets[presetIndex]; - ghb_dict_set_string(ud->settings, "VideoPreset", preset); + const char *preset; + + // Try to set same preset value + preset = ghb_dict_get_string(ud->settings, "VideoPreset"); + if (!ghb_set_video_preset(ud->settings, encoder, preset)) + { + int presetIndex, count = 0; + + // Try to set same preset index + presetIndex = ghb_dict_get_int(ud->settings, "VideoPresetSlider"); + while (video_presets[count]) count++; + if (presetIndex < count) + { + preset = video_presets[presetIndex]; + ghb_dict_set_string(ud->settings, "VideoPreset", preset); + } + else + { + // Try to set same preset "medium" preset + ghb_set_video_preset(ud->settings, encoder, "medium"); + } + } } if (!ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions") && |