]> granicus.if.org Git - handbrake/commitdiff
LinGui: Add UI support for BradleyS' sharpen filters
authorJohn Stebbins <jstebbins.hb@gmail.com>
Fri, 26 May 2017 21:16:18 +0000 (14:16 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Tue, 30 May 2017 18:20:42 +0000 (11:20 -0700)
gtk/src/callbacks.c
gtk/src/ghb.m4
gtk/src/hb-backend.c
gtk/src/makedeps.py

index 4cddf663db3e70ace29d721c2ed214f19eacd62d..c195a258436104a60d37c079cbd9c1977ae257b9 100644 (file)
@@ -2190,6 +2190,20 @@ denoise_filter_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
                   ghb_dict_get(ud->settings, "PictureDenoisePreset"));
 }
 
+G_MODULE_EXPORT void
+sharpen_filter_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+    ghb_widget_to_setting(ud->settings, widget);
+    ghb_check_dependency(ud, widget, NULL);
+    ghb_clear_presets_selection(ud);
+    ghb_live_reset(ud);
+    ghb_update_ui_combo_box(ud, "PictureSharpenPreset", NULL, FALSE);
+    ghb_update_ui_combo_box(ud, "PictureSharpenTune", NULL, FALSE);
+    ghb_ui_update(ud, "PictureSharpenPreset",
+                  ghb_dict_get(ud->settings, "PictureSharpenPreset"));
+    ghb_ui_update(ud, "PictureSharpenTune", ghb_string_value("none"));
+}
+
 G_MODULE_EXPORT void
 title_angle_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
index 5895743dc48e84ea2158f93e2669e177cdfd2e4c..1f3d279c23ba7695ad8eb74d62530e9c1a2757b0 100644 (file)
@@ -3307,6 +3307,140 @@ ifelse(eval(gtk_version < 312), 1, filter_output([
                             <property name="height">1</property>
                           </packing>
 ]))dnl
