diff options
-rw-r--r-- | gtk/src/audiohandler.c | 20 | ||||
-rw-r--r-- | gtk/src/callbacks.c | 25 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 187 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 8 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 1 | ||||
-rw-r--r-- | gtk/src/internal_defaults.xml | 79 | ||||
-rw-r--r-- | gtk/src/main.c | 32 | ||||
-rw-r--r-- | gtk/src/makedeps.py | 2 | ||||
-rw-r--r-- | gtk/src/presets.c | 957 | ||||
-rw-r--r-- | gtk/src/presets.h | 1 | ||||
-rw-r--r-- | gtk/src/preview.c | 3 | ||||
-rw-r--r-- | gtk/src/resources.c | 6 | ||||
-rw-r--r-- | gtk/src/resources.h | 1 | ||||
-rw-r--r-- | gtk/src/settings.h | 1 | ||||
-rw-r--r-- | gtk/src/standard_presets.xml | 2 | ||||
-rw-r--r-- | gtk/src/x264handler.c | 121 | ||||
-rw-r--r-- | gtk/src/x264handler.h | 1 |
17 files changed, 495 insertions, 952 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index eeeabd904..6c00e3c72 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -94,9 +94,7 @@ static void audio_deps(signal_user_data_t *ud, GValue *asettings, GtkWidget *wid gtk_widget_set_sensitive(widget, !is_passthru); widget = GHB_WIDGET(ud->builder, "AudioSamplerate"); gtk_widget_set_sensitive(widget, !is_passthru); - widget = GHB_WIDGET(ud->builder, "AudioTrackGain"); - gtk_widget_set_sensitive(widget, !is_passthru); - widget = GHB_WIDGET(ud->builder, "AudioTrackGain"); + widget = GHB_WIDGET(ud->builder, "AudioTrackGainSlider"); gtk_widget_set_sensitive(widget, !is_passthru); widget = GHB_WIDGET(ud->builder, "AudioTrackGainValue"); gtk_widget_set_sensitive(widget, !is_passthru); @@ -379,8 +377,8 @@ audio_update_dialog_widgets(signal_user_data_t *ud, GValue *asettings) ghb_settings_get_value(asettings, "AudioMixdown")); ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_settings_get_value(asettings, "AudioTrackDRCSlider")); - ghb_ui_update(ud, "AudioTrackGain", - ghb_settings_get_value(asettings, "AudioTrackGain")); + ghb_ui_update(ud, "AudioTrackGainSlider", + ghb_settings_get_value(asettings, "AudioTrackGainSlider")); ghb_ui_update(ud, "AudioTrackQuality", ghb_settings_get_value(asettings, "AudioTrackQuality")); ghb_ui_update(ud, "AudioTrackQualityEnable", @@ -477,7 +475,7 @@ audio_add_track( ghb_settings_set_double(asettings, "AudioTrackDRCSlider", drc); - ghb_settings_set_double(asettings, "AudioTrackGain", gain); + ghb_settings_set_double(asettings, "AudioTrackGainSlider", gain); audio_sanitize_settings(settings, asettings); audio_add_to_settings(settings, asettings); @@ -514,7 +512,7 @@ audio_select_and_add_track( samplerate = ghb_settings_combo_int(audio, "AudioSamplerate"); mix = ghb_settings_combo_int(audio, "AudioMixdown"); drc = ghb_settings_get_double(audio, "AudioTrackDRCSlider"); - gain = ghb_settings_get_double(audio, "AudioTrackGain"); + gain = ghb_settings_get_double(audio, "AudioTrackGainSlider"); enable_quality = ghb_settings_get_boolean(audio, "AudioTrackQualityEnable"); quality = ghb_settings_get_double(audio, "AudioTrackQuality"); @@ -577,7 +575,7 @@ static void set_pref_audio_with_lang( samplerate = ghb_settings_combo_int(audio, "AudioSamplerate"); mix = ghb_settings_combo_int(audio, "AudioMixdown"); drc = ghb_settings_get_double(audio, "AudioTrackDRCSlider"); - gain = ghb_settings_get_double(audio, "AudioTrackGain"); + gain = ghb_settings_get_double(audio, "AudioTrackGainSlider"); enable_quality = ghb_settings_get_boolean(audio, "AudioTrackQualityEnable"); quality = ghb_settings_get_double(audio, "AudioTrackQuality"); @@ -770,7 +768,7 @@ audio_refresh_list_row_ui( s_sr = g_strdup_printf("%.4gkHz", (double)sr/1000); s_mix = ghb_settings_combo_option(settings, "AudioMixdown"); - gain = ghb_settings_get_double(settings, "AudioTrackGain"); + gain = ghb_settings_get_double(settings, "AudioTrackGainSlider"); s_gain = g_strdup_printf("%ddB", (int)gain); drc = ghb_settings_get_double(settings, "AudioTrackDRCSlider"); @@ -1672,7 +1670,7 @@ audio_def_settings_init_row(GValue *adict, GtkWidget *row) ghb_widget_to_setting(adict, widget); widget = find_widget(row, "AudioSamplerate"); ghb_widget_to_setting(adict, widget); - widget = find_widget(row, "AudioTrackGain"); + widget = find_widget(row, "AudioTrackGainSlider"); ghb_widget_to_setting(adict, widget); widget = find_widget(row, "AudioTrackDRCSlider"); ghb_widget_to_setting(adict, widget); @@ -1856,7 +1854,7 @@ GtkWidget * ghb_create_audio_settings_row(signal_user_data_t *ud) "Adjust the amplification or attenuation of the output audio track."); gtk_widget_set_valign(GTK_WIDGET(scale), GTK_ALIGN_CENTER); - gtk_widget_set_name(GTK_WIDGET(scale), "AudioTrackGain"); + gtk_widget_set_name(GTK_WIDGET(scale), "AudioTrackGainSlider"); gtk_widget_show(GTK_WIDGET(scale)); g_signal_connect(scale, "value-changed", (GCallback)audio_def_gain_changed_cb, ud); gtk_box_pack_start(box3, GTK_WIDGET(scale), FALSE, FALSE, 0); diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 60f95ba19..597faec33 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -1079,6 +1079,8 @@ ghb_load_settings(signal_user_data_t * ud) ud->dont_clear_presets = FALSE; ud->scale_busy = FALSE; busy = FALSE; + + ghb_picture_settings_deps(ud); } static void @@ -2135,6 +2137,7 @@ scale_height_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_clear_presets_selection(ud); if (gtk_widget_is_sensitive(widget)) ghb_set_scale(ud, GHB_PIC_KEEP_HEIGHT); + update_preview = TRUE; ghb_live_reset(ud); @@ -2222,7 +2225,7 @@ show_crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_live_reset(ud); if (gtk_widget_is_sensitive(widget)) ghb_set_scale(ud, 0); - ghb_pref_save (ud->prefs, "preview_show_crop"); + ghb_pref_save(ud->prefs, "preview_show_crop"); update_preview = TRUE; } @@ -2252,6 +2255,7 @@ prefs_dialog_cb(GtkWidget *xwidget, signal_user_data_t *ud) dialog = GHB_WIDGET(ud->builder, "prefs_dialog"); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_hide(dialog); + ghb_prefs_store(); } typedef struct @@ -3264,7 +3268,7 @@ ghb_timer_cb(gpointer data) if (strcmp(dest_dir, def_dest) != 0) { ghb_settings_set_string (ud->prefs, "destination_dir", dest_dir); - ghb_pref_save (ud->prefs, "destination_dir"); + ghb_pref_save(ud->prefs, "destination_dir"); } g_free(dest); g_free(dest_dir); @@ -3835,19 +3839,18 @@ advanced_video_changed_cb(GtkWidget *widget, signal_user_data_t *ud) g_debug("advanced_video_changed_cb"); ghb_widget_to_setting(ud->prefs, widget); const gchar *name = ghb_get_setting_key(widget); - ghb_pref_save(ud->prefs, name); + ghb_pref_set(ud->prefs, name); ghb_show_hide_advanced_video(ud); } G_MODULE_EXPORT void pref_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - g_debug("pref_changed_cb"); ghb_widget_to_setting (ud->prefs, widget); // FIXME? ghb_check_dependency(ud, widget, NULL); const gchar *name = ghb_get_setting_key(widget); - ghb_pref_save(ud->prefs, name); + ghb_pref_set(ud->prefs, name); gint preview_count; preview_count = ghb_settings_get_int(ud->prefs, "preview_count"); @@ -3862,7 +3865,7 @@ use_m4v_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_widget_to_setting (ud->prefs, widget); ghb_check_dependency(ud, widget, NULL); const gchar *name = ghb_get_setting_key(widget); - ghb_pref_save(ud->prefs, name); + ghb_pref_set(ud->prefs, name); ghb_update_destination_extension(ud); } @@ -3873,7 +3876,7 @@ show_status_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_widget_to_setting (ud->prefs, widget); ghb_check_dependency(ud, widget, NULL); const gchar *name = ghb_get_setting_key(widget); - ghb_pref_save(ud->prefs, name); + ghb_pref_set(ud->prefs, name); #if defined(_USE_APP_IND) if (ud->ai) @@ -3904,7 +3907,7 @@ vqual_granularity_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_check_dependency(ud, widget, NULL); const gchar *name = ghb_get_setting_key(widget); - ghb_pref_save(ud->prefs, name); + ghb_pref_set(ud->prefs, name); gdouble vqmin, vqmax, step, page; gboolean inverted; @@ -3922,7 +3925,7 @@ tweaks_changed_cb(GtkWidget *widget, signal_user_data_t *ud) g_debug("tweaks_changed_cb"); ghb_widget_to_setting (ud->prefs, widget); const gchar *name = ghb_get_setting_key(widget); - ghb_pref_save(ud->prefs, name); + ghb_pref_set(ud->prefs, name); } G_MODULE_EXPORT void @@ -3931,7 +3934,7 @@ hbfd_feature_changed_cb(GtkWidget *widget, signal_user_data_t *ud) g_debug("hbfd_feature_changed_cb"); ghb_widget_to_setting (ud->prefs, widget); const gchar *name = ghb_get_setting_key(widget); - ghb_pref_save(ud->prefs, name); + ghb_pref_set(ud->prefs, name); gboolean hbfd = ghb_settings_get_boolean(ud->prefs, "hbfd_feature"); if (hbfd) @@ -3940,7 +3943,7 @@ hbfd_feature_changed_cb(GtkWidget *widget, signal_user_data_t *ud) val = ghb_settings_get_value(ud->prefs, "hbfd"); ghb_ui_settings_update(ud, ud->prefs, "hbfd", val); } - widget = GHB_WIDGET (ud->builder, "hbfd"); + widget = GHB_WIDGET(ud->builder, "hbfd"); gtk_widget_set_visible(widget, hbfd); } diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index f00805616..43270a5fe 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -226,12 +226,12 @@ conjunction with the "Forced" option.</property> <object class="GtkAdjustment" id="adjustment22"> <property name="upper">2</property> <property name="value">1</property> - <property name="step_increment">0.10000000000000001</property> + <property name="step_increment">0.1</property> <property name="page_increment">0.5</property> </object> <object class="GtkAdjustment" id="adjustment23"> <property name="upper">1</property> - <property name="step_increment">0.050000000000000003</property> + <property name="step_increment">0.05</property> <property name="page_increment">0.5</property> </object> <object class="GtkAdjustment" id="adjustment24"> @@ -259,9 +259,9 @@ conjunction with the "Forced" option.</property> <property name="page_increment">1</property> </object> <object class="GtkAdjustment" id="adjustment28"> - <property name="lower">0.90000000000000002</property> + <property name="lower">0.9</property> <property name="upper">4</property> - <property name="step_increment">0.10000000000000001</property> + <property name="step_increment">0.1</property> <property name="page_increment">1</property> </object> <object class="GtkAdjustment" id="adjustment29"> @@ -300,7 +300,7 @@ conjunction with the "Forced" option.</property> <object class="GtkAdjustment" id="adjustment34"> <property name="upper">2</property> <property name="value">1</property> - <property name="step_increment">0.10000000000000001</property> + <property name="step_increment">0.1</property> <property name="page_increment">0.5</property> </object> <object class="GtkAdjustment" id="adjustment35"> @@ -334,7 +334,7 @@ conjunction with the "Forced" option.</property> </object> <object class="GtkAdjustment" id="audio_quality_adj"> <property name="upper">10</property> - <property name="step_increment">0.10000000000000001</property> + <property name="step_increment">0.1</property> <property name="page_increment">1</property> </object> <object class="GtkAboutDialog" id="hb_about"> @@ -1072,7 +1072,7 @@ Here you can adjust cropping, resolution, aspect ratio, and filters.</property> <object class="GtkLabel" id="label20"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0.10000000149011612</property> + <property name="xalign">0.1</property> <property name="label" translatable="yes">Title:</property> </object> </child> @@ -1260,7 +1260,7 @@ This is often the feature title of a DVD.</property> <object class="GtkLabel" id="label6"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0.10000000149011612</property> + <property name="xalign">0.1</property> <property name="label" translatable="yes">Duration:</property> </object> <packing> @@ -1991,7 +1991,7 @@ This allows a player to initiate playback before downloading the entire file.</p <object class="GtkAlignment" id="alignment56"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="yalign">0.40000000596046448</property> + <property name="yalign">0.4</property> <property name="yscale">0</property> <property name="top_padding">12</property> <property name="right_padding">12</property> @@ -2058,7 +2058,7 @@ This allows a player to initiate playback before downloading the entire file.</p <property name="width_request">85</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0.20000000298023224</property> + <property name="xalign">0.2</property> <property name="yalign">0</property> <property name="label" translatable="yes">--</property> </object> @@ -6336,171 +6336,6 @@ on the Video tab instead.</property> <property name="can_focus">False</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> <object class="GtkCheckButton" id="allow_tweaks"> <property name="label" translatable="yes">Allow Tweaks</property> <property name="can_focus">True</property> @@ -10060,7 +9895,7 @@ weather-clear</property> <property name="can_focus">False</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <child> - <object class="GtkScaleButton" id="AudioTrackGain"> + <object class="GtkScaleButton" id="AudioTrackGainSlider"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="valign">GTK_ALIGN_CENTER</property> diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 8244e9b2c..5dff6898d 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -3736,8 +3736,8 @@ ghb_get_default_acodec() return HB_ACODEC_FAAC; } -static void -picture_settings_deps(signal_user_data_t *ud) +void +ghb_picture_settings_deps(signal_user_data_t *ud) { gboolean autoscale, keep_aspect, enable_keep_aspect; gboolean enable_scale_width, enable_scale_height; @@ -4092,7 +4092,7 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) ud->scale_busy = TRUE; ghb_set_scale_settings(ud->settings, mode); - picture_settings_deps(ud); + ghb_picture_settings_deps(ud); // Step needs to be at least 2 because odd widths cause scaler crash // subsampled chroma requires even crop values. @@ -4947,7 +4947,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) audio.out.codec = ghb_select_audio_codec(job->mux, aconfig, acodec, fallback, copy_mask); audio.out.gain = - ghb_settings_get_double(asettings, "AudioTrackGain"); + ghb_settings_get_double(asettings, "AudioTrackGainSlider"); audio.out.dynamic_range_compression = ghb_settings_get_double(asettings, "AudioTrackDRCSlider"); diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index e54aa1aad..3caae6225 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -108,6 +108,7 @@ hb_list_t * ghb_get_title_list(); void ghb_par_init(signal_user_data_t *ud); void ghb_set_scale(signal_user_data_t *ud, gint mode); void ghb_set_scale_settings(GValue *settings, gint mode); +void ghb_picture_settings_deps(signal_user_data_t *ud); GValue* ghb_get_chapters(gint titleindex); gint64 ghb_get_chapter_duration(gint ti, gint chap); gint64 ghb_get_chapter_start(gint ti, gint chap); diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml index 2815e52ff..e1c2eaef4 100644 --- a/gtk/src/internal_defaults.xml +++ b/gtk/src/internal_defaults.xml @@ -20,6 +20,8 @@ <key>angle</key> <integer>1</integer> <key>autoscale</key> + <true /> + <key>UsesMaxPictureSettings</key> <false /> <key>dest_dir</key> <string></string> @@ -77,44 +79,6 @@ <string>none</string> <key>volume_label</key> <string>New Video</string> - <key>x264_8x8dct</key> - <false /> - <key>x264_analyse</key> - <string>some</string> - <key>x264_bframes</key> - <integer>0</integer> - <key>x264_mbtree</key> - <true /> - <key>x264_bpyramid</key> - <false /> - <key>x264_cabac</key> - <true /> - <key>x264_deblock_alpha</key> - <integer>0</integer> - <key>x264_deblock_beta</key> - <integer>0</integer> - <key>x264_direct</key> - <string>spatial</string> - <key>x264_b_adapt</key> - <string>1</string> - <key>x264_me</key> - <string>hex</string> - <key>x264_merange</key> - <integer>16</integer> - <key>x264_mixed_refs</key> - <false /> - <key>x264_no_dct_decimate</key> - <false /> - <key>x264_no_fast_pskip</key> - <false /> - <key>x264_refs</key> - <integer>1</integer> - <key>x264_subme</key> - <integer>6</integer> - <key>x264_trellis</key> - <integer>0</integer> - <key>x264_weighted_bframes</key> - <false /> <key>audio_list</key> <array> </array> @@ -141,6 +105,14 @@ <key>VideoFrameratePFR</key> <false /> <key>VideoFramerateVFR</key> + <true /> + <key>PictureDeinterlaceDecomb</key> + <false /> + <key>x264PresetSlider</key> + <integer>0</integer> + <key>x264ZeroLatency</key> + <false /> + <key>x264FastDecode</key> <false /> </dict> <key>Preferences</key> @@ -226,29 +198,6 @@ <key>window_height</key> <integer>1</integer> </dict> - <key>XlatPresets</key> - <dict> - <key>autoscale</key> - <false /> - <key>vquality_type_bitrate</key> - <false /> - <key>vquality_type_constant</key> - <false /> - <key>VideoFramerateCFR</key> - <false /> - <key>VideoFrameratePFR</key> - <false /> - <key>VideoFramerateVFR</key> - <false /> - <key>PictureDeinterlaceDecomb</key> - <false /> - <key>x264PresetSlider</key> - <integer>0</integer> - <key>x264ZeroLatency</key> - <false /> - <key>x264FastDecode</key> - <false /> - </dict> <key>Presets</key> <dict> <key>PresetBuildNumber</key> @@ -264,7 +213,7 @@ <key>PictureLooseCrop</key> <false /> <key>PictureModulus</key> - <integer>16</integer> + <integer>2</integer> <key>PictureDeblock</key> <integer>0</integer> <key>PictureDecombDeinterlace</key> @@ -346,7 +295,7 @@ <false /> <key>AudioTrackQuality</key> <real>-1</real> - <key>AudioTrackGain</key> + <key>AudioTrackGainSlider</key> <real>0</real> <key>AudioTrackDRCSlider</key> <real>0</real> @@ -384,8 +333,6 @@ <true /> <key>UsesPictureSettings</key> <integer>2</integer> - <key>UsesMaxPictureSettings</key> - <false /> <key>VideoTwoPass</key> <false /> <key>VideoAvgBitrate</key> @@ -396,8 +343,6 @@ <integer>2</integer> <key>VideoQualitySlider</key> <real>0.60</real> - <key>VideoTargetSize</key> - <integer>700</integer> <key>lavcOption</key> <string></string> <key>x264Option</key> diff --git a/gtk/src/main.c b/gtk/src/main.c index e91d1d9ce..5b2a3b43b 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -1011,20 +1011,28 @@ main(int argc, char *argv[]) ghb_init_audio_defaults_ui(ud); ghb_init_subtitle_defaults_ui(ud); - // Load all internal settings with default values - ghb_settings_init(ud->globals, "Globals"); - ghb_settings_init(ud->prefs, "Preferences"); - ghb_settings_init(ud->settings, "Initialization"); - ghb_settings_init(ud->settings, "Presets"); - // Load prefs before presets. Some preset defaults may depend // on preference settings. + // First load default values + ghb_settings_init(ud->prefs, "Preferences"); + ghb_settings_init(ud->globals, "Globals"); + ghb_settings_init(ud->settings, "Initialization"); + // Load user preferences file ghb_prefs_load(ud); + // Store user preferences into ud->prefs + ghb_prefs_to_settings(ud->prefs); + + // Load all settings with default preset values + ghb_settings_init(ud->settings, "Presets"); // Load the presets files ghb_presets_load(ud); + // Note that ghb_preset_to_settings(ud->settings) is called when + // the default preset is selected. - ghb_globals_to_ui(ud); - ghb_prefs_to_ui(ud); + ghb_settings_to_ui(ud, ud->globals); + ghb_settings_to_ui(ud, ud->prefs); + // Note that ghb_settings_to_ui(ud->settings) happens when initial + // empty title is initialized. gint logLevel; logLevel = ghb_settings_get_int(ud->prefs, "LoggingLevel"); @@ -1039,7 +1047,7 @@ main(int argc, char *argv[]) g_free(source); // Parsing x264 options "" initializes x264 widgets to proper defaults - ghb_x264_parse_options(ud, ""); + ghb_x264_init(ud); // Populate the presets tree view ghb_presets_list_init(ud, NULL, 0); @@ -1067,6 +1075,11 @@ main(int argc, char *argv[]) ghb_settings_set_string(ud->globals, "scan_source", dvd_device); g_idle_add((GSourceFunc)ghb_idle_scan, ud); } + else + { + GValue *gval = ghb_settings_get_value(ud->prefs, "default_source"); + ghb_settings_set_value(ud->globals, "scan_source", gval); + } // Reload and check status of the last saved queue g_idle_add((GSourceFunc)ghb_reload_queue, ud); @@ -1265,6 +1278,7 @@ main(int argc, char *argv[]) ghb_value_free(ud->settings); g_io_channel_unref(ud->activity_log); ghb_settings_close(); + ghb_resource_free(); #if !defined(_WIN32) notify_uninit(); #endif diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py index ad00a23b3..7be7a71b5 100644 --- a/gtk/src/makedeps.py +++ b/gtk/src/makedeps.py @@ -57,7 +57,7 @@ dep_map = ( DepEntry("AudioEncoder", "AudioMixdownLabel", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), DepEntry("AudioEncoder", "AudioMixdown", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), DepEntry("AudioEncoder", "AudioTrackGainLabel", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), - DepEntry("AudioEncoder", "AudioTrackGain", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), + DepEntry("AudioEncoder", "AudioTrackGainSlider", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), DepEntry("AudioEncoder", "AudioTrackGainValue", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), DepEntry("x264_bframes", "x264_bpyramid", "<2", True, False), DepEntry("x264_bframes", "x264_direct", "0", True, False), diff --git a/gtk/src/presets.c b/gtk/src/presets.c index cced4aaba..c59b917f2 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -40,8 +40,8 @@ enum PRESETS_CUSTOM }; +static GValue *presetsPlistFile = NULL; static GValue *presetsPlist = NULL; -static GValue *internalPlist = NULL; static GValue *prefsPlist = NULL; static gboolean prefs_modified = FALSE; @@ -50,6 +50,30 @@ static void store_plist(GValue *plist, const gchar *name); static void store_presets(void); static void store_prefs(void); +static void +dict_clean(GValue *dict, GValue *template) +{ + GValue *tmp = ghb_value_dup(dict); + GHashTableIter iter; + gchar *key; + GValue *value; + GValue *template_val; + + ghb_dict_iter_init(&iter, tmp); + // middle (void*) cast prevents gcc warning "defreferencing type-punned + // pointer will break strict-aliasing rules" + while (g_hash_table_iter_next( + &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value)) + { + template_val = ghb_dict_lookup(template, key); + if (template_val == NULL) + { + ghb_dict_remove(dict, key); + } + } + ghb_value_free(tmp); +} + gint preset_path_cmp(gint *indices1, gint len1, gint *indices2, gint len2) { @@ -736,95 +760,119 @@ key_cmp(gconstpointer a, gconstpointer b) static const GValue* preset_dict_get_value(GValue *dict, const gchar *key) { - const GValue *gval = NULL; + return ghb_dict_lookup(dict, key); +} + +static const char * dict_get_string(GValue *dict, const char *key) +{ + GValue *gval = ghb_dict_lookup(dict, key); - if (dict) - { - gval = ghb_dict_lookup(dict, key); - } - if (internalPlist == NULL) return NULL; if (gval == NULL) - { - dict = plist_get_dict(internalPlist, "Presets"); - if (dict == NULL) return NULL; - gval = ghb_dict_lookup(dict, key); - } - return gval; + return NULL; + return g_value_get_string(gval); +} + +static gboolean dict_get_boolean(GValue *dict, const char *key) +{ + GValue *gval = ghb_dict_lookup(dict, key); + + if (gval == NULL) + return FALSE; + return g_value_get_boolean(gval); } const gchar* ghb_presets_get_description(GValue *pdict) { - const gchar *desc; - - if (pdict == NULL) return NULL; - desc = g_value_get_string( - preset_dict_get_value(pdict, "PresetDescription")); - if (desc[0] == 0) return NULL; - return desc; + return dict_get_string(pdict, "PresetDescription"); } static void init_settings_from_dict( - GValue *dest, GValue *internal, GValue *dict); + GValue *dest, GValue *template, GValue *dict, gboolean filter); static void init_settings_from_array( GValue *dest, - GValue *internal, - GValue *array) + GValue *template, + GValue *array, + gboolean filter) { - GValue *gval, *val; + GValue *gval, *val, *new_val; gint count, ii; + if (ghb_array_len(template) == 0) + { + if (!filter) + { + count = ghb_array_len(array); + for (ii = 0; ii < count; ii++) + { + val = ghb_array_get_nth(array, ii); + ghb_array_append(dest, ghb_value_dup(val)); + } + } + return; + } + count = ghb_array_len(array); - // The first element of the internal version is always the + // The first element of the template array is always the // template for the allowed values - gval = ghb_array_get_nth(internal, 0); + gval = ghb_array_get_nth(template, 0); for (ii = 0; ii < count; ii++) { - val = NULL; val = ghb_array_get_nth(array, ii); - if (val == NULL) - val = gval; if (G_VALUE_TYPE(gval) == ghb_dict_get_type()) { GValue *new_dict; - new_dict = ghb_dict_value_new(); - ghb_array_append(dest, new_dict); - if (G_VALUE_TYPE(val) == ghb_dict_get_type()) - init_settings_from_dict(new_dict, gval, val); + if (val != NULL && G_VALUE_TYPE(val) == ghb_dict_get_type()) + { + new_dict = ghb_dict_value_new(); + init_settings_from_dict(new_dict, gval, val, filter); + } else - init_settings_from_dict(new_dict, gval, gval); + { + new_dict = ghb_value_dup(gval); + } + new_val = new_dict; } else if (G_VALUE_TYPE(gval) == ghb_array_get_type()) { GValue *new_array; - new_array = ghb_array_value_new(8); - ghb_array_append(dest, new_array); - if (G_VALUE_TYPE(val) == ghb_array_get_type()) - init_settings_from_array(new_array, gval, val); + if (val != NULL && G_VALUE_TYPE(val) == ghb_array_get_type()) + { + new_array = ghb_array_value_new(8); + init_settings_from_array(new_array, gval, val, filter); + } else - init_settings_from_array(new_array, gval, gval); + { + new_array = ghb_value_dup(gval); + } + new_val = new_array; } - else if (val != NULL) + else { - ghb_array_append(dest, ghb_value_dup(val)); + if (val == NULL) + new_val = ghb_value_dup(gval); + else + new_val = ghb_value_dup(val); } + ghb_array_append(dest, new_val); } } static void init_settings_from_dict( GValue *dest, - GValue *internal, - GValue *dict) + GValue *template, + GValue *dict, + gboolean filter) { GHashTableIter iter; gchar *key; - GValue *gval, *val; + GValue *gval, *val, *new_val; - ghb_dict_iter_init(&iter, internal); + ghb_dict_iter_init(&iter, template); // middle (void*) cast prevents gcc warning "defreferencing type-punned // pointer will break strict-aliasing rules" while (g_hash_table_iter_next( @@ -833,93 +881,61 @@ init_settings_from_dict( val = NULL; if (dict) val = ghb_dict_lookup(dict, key); - if (val == NULL) - val = gval; if (G_VALUE_TYPE(gval) == ghb_dict_get_type()) { GValue *new_dict; - new_dict = ghb_dict_value_new(); - ghb_settings_take_value(dest, key, new_dict); - if (G_VALUE_TYPE(val) == ghb_dict_get_type()) - init_settings_from_dict(new_dict, gval, val); + if (val != NULL && G_VALUE_TYPE(val) == ghb_dict_get_type()) + { + new_dict = ghb_dict_value_new(); + init_settings_from_dict(new_dict, gval, val, filter); + } else - init_settings_from_dict(new_dict, gval, gval); + { + new_dict = ghb_value_dup(gval); + } + new_val = new_dict; } else if (G_VALUE_TYPE(gval) == ghb_array_get_type()) { GValue *new_array; - new_array = ghb_array_value_new(8); - ghb_settings_take_value(dest, key, new_array); - if (G_VALUE_TYPE(val) == ghb_array_get_type()) - init_settings_from_array(new_array, gval, val); + if (val != NULL && G_VALUE_TYPE(val) == ghb_array_get_type()) + { + new_array = ghb_array_value_new(8); + init_settings_from_array(new_array, gval, val, filter); + } else - init_settings_from_array(new_array, gval, gval); + { + new_array = ghb_value_dup(gval); + } + new_val = new_array; } else { - ghb_settings_set_value(dest, key, val); + if (val == NULL) + new_val = ghb_value_dup(gval); + else + new_val = ghb_value_dup(val); } + ghb_settings_take_value(dest, key, new_val); } -} - -static const char * dict_get_string(GValue *dict, const char *key) -{ - GValue *gval = ghb_dict_lookup(dict, key); - if (gval == NULL) - return NULL; - return g_value_get_string(gval); -} - -static gboolean dict_get_boolean(GValue *dict, const char *key) -{ - GValue *gval = ghb_dict_lookup(dict, key); - - if (gval == NULL) - return FALSE; - return g_value_get_boolean(gval); -} - -void -init_ui_from_dict( - signal_user_data_t *ud, - GValue *internal, - GValue *dict) -{ - GHashTableIter iter; - gchar *key; - GValue *gval, *val; - GValue *tmp = ghb_value_dup(internal); + if (filter || dict == NULL) + return; - ghb_dict_iter_init(&iter, tmp); + // If not filtering the source, copy source elements that + // were not in the template. + ghb_dict_iter_init(&iter, dict); // middle (void*) cast prevents gcc warning "defreferencing type-punned // pointer will break strict-aliasing rules" while (g_hash_table_iter_next( &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) { - if (!strcmp(key, "x264Option")) + val = ghb_dict_lookup(template, key); + if (val == NULL) { - continue; + ghb_settings_set_value(dest, key, gval); } - val = NULL; - if (dict) - val = ghb_dict_lookup(dict, key); - if (val == NULL) - val = gval; - ghb_ui_update(ud, key, val); - } - ghb_value_free(tmp); - - if (dict == NULL) - dict = internal; - - if (ghb_value_boolean(preset_dict_get_value(dict, "x264UseAdvancedOptions"))) - - { - val = ghb_dict_lookup(dict, "x264Option"); - if (val != NULL) - ghb_ui_update(ud, "x264Option", val); } } @@ -927,50 +943,175 @@ void ghb_preset_to_settings(GValue *settings, GValue *preset) { // Initialize the ui from presets file. - GValue *internal, *hidden; + GValue *internal; // Get key list from internal default presets. This way we do not // load any unknown keys. + GValue *internalPlist = ghb_resource_get("internal-defaults"); if (internalPlist == NULL) return; internal = plist_get_dict(internalPlist, "Presets"); - hidden = plist_get_dict(internalPlist, "XlatPresets"); - // Setting a ui widget will cause the corresponding setting - // to be set, but it also triggers a callback that can - // have the side effect of using other settings values - // that have not yet been set. So set *all* settings first - // then update the ui. - init_settings_from_dict(settings, internal, preset); - init_settings_from_dict(settings, hidden, preset); - if (preset == NULL) preset = internal; - GValue *val; - gboolean dd; + init_settings_from_dict(settings, preset, NULL, TRUE); + + // Fix up all the internal settings that are derived from preset values. + ghb_settings_set_boolean(settings, "PictureDeinterlaceDecomb", + !ghb_settings_get_boolean(settings, "PictureDecombDeinterlace")); + + ghb_settings_set_value(settings, "scale_height", + ghb_settings_get_value(settings, "PictureHeight")); - val = ghb_dict_lookup(preset, "PictureDecombDeinterlace"); - if (val != NULL) + ghb_settings_set_value(settings, "scale_width", + ghb_settings_get_value(settings, "PictureWidth")); + + ghb_settings_set_boolean(settings, "preset_modified", FALSE); + + gboolean uses_max; + gint uses_pic; + gint vqtype; + + uses_max = ghb_settings_get_boolean(settings, "UsesMaxPictureSettings"); + uses_pic = ghb_settings_get_int(settings, "UsesPictureSettings"); + vqtype = ghb_settings_get_int(settings, "VideoQualityType"); + + // "Use max" or "strict anamorphic" imply autoscale + if (uses_max || uses_pic == 2) { - dd = ghb_value_boolean(val); - ghb_settings_set_boolean(settings, "PictureDeinterlaceDecomb", !dd); + ghb_settings_set_boolean(settings, "autoscale", TRUE); } - val = ghb_dict_lookup(preset, "PictureHeight"); - if (val != NULL) + else if (uses_pic == 1) { - ghb_settings_set_value(settings, "scale_height", val); + ghb_settings_set_boolean(settings, "autoscale", FALSE); } - val = ghb_dict_lookup(preset, "PictureWidth"); - if (val != NULL) + + // VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant + // *note: target is no longer used + switch (vqtype) + { + case 0: { - ghb_settings_set_value(settings, "scale_width", val); + ghb_settings_set_boolean(settings, "vquality_type_bitrate", TRUE); + ghb_settings_set_boolean(settings, "vquality_type_constant", FALSE); + } break; + case 1: + { + ghb_settings_set_boolean(settings, "vquality_type_bitrate", TRUE); + ghb_settings_set_boolean(settings, "vquality_type_constant", FALSE); + } break; + case 2: + { + ghb_settings_set_boolean(settings, "vquality_type_bitrate", FALSE); + ghb_settings_set_boolean(settings, "vquality_type_constant", TRUE); + } break; + default: + { + ghb_settings_set_boolean(settings, "vquality_type_bitrate", FALSE); + ghb_settings_set_boolean(settings, "vquality_type_constant", TRUE); + } break; } - ghb_settings_set_boolean(settings, "preset_modified", FALSE); + + gchar *mode = ghb_settings_get_string(settings, "VideoFramerateMode"); + if (strcmp(mode, "cfr") == 0) + { + ghb_settings_set_boolean(settings, "VideoFramerateCFR", TRUE); + ghb_settings_set_boolean(settings, "VideoFrameratePFR", FALSE); + ghb_settings_set_boolean(settings, "VideoFramerateVFR", FALSE); + } + else if (strcmp(mode, "pfr") == 0) + { + ghb_settings_set_boolean(settings, "VideoFramerateCFR", FALSE); + ghb_settings_set_boolean(settings, "VideoFrameratePFR", TRUE); + ghb_settings_set_boolean(settings, "VideoFramerateVFR", FALSE); + } + else + { + ghb_settings_set_boolean(settings, "VideoFramerateCFR", FALSE); + ghb_settings_set_boolean(settings, "VideoFrameratePFR", FALSE); + ghb_settings_set_boolean(settings, "VideoFramerateVFR", TRUE); + } + g_free(mode); + + if (ghb_settings_get_boolean(settings, "x264UseAdvancedOptions")) + { + // Force preset/tune/profile/level/opts to conform to option string + ghb_settings_set_string(settings, "x264Preset", "medium"); + ghb_settings_set_string(settings, "x264Tune", "none"); + ghb_settings_set_string(settings, "h264Profile", "auto"); + ghb_settings_set_string(settings, "h264Level", "auto"); + ghb_settings_set_value(settings, "x264OptionExtra", + ghb_settings_get_value(settings, "x264Option")); + } + else + { + ghb_dict_remove(settings, "x264Option"); + } + + const char * const *x264preset = hb_x264_presets(); + char *x264Preset = ghb_settings_get_string(settings, "x264Preset"); + int ii; + for (ii = 0; x264preset[ii]; ii++) + { + if (!strcasecmp(x264Preset, x264preset[ii])) + { + ghb_settings_set_int(settings, "x264PresetSlider", ii); + } + } + g_free(x264Preset); + + char *x264Tune = ghb_settings_get_string(settings, "x264Tune"); + char *tune = NULL; + char *tmp = g_strdup(x264Tune); + char *saveptr; + char * tok = strtok_r(tmp, ",./-+", &saveptr); + while (tok != NULL) + { + if (!strcasecmp(tok, "fastdecode")) + { + ghb_settings_set_boolean(settings, "x264FastDecode", TRUE); + } + else if (!strcasecmp(tok, "zerolatency")) + { + ghb_settings_set_boolean(settings, "x264ZeroLatency", TRUE); + } + else if (tune == NULL) + { + tune = g_strdup(tok); + } + else + { + ghb_log("Superfluous tunes! %s", tok); + } + tok = strtok_r(NULL, ",./-+", &saveptr); + } + if (tune != NULL) + { + ghb_settings_set_string(settings, "x264Tune", tune); + g_free(tune); + } + g_free(x264Tune); } void ghb_settings_to_ui(signal_user_data_t *ud, GValue *dict) { - init_ui_from_dict(ud, dict, NULL); + GHashTableIter iter; + gchar *key; + GValue *gval; + GValue *tmp = ghb_value_dup(dict); + + if (dict == NULL) + return; + + ghb_dict_iter_init(&iter, tmp); + // middle (void*) cast prevents gcc warning "defreferencing type-punned + // pointer will break strict-aliasing rules" + while (g_hash_table_iter_next( + &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) + { + ghb_ui_settings_update(ud, dict, key, gval); + } + ghb_value_free(tmp); } static GValue *current_preset = NULL; @@ -1322,111 +1463,6 @@ remove_plist(const gchar *name) g_free(config); } -static gboolean prefs_initializing = FALSE; - -void -ghb_globals_to_ui(signal_user_data_t *ud) -{ - const GValue *gval; - gchar *key; - GValue *internal; - GHashTableIter iter; - - internal = plist_get_dict(internalPlist, "Initialization"); - ghb_dict_iter_init(&iter, internal); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) - { - ghb_ui_settings_update(ud, ud->settings, key, gval); - } - - internal = plist_get_dict(internalPlist, "Globals"); - ghb_dict_iter_init(&iter, internal); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) - { - ghb_ui_settings_update(ud, ud->globals, key, gval); - } -} - -void -ghb_prefs_to_ui(signal_user_data_t *ud) -{ - const GValue *gval; - gchar *key; - GValue *internal, *dict; - GHashTableIter iter; - - - g_debug("ghb_prefs_to_ui"); - prefs_initializing = TRUE; - - // Setting a ui widget will cause the corresponding setting - // to be set, but it also triggers a callback that can - // have the side effect of using other settings values - // that have not yet been set. So set *all* settings first - // then update the ui. - dict = plist_get_dict(prefsPlist, "Preferences"); - internal = plist_get_dict(internalPlist, "Preferences"); - ghb_dict_iter_init(&iter, internal); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) - { - const GValue *value = NULL; - if (dict) - value = ghb_dict_lookup(dict, key); - if (value == NULL) - value = gval; - ghb_settings_set_value(ud->prefs, key, value); - } - internal = plist_get_dict(internalPlist, "Preferences"); - ghb_dict_iter_init(&iter, internal); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) - { - const GValue *value = NULL; - if (dict) - value = ghb_dict_lookup(dict, key); - if (value == NULL) - value = gval; - ghb_ui_settings_update(ud, ud->prefs, key, value); - } -#if 0 - const GValue *val; - val = ghb_settings_get_value(ud->prefs, "show_presets"); - ghb_ui_settings_update(ud, ud->prefs, "show_presets", val); -#endif - if (ghb_settings_get_boolean(ud->prefs, "hbfd_feature")) - { - GtkWidget *widget; -#if 0 - val = ghb_settings_get_value(ud->settings, "hbfd"); - ghb_ui_settings_update(ud, ud->prefs, "hbfd", val); -#endif - widget = GHB_WIDGET (ud->builder, "hbfd"); - gtk_widget_set_visible(widget, TRUE); - } - else - { - ghb_ui_settings_update(ud, ud->prefs, "hbfd", ghb_int64_value(0)); - } - gval = ghb_settings_get_value(ud->prefs, "default_source"); - ghb_settings_set_value(ud->globals, "scan_source", gval); - - ghb_ui_settings_update(ud, ud->settings, "dest_dir", - ghb_settings_get_value(ud->prefs, "destination_dir")); - - prefs_initializing = FALSE; -} - void ghb_prefs_save(GValue *settings) { @@ -1436,7 +1472,7 @@ ghb_prefs_save(GValue *settings) gchar *key; const GValue *value; - if (prefs_initializing) return; + GValue *internalPlist = ghb_resource_get("internal-defaults"); dict = plist_get_dict(internalPlist, "Preferences"); if (dict == NULL) return; pref_dict = plist_get_dict(prefsPlist, "Preferences"); @@ -1462,7 +1498,6 @@ ghb_pref_save(GValue *settings, const gchar *key) { const GValue *value, *value2; - if (prefs_initializing) return; value = ghb_settings_get_value(settings, key); if (value != NULL) { @@ -1484,7 +1519,6 @@ ghb_pref_set(GValue *settings, const gchar *key) { const GValue *value, *value2; - if (prefs_initializing) return; value = ghb_settings_get_value(settings, key); if (value != NULL) { @@ -1519,7 +1553,7 @@ ghb_settings_init(GValue *settings, const char *name) GValue *gval; g_debug("ghb_settings_init"); - internalPlist = ghb_resource_get("internal-defaults"); + GValue *internalPlist = ghb_resource_get("internal-defaults"); // Setting a ui widget will cause the corresponding setting // to be set, but it also triggers a callback that can // have the side effect of using other settings values @@ -1539,8 +1573,6 @@ ghb_settings_init(GValue *settings, const char *name) void ghb_settings_close() { - if (internalPlist) - ghb_value_free(internalPlist); if (presetsPlist) ghb_value_free(presetsPlist); if (prefsPlist) @@ -1584,6 +1616,7 @@ ghb_prefs_load(signal_user_data_t *ud) GValue *gval; g_debug("ghb_prefs_load"); + GValue *internalPlist = ghb_resource_get("internal-defaults"); prefsPlist = load_plist("preferences"); if (prefsPlist == NULL) prefsPlist = ghb_dict_value_new(); @@ -1638,6 +1671,29 @@ ghb_prefs_load(signal_user_data_t *ud) } } +void +ghb_prefs_to_settings(GValue *settings) +{ + // Initialize the ui from presets file. + GValue *internal, *dict; + + if (prefsPlist == NULL) + return; + + // Get key list from internal default presets. This way we do not + // load any unknown keys. + GValue *internalPlist = ghb_resource_get("internal-defaults"); + if (internalPlist == NULL) return; + internal = plist_get_dict(internalPlist, "Preferences"); + dict = plist_get_dict(prefsPlist, "Preferences"); + // Setting a ui widget will cause the corresponding setting + // to be set, but it also triggers a callback that can + // have the side effect of using other settings values + // that have not yet been set. So set *all* settings first + // then update the ui. + init_settings_from_dict(settings, internal, dict, TRUE); +} + static const gchar* get_preset_color(gint type, gboolean folder) { @@ -2221,6 +2277,7 @@ export_value_container(GValue *lin_val) return sval; } +// Translate values for compatibility with other platforms static void export_value_xlat(GValue *dict) { @@ -2476,6 +2533,7 @@ import_value_xlat(GValue *dict) GValue *defaults, *mac_val, *gval; const gchar *key; + GValue *internalPlist = ghb_resource_get("internal-defaults"); defaults = plist_get_dict(internalPlist, "Presets"); key = "VideoEncoder"; mac_val = ghb_dict_lookup(dict, key); @@ -2564,7 +2622,7 @@ import_value_xlat(GValue *dict) { gdouble drc; drc = ghb_value_double(mac_val); - if (drc < 1.0 && drc > 0.0) + if (drc < 1.0) { ghb_dict_insert(adict, g_strdup("AudioTrackDRCSlider"), ghb_double_value_new(0.0)); @@ -2574,86 +2632,20 @@ import_value_xlat(GValue *dict) } } -static void -import_xlat_preset(GValue *dict) +static GValue* +import_xlat_preset(GValue *user_preset) { - gboolean uses_max; - gint uses_pic; - gint par; - gint vqtype; + GValue *dict, *internal; g_debug("import_xlat_preset ()"); - uses_max = ghb_value_boolean( - preset_dict_get_value(dict, "UsesMaxPictureSettings")); - uses_pic = ghb_value_int( - preset_dict_get_value(dict, "UsesPictureSettings")); - par = ghb_value_int(preset_dict_get_value(dict, "PicturePAR")); - vqtype = ghb_value_int(preset_dict_get_value(dict, "VideoQualityType")); - if (uses_max || uses_pic == 2) - { - ghb_dict_insert(dict, g_strdup("autoscale"), - ghb_boolean_value_new(TRUE)); - } - switch (par) - { - case 0: - { - if (ghb_dict_lookup(dict, "PictureModulus") == NULL) - ghb_dict_insert(dict, g_strdup("PictureModulus"), - ghb_int_value_new(16)); - } break; - case 1: - { - ghb_dict_insert(dict, g_strdup("PictureModulus"), - ghb_int_value_new(1)); - } break; - case 2: - { - if (ghb_dict_lookup(dict, "PictureModulus") == NULL) - ghb_dict_insert(dict, g_strdup("PictureModulus"), - ghb_int_value_new(16)); - } break; - default: - { - if (ghb_dict_lookup(dict, "PictureModulus") == NULL) - ghb_dict_insert(dict, g_strdup("PictureModulus"), - ghb_int_value_new(16)); - } break; - } - // VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant - // *note: target is no longer used - switch (vqtype) - { - case 0: - { - ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), - ghb_boolean_value_new(TRUE)); - ghb_dict_insert(dict, g_strdup("vquality_type_constant"), - ghb_boolean_value_new(FALSE)); - } break; - case 1: - { - ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), - ghb_boolean_value_new(TRUE)); - ghb_dict_insert(dict, g_strdup("vquality_type_constant"), - ghb_boolean_value_new(FALSE)); - } break; - case 2: - { - ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), - ghb_boolean_value_new(FALSE)); - ghb_dict_insert(dict, g_strdup("vquality_type_constant"), - ghb_boolean_value_new(TRUE)); - } break; - default: - { - ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), - ghb_boolean_value_new(FALSE)); - ghb_dict_insert(dict, g_strdup("vquality_type_constant"), - ghb_boolean_value_new(TRUE)); - } break; - } + dict = ghb_dict_value_new(); + + // First, initialize the preset with defaults. + // Then import user presets over top of defaults + GValue *internalPlist = ghb_resource_get("internal-defaults"); + internal = plist_get_dict(internalPlist, "Presets"); + init_settings_from_dict(dict, internal, user_preset, FALSE); // Initialize the AudioLanguageList from preferences PreferredLanguage // and translate old AudioDUB preference option if found @@ -2726,163 +2718,7 @@ import_xlat_preset(GValue *dict) import_value_xlat(dict); - GValue *mode = ghb_dict_lookup(dict, "VideoFramerateMode"); - if (mode == NULL) - { - GValue *fr = ghb_dict_lookup(dict, "VideoFramerate"); - if (fr) - { - gchar *str; - gboolean pfr = FALSE; - GValue *pfr_val = ghb_dict_lookup(dict, "VideoFrameratePFR"); - if (pfr_val) - { - pfr = ghb_value_boolean(pfr_val); - } - str = ghb_value_string(fr); - if (strcmp(str, "source") == 0) - { - ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), - ghb_boolean_value_new(FALSE)); - ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), - ghb_boolean_value_new(TRUE)); - } - else if (!pfr) - { - ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), - ghb_boolean_value_new(TRUE)); - ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), - ghb_boolean_value_new(FALSE)); - } - else - { - ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), - ghb_boolean_value_new(FALSE)); - ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), - ghb_boolean_value_new(FALSE)); - } - g_free(str); - } - } - else - { - gchar *str; - str = ghb_value_string(mode); - if (strcmp(str, "cfr") == 0) - { - ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), - ghb_boolean_value_new(TRUE)); - ghb_dict_insert(dict, g_strdup("VideoFrameratePFR"), - ghb_boolean_value_new(FALSE)); - ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), - ghb_boolean_value_new(FALSE)); - } - else if (strcmp(str, "pfr") == 0) - { - ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), - ghb_boolean_value_new(FALSE)); - ghb_dict_insert(dict, g_strdup("VideoFrameratePFR"), - ghb_boolean_value_new(TRUE)); - ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), - ghb_boolean_value_new(FALSE)); - } - else - { - ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), - ghb_boolean_value_new(FALSE)); - ghb_dict_insert(dict, g_strdup("VideoFrameratePFR"), - ghb_boolean_value_new(FALSE)); - ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), - ghb_boolean_value_new(TRUE)); - } - g_free(str); - } - - const char * const *preset = hb_x264_presets(); - if (ghb_value_boolean(preset_dict_get_value(dict, "x264UseAdvancedOptions"))) - { - // Force preset/tune/profile/level/opts to conform to option string - ghb_dict_insert(dict, g_strdup("x264Preset"), - ghb_string_value_new("medium")); - ghb_dict_insert(dict, g_strdup("x264Tune"), - ghb_string_value_new("none")); - ghb_dict_insert(dict, g_strdup("h264Profile"), - ghb_string_value_new("auto")); - ghb_dict_insert(dict, g_strdup("h264Level"), - ghb_string_value_new("auto")); - GValue *opt = ghb_dict_lookup(dict, "x264Option"); - ghb_dict_insert(dict, g_strdup("x264OptionExtra"), - ghb_value_dup(opt)); - } - - GValue *x264Preset = ghb_dict_lookup(dict, "x264Preset"); - if (x264Preset != NULL) - { - gchar *str; - str = ghb_value_string(x264Preset); - int ii; - for (ii = 0; preset[ii]; ii++) - { - if (!strcasecmp(str, preset[ii])) - { - ghb_dict_insert(dict, g_strdup("x264PresetSlider"), - ghb_int_value_new(ii)); - } - } - g_free(str); - } - else - { - int ii; - for (ii = 0; preset[ii]; ii++) - { - if (!strcasecmp("medium", preset[ii])) - { - ghb_dict_insert(dict, g_strdup("x264PresetSlider"), - ghb_int_value_new(ii)); - } - } - ghb_dict_insert(dict, g_strdup("x264UseAdvancedOptions"), - ghb_boolean_value_new(TRUE)); - } - - const char *x264Tune = dict_get_string(dict, "x264Tune"); - if (x264Tune != NULL) - { - char *tune = NULL; - char *tmp = g_strdup(x264Tune); - char *saveptr; - - char * tok = strtok_r(tmp, ",./-+", &saveptr); - while (tok != NULL) - { - if (!strcasecmp(tok, "fastdecode")) - { - ghb_dict_insert(dict, g_strdup("x264FastDecode"), - ghb_boolean_value_new(TRUE)); - } - else if (!strcasecmp(tok, "zerolatency")) - { - ghb_dict_insert(dict, g_strdup("x264ZeroLatency"), - ghb_boolean_value_new(TRUE)); - } - else if (tune == NULL) - { - tune = g_strdup(tok); - } - else - { - ghb_log("Superfluous tunes! %s", tok); - } - tok = strtok_r(NULL, ",./-+", &saveptr); - } - if (tune != NULL) - { - ghb_dict_insert(dict, g_strdup("x264Tune"), - ghb_string_value_new(tune)); - g_free(tune); - } - } + return dict; } static void @@ -2908,11 +2744,13 @@ import_xlat_presets(GValue *presets) } else { - import_xlat_preset(dict); + GValue *import_dict = import_xlat_preset(dict); + ghb_array_replace(presets, ii, import_dict); } } } +// Translate internal values to preset key, value pairs static void export_xlat_preset(GValue *dict) { @@ -2961,6 +2799,11 @@ export_xlat_preset(GValue *dict) ghb_string_value_new("vfr")); } + if (ghb_value_int(preset_dict_get_value(dict, "PictureDeblock")) < 5) + { + ghb_dict_insert(dict, g_strdup("PictureDeblock"), ghb_int_value_new(0)); + } + GValue *alist, *adict; gint count, ii; @@ -2973,7 +2816,7 @@ export_xlat_preset(GValue *dict) adict = ghb_array_get_nth(alist, ii); drc = ghb_value_double( preset_dict_get_value(adict, "AudioTrackDRCSlider")); - if (drc < 1.0 && drc > 0.0) + if (drc < 1.0) { ghb_dict_insert(adict, g_strdup("AudioTrackDRCSlider"), ghb_double_value_new(0.0)); @@ -3010,24 +2853,11 @@ export_xlat_preset(GValue *dict) g_free(tunes); } + // Remove everything from dist that isn't in "Presets" GValue *internal; - GHashTableIter iter; - gchar *key; - GValue *value; - internal = plist_get_dict(internalPlist, "XlatPresets"); - ghb_dict_iter_init(&iter, internal); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value)) - { - ghb_dict_remove(dict, key); - } - - // remove obsolete keys - ghb_dict_remove(dict, "UsesMaxPictureSettings"); - ghb_dict_remove(dict, "VFR"); - ghb_dict_remove(dict, "VideoFrameratePFR"); + GValue *internalPlist = ghb_resource_get("internal-defaults"); + internal = plist_get_dict(internalPlist, "Presets"); + dict_clean(dict, internal); export_value_xlat(dict); } @@ -3104,7 +2934,7 @@ ghb_presets_reload(signal_user_data_t *ud) int *indices, len; g_debug("ghb_presets_reload()\n"); - std_presets = ghb_resource_get("standard-presets"); + std_presets = ghb_value_dup(ghb_resource_get("standard-presets")); if (std_presets == NULL) return; remove_std_presets(ud); @@ -3131,20 +2961,21 @@ ghb_presets_reload(signal_user_data_t *ud) } import_xlat_presets(presetsPlist); store_presets(); + ghb_value_free(std_presets); } static gboolean -check_old_presets() +check_old_presets(GValue *presetsArray) { gint count, ii; - count = ghb_array_len(presetsPlist); + count = ghb_array_len(presetsArray); for (ii = count-1; ii >= 0; ii--) { GValue *dict; GValue *type; - dict = ghb_array_get_nth(presetsPlist, ii); + dict = ghb_array_get_nth(presetsArray, ii); type = ghb_dict_lookup(dict, "Type"); if (type == NULL) return TRUE; @@ -3153,36 +2984,42 @@ check_old_presets() } static void -replace_standard_presets() +replace_standard_presets(GValue *presetsArray) { - GValue *std_presets; + GValue *std_presets, *tmp; int *indices, len; gint count, ii; - count = ghb_array_len(presetsPlist); + // Remove existing standard presets + count = ghb_array_len(presetsArray); for (ii = count-1; ii >= 0; ii--) { GValue *dict; gint ptype; - dict = ghb_array_get_nth(presetsPlist, ii); + dict = ghb_array_get_nth(presetsArray, ii); ptype = ghb_value_int(preset_dict_get_value(dict, "Type")); if (ptype == PRESETS_BUILTIN) { gint indices = 0; - ghb_presets_remove(presetsPlist, &indices, 1); + ghb_presets_remove(presetsArray, &indices, 1); } } - std_presets = ghb_resource_get("standard-presets"); - if (std_presets == NULL) return; + // Get the default standard presets + tmp = ghb_resource_get("standard-presets"); + if (tmp == NULL) return; + std_presets = ghb_value_dup(tmp); - indices = presets_find_default(presetsPlist, &len); + // Clear the default in the standard presets if one is already set + // in custom presets + indices = presets_find_default(presetsArray, &len); if (indices) { presets_clear_default(std_presets); g_free(indices); } + // Merge the keyfile contents into our presets count = ghb_array_len(std_presets); for (ii = count-1; ii >= 0; ii--) @@ -3195,18 +3032,17 @@ replace_standard_presets() copy_dict = ghb_value_dup(std_dict); ghb_dict_insert(copy_dict, g_strdup("PresetBuildNumber"), ghb_int64_value_new(hb_get_build(NULL))); - ghb_presets_insert(presetsPlist, copy_dict, &indices, 1); + ghb_presets_insert(presetsArray, copy_dict, &indices, 1); } - import_xlat_presets(presetsPlist); - store_presets(); + ghb_value_free(std_presets); } static int -update_standard_presets(signal_user_data_t *ud) +update_standard_presets(signal_user_data_t *ud, GValue *presetsArray) { gint count, ii; - count = ghb_array_len(presetsPlist); + count = ghb_array_len(presetsArray); for (ii = count-1; ii >= 0; ii--) { GValue *dict; @@ -3214,12 +3050,12 @@ update_standard_presets(signal_user_data_t *ud) gint64 build; gint type; - dict = ghb_array_get_nth(presetsPlist, ii); + dict = ghb_array_get_nth(presetsArray, ii); gval = ghb_dict_lookup(dict, "Type"); if (gval == NULL) { // Old preset that doesn't have a Type - replace_standard_presets(); + replace_standard_presets(presetsArray); return 1; } @@ -3230,7 +3066,7 @@ update_standard_presets(signal_user_data_t *ud) if (gval == NULL) { // Old preset that doesn't have a build number - replace_standard_presets(); + replace_standard_presets(presetsArray); return 1; } @@ -3238,7 +3074,7 @@ update_standard_presets(signal_user_data_t *ud) if (build != hb_get_build(NULL)) { // Build number does not match - replace_standard_presets(); + replace_standard_presets(presetsArray); return 1; } } @@ -3249,48 +3085,37 @@ update_standard_presets(signal_user_data_t *ud) void ghb_presets_load(signal_user_data_t *ud) { - presetsPlist = load_plist("presets"); - if (presetsPlist == NULL) + gboolean store = FALSE; + presetsPlistFile = load_plist("presets"); + if ((presetsPlistFile == NULL) || + (G_VALUE_TYPE(presetsPlistFile) == ghb_dict_get_type()) || + (check_old_presets(presetsPlistFile))) { - presetsPlist = ghb_value_dup(ghb_resource_get("standard-presets")); - import_xlat_presets(presetsPlist); - store_presets(); - } - else if (G_VALUE_TYPE(presetsPlist) == ghb_dict_get_type()) - { // Presets is older dictionary format. Convert to array - ghb_value_free(presetsPlist); - presetsPlist = ghb_value_dup(ghb_resource_get("standard-presets")); - import_xlat_presets(presetsPlist); - store_presets(); - } - else if (check_old_presets()) - { - ghb_value_free(presetsPlist); - presetsPlist = ghb_value_dup(ghb_resource_get("standard-presets")); - import_xlat_presets(presetsPlist); - store_presets(); + presetsPlistFile = ghb_resource_get("standard-presets"); + store = TRUE; } else { - if (!update_standard_presets(ud)) - import_xlat_presets(presetsPlist); + update_standard_presets(ud, presetsPlistFile); } + presetsPlist = ghb_value_dup(presetsPlistFile); + import_xlat_presets(presetsPlist); + if (store) + store_presets(); } static void settings_save(signal_user_data_t *ud, const GValue *path) { - GValue *dict, *internal; - GHashTableIter iter; - gchar *key; - GValue *value; + GValue *dict; gint *indices, len, count; gint *def_indices, def_len; const gchar *name; gboolean replace = FALSE; g_debug("settings_save"); + GValue *internalPlist = ghb_resource_get("internal-defaults"); if (internalPlist == NULL) return; count = ghb_array_len(path); name = g_value_get_string(ghb_array_get_nth(path, count-1)); @@ -3308,7 +3133,7 @@ settings_save(signal_user_data_t *ud, const GValue *path) g_free(message); return; } - dict = ghb_dict_value_new(); + dict = ghb_value_dup(ud->settings); ghb_presets_replace(presetsPlist, dict, indices, len); replace = TRUE; } @@ -3317,7 +3142,7 @@ settings_save(signal_user_data_t *ud, const GValue *path) indices = presets_find_pos(path, PRESETS_CUSTOM, &len); if (indices) { - dict = ghb_dict_value_new(); + dict = ghb_value_dup(ud->settings); ghb_presets_insert(presetsPlist, dict, indices, len); } else @@ -3327,41 +3152,9 @@ settings_save(signal_user_data_t *ud, const GValue *path) } } current_preset = dict; - ghb_settings_set_int64(ud->settings, "Type", PRESETS_CUSTOM); - ghb_settings_set_int64(ud->settings, "PresetBuildNumber", hb_get_build(NULL)); - - internal = plist_get_dict(internalPlist, "Presets"); - ghb_dict_iter_init(&iter, internal); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value)) - { - const GValue *gval; - - gval = ghb_settings_get_value(ud->settings, key); - if (gval == NULL) - { - continue; - } - ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(gval)); - } - internal = plist_get_dict(internalPlist, "XlatPresets"); - ghb_dict_iter_init(&iter, internal); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value)) - { - const GValue *gval; + ghb_settings_set_int64(dict, "Type", PRESETS_CUSTOM); + ghb_settings_set_int64(dict, "PresetBuildNumber", hb_get_build(NULL)); - gval = ghb_settings_get_value(ud->settings, key); - if (gval == NULL) - { - continue; - } - ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(gval)); - } ghb_dict_insert(dict, g_strdup("PresetName"), ghb_string_value_new(name)); if (replace) { @@ -3380,18 +3173,18 @@ settings_save(signal_user_data_t *ud, const GValue *path) ghb_boolean_value_new(FALSE)); presets_list_insert(ud, indices, len); } - if (!ghb_settings_get_boolean( ud->settings, "PictureWidthEnable")) + if (!ghb_settings_get_boolean(ud->settings, "PictureWidthEnable")) { ghb_dict_remove(dict, "PictureWidth"); } - if (!ghb_settings_get_boolean( ud->settings, "PictureHeightEnable")) + if (!ghb_settings_get_boolean(ud->settings, "PictureHeightEnable")) { ghb_dict_remove(dict, "PictureHeight"); } ghb_dict_insert(dict, g_strdup("autoscale"), ghb_boolean_value_new( - !ghb_settings_get_boolean( ud->settings, "PictureWidthEnable") && - !ghb_settings_get_boolean( ud->settings, "PictureHeightEnable") + !ghb_settings_get_boolean(ud->settings, "PictureWidthEnable") && + !ghb_settings_get_boolean(ud->settings, "PictureHeightEnable") ) ); diff --git a/gtk/src/presets.h b/gtk/src/presets.h index 845160ef7..add5eac2b 100644 --- a/gtk/src/presets.h +++ b/gtk/src/presets.h @@ -49,6 +49,7 @@ void ghb_write_pid_file(); GValue* ghb_get_current_preset(signal_user_data_t *ud); GValue* ghb_get_current_preset_path(signal_user_data_t *ud); void ghb_preset_to_settings(GValue *settings, GValue *preset); +void ghb_prefs_to_settings(GValue *settings); void dump_preset_path(const gchar *msg, const GValue *path); #endif // _GHB_PRESETS_H_ diff --git a/gtk/src/preview.c b/gtk/src/preview.c index 8cdf4eb3e..a63f61b2d 100644 --- a/gtk/src/preview.c +++ b/gtk/src/preview.c @@ -1278,14 +1278,13 @@ picture_settings_alt2_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) gtk_widget_set_tooltip_text(toggle, _("Hide the picture settings window while " "leaving the preview visible.")); - gtk_widget_show(window); } else { gtk_button_set_label(GTK_BUTTON(toggle), _("Show Settings")); gtk_widget_set_tooltip_text(toggle, _("Show picture settings.")); - gtk_widget_hide(window); } + gtk_widget_set_visible(window, !active); } G_MODULE_EXPORT void diff --git a/gtk/src/resources.c b/gtk/src/resources.c index 05ec53ec7..39c304011 100644 --- a/gtk/src/resources.c +++ b/gtk/src/resources.c @@ -40,3 +40,9 @@ ghb_resource_get(const gchar *name) result = ghb_dict_lookup(resources, name); return result; } + +void +ghb_resource_free() +{ + ghb_value_free(resources); +} diff --git a/gtk/src/resources.h b/gtk/src/resources.h index 59a1e499b..c9378acc4 100644 --- a/gtk/src/resources.h +++ b/gtk/src/resources.h @@ -17,6 +17,7 @@ #define _RESOURCES_H_ void ghb_resource_init(void); +void ghb_resource_free(); GValue* ghb_resource_get(const gchar *name); #endif // _RESOURCES_H_ diff --git a/gtk/src/settings.h b/gtk/src/settings.h index 9d28da729..0e871bc49 100644 --- a/gtk/src/settings.h +++ b/gtk/src/settings.h @@ -58,6 +58,7 @@ typedef struct gboolean scale_busy; gint cancel_encode; GtkBuilder *builder; + GValue *x264_priv; GValue *globals; GValue *prefs; GValue *settings; diff --git a/gtk/src/standard_presets.xml b/gtk/src/standard_presets.xml index a12deb619..6fe8cb396 100644 --- a/gtk/src/standard_presets.xml +++ b/gtk/src/standard_presets.xml @@ -1339,7 +1339,7 @@ <key>PictureHeight</key> <integer>720</integer> <key>PictureKeepRatio</key> - <integer>0</integer> + <integer>1</integer> <key>PictureLeftCrop</key> <integer>0</integer> <key>PictureModulus</key> diff --git a/gtk/src/x264handler.c b/gtk/src/x264handler.c index 753987954..51a523f25 100644 --- a/gtk/src/x264handler.c +++ b/gtk/src/x264handler.c @@ -217,7 +217,7 @@ x264_option_changed_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void x264_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - ghb_widget_to_setting(ud->settings, widget); + ghb_widget_to_setting(ud->x264_priv, widget); if (!ignore_options_update) { ignore_options_update = TRUE; @@ -231,7 +231,7 @@ x264_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void x264_slider_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - ghb_widget_to_setting(ud->settings, widget); + ghb_widget_to_setting(ud->x264_priv, widget); // Lock slider values to multiples of step_increment GtkAdjustment * adj = gtk_range_get_adjustment(GTK_RANGE(widget)); @@ -265,7 +265,7 @@ x264_me_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { gint me; - ghb_widget_to_setting(ud->settings, widget); + ghb_widget_to_setting(ud->x264_priv, widget); if (!ignore_options_update) { ignore_options_update = TRUE; @@ -275,7 +275,7 @@ x264_me_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_check_dependency(ud, widget, NULL); ghb_clear_presets_selection(ud); widget = GHB_WIDGET(ud->builder, "x264_merange"); - me = ghb_settings_combo_int(ud->settings, "x264_me"); + me = ghb_settings_combo_int(ud->x264_priv, "x264_me"); if (me < 2) { // me < umh // me_range 4 - 16 @@ -331,17 +331,6 @@ x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud) g_free(options); options = sopts; } -#if 0 - if (ghb_settings_get_boolean(ud->settings, "x264UseAdvancedOptions")) - { - ghb_ui_update(ud, "x264PresetSlider", ghb_int_value(5)); - ghb_ui_update(ud, "x264Tune", ghb_string_value("none")); - ghb_ui_update(ud, "h264Profile", ghb_string_value("auto")); - ghb_ui_update(ud, "h264Level", ghb_string_value("auto")); - - ghb_ui_update(ud, "x264OptionExtra", ghb_string_value(options)); - } -#endif g_free(options); ignore_options_update = FALSE; } @@ -523,7 +512,7 @@ x264_update_double(signal_user_data_t *ud, const gchar *name, const gchar *val) if (val == NULL) return; dval = g_strtod (val, NULL); - ghb_ui_update(ud, name, ghb_double_value(dval)); + ghb_settings_set_double(ud->x264_priv, name, dval); } static void @@ -533,7 +522,7 @@ x264_update_int(signal_user_data_t *ud, const gchar *name, const gchar *val) if (val == NULL) return; ival = g_strtod (val, NULL); - ghb_ui_update(ud, name, ghb_int64_value(ival)); + ghb_settings_set_int(ud->x264_priv, name, ival); } static void @@ -543,7 +532,7 @@ x264_update_int_setting(signal_user_data_t *ud, const gchar *name, const gchar * if (val == NULL) return; ival = g_strtod (val, NULL); - ghb_settings_set_value(ud->settings, name, ghb_int64_value(ival)); + ghb_settings_set_value(ud->x264_priv, name, ghb_int64_value(ival)); ghb_check_dependency(ud, NULL, name); } @@ -571,18 +560,18 @@ static void x264_update_bool(signal_user_data_t *ud, const gchar *name, const gchar *val) { if (val == NULL) - ghb_ui_update(ud, name, ghb_boolean_value(1)); + ghb_settings_set_boolean(ud->x264_priv, name, TRUE); else - ghb_ui_update(ud, name, ghb_boolean_value(str_is_true(val))); + ghb_settings_set_boolean(ud->x264_priv, name, str_is_true(val)); } static void x264_update_bool_setting(signal_user_data_t *ud, const gchar *name, const gchar *val) { if (val == NULL) - ghb_settings_set_value(ud->settings, name, ghb_boolean_value(1)); + ghb_settings_set_boolean(ud->x264_priv, name, TRUE); else - ghb_settings_set_value(ud->settings, name, ghb_boolean_value(str_is_true(val))); + ghb_settings_set_boolean(ud->x264_priv, name, str_is_true(val)); ghb_check_dependency(ud, NULL, name); } @@ -590,64 +579,13 @@ x264_update_bool_setting(signal_user_data_t *ud, const gchar *name, const gchar static void x264_update_combo(signal_user_data_t *ud, const gchar *name, const gchar *val) { - GtkTreeModel *store; - GtkTreeIter iter; - gchar *shortOpt; - gdouble ivalue; - gboolean foundit = FALSE; - GtkWidget *widget; - - if (val == NULL) return; - widget = GHB_WIDGET(ud->builder, name); - if (widget == NULL) - { - g_debug("Failed to find widget for key: %s\n", name); - return; - } - store = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); - if (gtk_tree_model_get_iter_first (store, &iter)) - { - do - { - gtk_tree_model_get(store, &iter, 2, &shortOpt, 3, &ivalue, -1); - if (strcmp(shortOpt, val) == 0) - { - gtk_combo_box_set_active_iter (GTK_COMBO_BOX(widget), &iter); - g_free(shortOpt); - foundit = TRUE; - break; - } - g_free(shortOpt); - } while (gtk_tree_model_iter_next (store, &iter)); - } - if (!foundit) - { - if (gtk_tree_model_get_iter_first (store, &iter)) - { - do - { - gtk_tree_model_get(store, &iter, 2, &shortOpt, 3, &ivalue, -1); - if (strcmp(shortOpt, "custom") == 0) - { - gtk_list_store_set(GTK_LIST_STORE(store), &iter, 4, val, -1); - gtk_combo_box_set_active_iter (GTK_COMBO_BOX(widget), &iter); - g_free(shortOpt); - foundit = TRUE; - break; - } - g_free(shortOpt); - } while (gtk_tree_model_iter_next (store, &iter)); - } - } - // Its possible the value hasn't changed. Since settings are only - // updated when the value changes, I'm initializing settings here as well. - ghb_widget_to_setting(ud->settings, widget); + ghb_settings_set_string(ud->x264_priv, name, val); } static void x264_update_deblock(signal_user_data_t *ud, const gchar *xval) { - gdouble avalue, bvalue; + int avalue, bvalue; gchar *end; gchar *val; gchar *bval = NULL; @@ -663,15 +601,15 @@ x264_update_deblock(signal_user_data_t *ud, const gchar *xval) bval = pos + 1; *pos = 0; } - avalue = g_strtod (val, &end); + avalue = (int)g_strtod(val, &end); if (bval != NULL) { - bvalue = g_strtod (bval, &end); + bvalue = (int)g_strtod(bval, &end); } } g_free(val); - ghb_ui_update(ud, "x264_deblock_alpha", ghb_int64_value(avalue)); - ghb_ui_update(ud, "x264_deblock_beta", ghb_int64_value(bvalue)); + ghb_settings_set_int(ud->x264_priv, "x264_deblock_alpha", avalue); + ghb_settings_set_int(ud->x264_priv, "x264_deblock_beta", bvalue); } static void @@ -693,8 +631,8 @@ x264_update_psy(signal_user_data_t *ud, const gchar *xval) if (xval == NULL) return; x264_parse_psy(xval, &rd_value, &trell_value); - ghb_ui_update(ud, "x264_psy_rd", ghb_double_value(rd_value)); - ghb_ui_update(ud, "x264_psy_trell", ghb_double_value(trell_value)); + ghb_settings_set_double(ud->x264_priv, "x264_psy_rd", rd_value); + ghb_settings_set_double(ud->x264_priv, "x264_psy_trell", trell_value); } static void do_update(signal_user_data_t *ud, char *name, gint type, char *val) @@ -852,6 +790,7 @@ ghb_x264_parse_options(signal_user_data_t *ud, const gchar *options) } } g_strfreev(split); + ghb_settings_to_ui(ud, ud->x264_priv); } gchar* @@ -859,8 +798,8 @@ get_deblock_val(signal_user_data_t *ud) { gchar *alpha, *beta; gchar *result; - alpha = ghb_settings_get_string(ud->settings, "x264_deblock_alpha"); - beta = ghb_settings_get_string(ud->settings, "x264_deblock_beta"); + alpha = ghb_settings_get_string(ud->x264_priv, "x264_deblock_alpha"); + beta = ghb_settings_get_string(ud->x264_priv, "x264_deblock_beta"); result = g_strdup_printf("%s,%s", alpha, beta); g_free(alpha); g_free(beta); @@ -872,8 +811,8 @@ get_psy_val(signal_user_data_t *ud) { gdouble rd, trell; gchar *result; - rd = ghb_settings_get_double(ud->settings, "x264_psy_rd"); - trell = ghb_settings_get_double(ud->settings, "x264_psy_trell"); + rd = ghb_settings_get_double(ud->x264_priv, "x264_psy_rd"); + trell = ghb_settings_get_double(ud->x264_priv, "x264_psy_trell"); result = g_strdup_printf("%g|%g", rd, trell); return result; } @@ -1200,12 +1139,12 @@ sanitize_x264opts(signal_user_data_t *ud, const gchar *options) gint ii; // Fix up option dependencies - gint subme = ghb_settings_combo_int(ud->settings, "x264_subme"); + gint subme = ghb_settings_combo_int(ud->x264_priv, "x264_subme"); if (subme < 6) { x264_remove_opt(split, x264_psy_syns); } - gint trell = ghb_settings_combo_int(ud->settings, "x264_trellis"); + gint trell = ghb_settings_combo_int(ud->x264_priv, "x264_trellis"); if (subme >= 10) { gint aqmode = ghb_lookup_aqmode(options); @@ -1233,7 +1172,7 @@ sanitize_x264opts(signal_user_data_t *ud, const gchar *options) split[psy] = g_strdup_printf("psy-rd=%g|0", psy_rd); } } - gint bframes = ghb_settings_get_int(ud->settings, "x264_bframes"); + gint bframes = ghb_settings_get_int(ud->x264_priv, "x264_bframes"); if (bframes == 0) { x264_remove_opt(split, x264_direct_syns); @@ -1321,3 +1260,9 @@ format_x264_preset_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud) return g_strdup_printf(" %-12s", preset); } +void +ghb_x264_init(signal_user_data_t *ud) +{ + ud->x264_priv = ghb_settings_new(); + ghb_x264_parse_options(ud, ""); +} diff --git a/gtk/src/x264handler.h b/gtk/src/x264handler.h index a29c2626c..1e1220d55 100644 --- a/gtk/src/x264handler.h +++ b/gtk/src/x264handler.h @@ -27,6 +27,7 @@ #include "settings.h" +void ghb_x264_init(signal_user_data_t *ud); void ghb_x264_parse_options(signal_user_data_t *ud, const gchar *options); gint ghb_lookup_badapt(const gchar *options); void ghb_show_hide_advanced_video( signal_user_data_t *ud ); |