From 66a364099807593f50226c811dc3345ed4d5371a Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Fri, 26 May 2017 14:16:18 -0700 Subject: [PATCH] LinGui: Add UI support for BradleyS' sharpen filters --- gtk/src/callbacks.c | 14 +++++ gtk/src/ghb.m4 | 138 ++++++++++++++++++++++++++++++++++++++++++- gtk/src/hb-backend.c | 59 ++++++++++++++++++ gtk/src/makedeps.py | 9 +++ 4 files changed, 218 insertions(+), 2 deletions(-) diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 4cddf663d..c195a2584 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -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) { diff --git a/gtk/src/ghb.m4 b/gtk/src/ghb.m4 index 5895743dc..1f3d279c2 100644 --- a/gtk/src/ghb.m4 +++ b/gtk/src/ghb.m4 @@ -3307,6 +3307,140 @@ ifelse(eval(gtk_version < 312), 1, filter_output([ 1 ]))dnl +filter_output([ + + + + 2 + True + False + 5 + start + start + + + True + False + start + Sharpen Filter: + + + 0 + 0 + 1 + 1 + + + + + GTK_ALIGN_CENTER + 100 + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Sharpen filtering enhances edges and other +high frequency components in the video. + + + + 0 + 1 + 1 + 1 + + + + + True + False + start + Sharpen Preset: + + + 1 + 0 + 1 + 1 + + + + + GTK_ALIGN_CENTER + 100 + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Sharpen filtering enhances edges and other +high frequency components in the video. + + + + 1 + 1 + 1 + 1 + + + + + True + False + start + Sharpen Tune: + + + 2 + 0 + 1 + 1 + + + + + GTK_ALIGN_CENTER + 100 + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Sharpen filtering enhances edges and other +high frequency components in the video. + + + + 2 + 1 + 1 + 1 + + + + + True + Custom denoise filter string format + +SpatialLuma:SpatialChroma:TemporalLuma:TemporalChroma + 8 + False + False + + + + 3 + 1 + 1 + 1 + + + +])dnl +ifelse(eval(gtk_version < 312), 1, filter_output([ + + 1 + 2 + 1 + 1 + +]))dnl filter_output([ @@ -3353,7 +3487,7 @@ filter_output([ ifelse(eval(gtk_version < 312), 1, filter_output([ 1 - 2 + 3 1 1 @@ -3377,7 +3511,7 @@ filter_output([ ifelse(eval(gtk_version < 312), 1, filter_output([ 1 - 3 + 4 1 1 diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 38e22eca7..ec819895c 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -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) { diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py index 3641b79e8..5ff09304e 100644 --- a/gtk/src/makedeps.py +++ b/gtk/src/makedeps.py @@ -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), -- 2.40.0