+filter_output([
+                        </child>
+                        <child>
+                          <object class="GtkGrid" id="SharpenTable">
+                            <property name="row-spacing">2</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="column_spacing">5</property>
+                            <property name="halign">start</property>
+                            <property name="valign">start</property>
+                            <child>
+                              <object class="GtkLabel" id="PictureSharpenFilterel">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="label" translatable="yes">Sharpen Filter:</property>
+                              </object>
+                              <packing>
+                                <property name="top_attach">0</property>
+                                <property name="left_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="PictureSharpenFilter">
+                                <property name="valign">GTK_ALIGN_CENTER</property>
+                                <property name="width_request">100</property>
+                                <property name="visible">True</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>
+                                <property name="tooltip_text" translatable="yes">Sharpen filtering enhances edges and other
+high frequency components in the video.</property>
+                                <signal name="changed" handler="sharpen_filter_changed_cb" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="top_attach">0</property>
+                                <property name="left_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="PictureSharpenPresetLabel">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="label" translatable="yes">Sharpen Preset:</property>
+                              </object>
+                              <packing>
+                                <property name="top_attach">1</property>
+                                <property name="left_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="PictureSharpenPreset">
+                                <property name="valign">GTK_ALIGN_CENTER</property>
+                                <property name="width_request">100</property>
+                                <property name="visible">True</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>
+                                <property name="tooltip_text" translatable="yes">Sharpen filtering enhances edges and other
+high frequency components in the video.</property>
+                                <signal name="changed" handler="setting_widget_changed_cb" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="top_attach">1</property>
+                                <property name="left_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="PictureSharpenTuneLabel">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="label" translatable="yes">Sharpen Tune:</property>
+                              </object>
+                              <packing>
+                                <property name="top_attach">2</property>
+                                <property name="left_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="PictureSharpenTune">
+                                <property name="valign">GTK_ALIGN_CENTER</property>
+                                <property name="width_request">100</property>
+                                <property name="visible">True</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>
+                                <property name="tooltip_text" translatable="yes">Sharpen filtering enhances edges and other
+high frequency components in the video.</property>
+                                <signal name="changed" handler="setting_widget_changed_cb" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="top_attach">2</property>
+                                <property name="left_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="PictureSharpenCustom">
+                                <property name="can_focus">True</property>
+                                <property name="tooltip_text" translatable="yes">Custom denoise filter string format
+
+SpatialLuma:SpatialChroma:TemporalLuma:TemporalChroma</property>
+                                <property name="width_chars">8</property>
+                                <property name="primary_icon_activatable">False</property>
+                                <property name="secondary_icon_activatable">False</property>
+                                <signal name="changed" handler="setting_widget_changed_cb" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="top_attach">3</property>
+                                <property name="left_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                          </object>
+])dnl
+ifelse(eval(gtk_version < 312), 1, filter_output([
+                          <packing>
+                            <property name="top_attach">1</property>
+                            <property name="left_attach">2</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
+]))dnl
 filter_output([
                         </child>
                         <child>
@@ -3353,7 +3487,7 @@ filter_output([
 ifelse(eval(gtk_version < 312), 1, filter_output([
                           <packing>
                             <property name="top_attach">1</property>
-                            <property name="left_attach">2</property>
+                            <property name="left_attach">3</property>
                             <property name="width">1</property>
                             <property name="height">1</property>
                           </packing>
@@ -3377,7 +3511,7 @@ filter_output([
 ifelse(eval(gtk_version < 312), 1, filter_output([
                           <packing>
                             <property name="top_attach">1</property>
-                            <property name="left_attach">3</property>
+                            <property name="left_attach">4</property>
                             <property name="width">1</property>
                             <property name="height">1</property>
                           </packing>
index 38e22eca71c8686b60581168ecae3a9f787428e2..ec819895c427fafebb647fcb9ce1c56f1c284771 100644 (file)
@@ -220,6 +220,18 @@ combo_opts_t denoise_opts =
     d_denoise_opts
 };
 
+static options_map_t d_sharpen_opts[] =
+{
+    {N_("Off"),      "off",      HB_FILTER_INVALID},
+    {N_("Unsharp"),  "unsharp",  HB_FILTER_UNSHARP},
+    {N_("Lapsharp"), "lapsharp", HB_FILTER_LAPSHARP },
+};
+combo_opts_t sharpen_opts =
+{
+    sizeof(d_sharpen_opts)/sizeof(options_map_t),
+    d_sharpen_opts
+};
+
 static options_map_t d_rotate_opts[] =
 {
     {N_("Off"),         "disable=1",   0},
@@ -367,6 +379,18 @@ static filter_opts_t nlmeans_tune_opts =
     .preset    = FALSE
 };
 
+static filter_opts_t sharpen_preset_opts =
+{
+    .filter_id = HB_FILTER_UNSHARP,
+    .preset    = TRUE
+};
+
+static filter_opts_t sharpen_tune_opts =
+{
+    .filter_id = HB_FILTER_UNSHARP,
+    .preset    = FALSE
+};
+
 #if 0
 static filter_opts_t hqdn3d_preset_opts =
 {
@@ -439,6 +463,8 @@ static void deint_opts_set(signal_user_data_t *ud, const gchar *name,
                            void *vopts, const void* data);
 static void denoise_opts_set(signal_user_data_t *ud, const gchar *name,
                              void *vopts, const void* data);
+static void sharpen_opts_set(signal_user_data_t *ud, const gchar *name,
+                             void *vopts, const void* data);
 
 static GhbValue * generic_opt_get(const char *name, const void *opts,
                                   const GhbValue *gval, GhbType type);
@@ -555,6 +581,24 @@ combo_name_map_t combo_name_map[] =
         filter_opts_set,
         filter_opt_get
     },
+    {
+        "PictureSharpenFilter",
+        &sharpen_opts,
+        small_opts_set,
+        generic_opt_get
+    },
+    {
+        "PictureSharpenPreset",
+        &sharpen_preset_opts,
+        sharpen_opts_set,
+        filter_opt_get
+    },
+    {
+        "PictureSharpenTune",
+        &sharpen_tune_opts,
+        sharpen_opts_set,
+        filter_opt_get
+    },
     {
         "PictureRotate",
         &rotate_opts,
@@ -2575,6 +2619,21 @@ denoise_opts_set(signal_user_data_t *ud, const gchar *name,
                                   "denoise", opts->filter_id);
 }
 
+static void
+sharpen_opts_set(signal_user_data_t *ud, const gchar *name,
+               void *vopts, const void* data)
+{
+    (void)data;  // Silence "unused variable" warning
+
+    filter_opts_t *opts = (filter_opts_t*)vopts;
+    opts->filter_id = ghb_settings_combo_int(ud->settings,
+                                             "PictureSharpenFilter");
+    filter_opts_set2(ud, name, opts->filter_id, opts->preset);
+
+    ghb_set_custom_filter_tooltip(ud, "PictureSharpenCustom",
+                                  "sharpen", opts->filter_id);
+}
+
 combo_name_map_t*
 find_combo_map(const gchar *name)
 {
index 3641b79e8a1c57efca15d110875258ba2a5f6fe3..5ff09304e2522640fe0e2c14b0584ee876e6aea9 100644 (file)
@@ -41,6 +41,15 @@ dep_map = (
     DepEntry("PictureDenoisePreset", "PictureDenoiseCustom", "custom", False, True),
     DepEntry("PictureDenoisePreset", "PictureDenoiseTune", "custom", True, True),
     DepEntry("PictureDenoisePreset", "PictureDenoiseTuneLabel", "custom", True, True),
+
+    DepEntry("PictureSharpenFilter", "PictureSharpenPreset", "off", True, True),
+    DepEntry("PictureSharpenFilter", "PictureSharpenPresetLabel", "off", True, True),
+    DepEntry("PictureSharpenFilter", "PictureSharpenTune", "off", True, True),
+    DepEntry("PictureSharpenFilter", "PictureSharpenTuneLabel", "off", True, True),
+    DepEntry("PictureSharpenFilter", "PictureSharpenCustom", "off", True, True),
+    DepEntry("PictureSharpenPreset", "PictureSharpenCustom", "custom", False, True),
+    DepEntry("PictureSharpenPreset", "PictureSharpenTune", "custom", True, True),
+    DepEntry("PictureSharpenPreset", "PictureSharpenTuneLabel", "custom", True, True),
     DepEntry("PictureDetelecine", "PictureDetelecineCustom", "custom", False, True),
     DepEntry("PictureWidthEnable", "PictureWidth", "1", False, False),
     DepEntry("PictureHeightEnable", "PictureHeight", "1", False, False),