From 212b4a9f3cdc1e4a0bdf6c99202c2e58537c7af7 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Thu, 21 Aug 2008 00:43:46 +0000 Subject: LinGui: add a hidden feature to allow tweaking some settings. currently tweaks are available for detelecine, decomb, deinterlace, deblock, and denoise to enable, you must manually edit preferences file and add "allow_tweaks=1" to tweak a setting, right click on the widget, an entry dialog will appear. minimal validity checking is done on the tweak's value. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1648 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- gtk/src/callbacks.c | 64 +++++++++++++++++++ gtk/src/ghb.ui | 135 +++++++++++++++++++++++++++++++++++++--- gtk/src/hb-backend.c | 148 ++++++++++++++++++++++++++++++++++++++++++++ gtk/src/hb-backend.h | 2 + gtk/src/internal_defaults | 9 ++- gtk/src/internal_defaults.h | 9 ++- gtk/src/main.c | 6 +- 7 files changed, 357 insertions(+), 16 deletions(-) (limited to 'gtk/src') diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index df6a17b55..803737241 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -2471,6 +2471,11 @@ validate_settings(signal_user_data_t *ud) { return FALSE; } + // Validate filter settings + if (!ghb_validate_filters(ud)) + { + return FALSE; + } audio_list_refresh(ud); return TRUE; } @@ -3510,3 +3515,62 @@ ghb_hal_init() //gvm_hal_claim_branch ("/org/freedesktop/Hal/devices/local"); } +gboolean +tweak_setting_cb( + GtkWidget *widget, + GdkEventButton *event, + signal_user_data_t *ud) +{ + const gchar *name; + gchar *tweak_name; + gboolean ret = FALSE; + gboolean allow_tweaks; + + g_debug("press %d %d", event->type, event->button); + allow_tweaks = ghb_settings_get_bool (ud->settings, "allow_tweaks"); + if (allow_tweaks && event->type == GDK_BUTTON_PRESS && event->button == 3) + { // Its a right mouse click + GtkWidget *dialog; + GtkEntry *entry; + GtkResponseType response; + const gchar *tweak = NULL; + + name = gtk_widget_get_name(widget); + if (g_str_has_prefix(name, "tweak_")) + { + tweak_name = g_strdup(name); + } + else + { + tweak_name = g_strdup_printf("tweak_%s", name); + } + + tweak = ghb_settings_get_string (ud->settings, tweak_name); + dialog = GHB_WIDGET(ud->builder, "tweak_dialog"); + gtk_window_set_title(GTK_WINDOW(dialog), tweak_name); + entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "tweak_setting")); + if (tweak) + gtk_entry_set_text(entry, tweak); + response = gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_hide(dialog); + if (response == GTK_RESPONSE_OK) + { + tweak = gtk_entry_get_text(entry); + if (ghb_validate_filter_string(tweak, -1)) + ghb_settings_set_string(ud->settings, tweak_name, tweak); + else + { + gchar *message; + message = g_strdup_printf( + "Invalid Settings:\n%s", + tweak); + ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); + g_free(message); + } + } + g_free(tweak_name); + ret = TRUE; + } + return ret; +} + diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 6af322955..594388be3 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -1311,6 +1311,7 @@ Detelecine True + 1 @@ -1325,6 +1326,7 @@ True True + False @@ -1339,6 +1341,7 @@ Deblock True + False @@ -1350,12 +1353,22 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Deinterlace: - 10 + False + True + + + + True + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Deinterlace: + 10 + + False @@ -1366,6 +1379,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False @@ -1384,12 +1398,21 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Denoise: - 10 + False + True + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Denoise: + 10 + + False @@ -1400,6 +1423,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False @@ -3412,6 +3436,97 @@ this setting. pref_ok + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + True + GTK_WIN_POS_CENTER_ON_PARENT + GDK_WINDOW_TYPE_HINT_DIALOG + False + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Setting: + + + False + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 40 + True + 30 + True + + + False + 1 + + + + + False + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_BUTTONBOX_END + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-cancel + True + + + + + True + True + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-ok + True + + + 1 + + + + + False + GTK_PACK_END + + + + + + tweak_cancel + tweak_ok + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 57e1a857c..376166426 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -2023,6 +2023,107 @@ ghb_guess_bitrate(GHashTable *settings) return bitrate; } +gboolean +ghb_validate_filter_string(const gchar *str, gint max_fields) +{ + gint fields = 0; + gboolean in_field = FALSE; + if (str == NULL || *str == 0) return TRUE; + while (*str) + { + if (*str >= '0' && *str <= '9') + { + if (!in_field) + { + fields++; + // negative max_fields means infinate + if (max_fields >= 0 && fields > max_fields) return FALSE; + in_field = TRUE; + } + } + else if (!in_field) return FALSE; + else if (*str != ':') return FALSE; + else in_field = FALSE; + str++; + } + return TRUE; +} + +gboolean +ghb_validate_filters(signal_user_data_t *ud) +{ + gboolean tweaks; + const gchar *str; + gchar *message; + gboolean enabled; + + tweaks = ghb_settings_get_bool(ud->settings, "allow_tweaks"); + if (tweaks) + { + // detele 6 + str = ghb_settings_get_string(ud->settings, "tweak_detelecine"); + enabled = ghb_settings_get_bool(ud->settings, "detelecine"); + if (enabled && !ghb_validate_filter_string(str, 6)) + { + message = g_strdup_printf( + "Invalid Detelecine Settings:\n\n%s\n", + str); + ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); + g_free(message); + return FALSE; + } + // decomb 7 + str = ghb_settings_get_string(ud->settings, "tweak_decomb"); + enabled = ghb_settings_get_bool(ud->settings, "decomb"); + if (enabled && !ghb_validate_filter_string(str, 7)) + { + message = g_strdup_printf( + "Invalid Decomb Settings:\n\n%s\n", + str); + ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); + g_free(message); + return FALSE; + } + // deinte 4 + str = ghb_settings_get_string(ud->settings, "tweak_deinterlace"); + enabled = ghb_settings_get_bool(ud->settings, "deinterlace"); + if (enabled && !ghb_validate_filter_string(str, 4)) + { + message = g_strdup_printf( + "Invalid Deinterlace Settings:\n\n%s\n", + str); + ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); + g_free(message); + return FALSE; + } + // debloc 2 + str = ghb_settings_get_string(ud->settings, "tweak_deblock"); + enabled = ghb_settings_get_bool(ud->settings, "deblock"); + if (enabled && !ghb_validate_filter_string(str, 2)) + { + message = g_strdup_printf( + "Invalid Deblock Settings:\n\n%s\n", + str); + ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); + g_free(message); + return FALSE; + } + // denois 4 + str = ghb_settings_get_string(ud->settings, "tweak_denoise"); + enabled = ghb_settings_get_bool(ud->settings, "denoise"); + if (enabled && !ghb_validate_filter_string(str, 4)) + { + message = g_strdup_printf( + "Invalid Denoise Settings:\n\n%s\n", + str); + ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); + g_free(message); + return FALSE; + } + } + return TRUE; +} + gboolean ghb_validate_video(signal_user_data_t *ud) { @@ -2363,6 +2464,7 @@ ghb_add_job(job_settings_t *js, gint unique_id) GHashTable *settings = js->settings; static gchar *x264opts; gint sub_id = 0; + gboolean tweaks = FALSE; g_debug("ghb_add_job()\n"); if (h == NULL) return; @@ -2382,6 +2484,7 @@ ghb_add_job(job_settings_t *js, gint unique_id) job = title->job; if (job == NULL) return; + tweaks = ghb_settings_get_int(settings, "allow_tweaks"); job->mux = ghb_settings_get_int(settings, "container"); if (job->mux == HB_MUX_MP4) { @@ -2465,28 +2568,73 @@ ghb_add_job(job_settings_t *js, gint unique_id) if( ghb_settings_get_bool(settings, "detelecine" ) || job->vfr ) { hb_filter_detelecine.settings = NULL; + if (tweaks) + { + const gchar *str; + str = ghb_settings_get_string(settings, "tweak_detelecine"); + if (str && str[0]) + { + hb_filter_detelecine.settings = (gchar*)str; + } + } hb_list_add( job->filters, &hb_filter_detelecine ); } if( decomb ) { // Use default settings hb_filter_decomb.settings = NULL; + if (tweaks) + { + const gchar *str; + str = ghb_settings_get_string(settings, "tweak_decomb"); + if (str && str[0]) + { + hb_filter_decomb.settings = (gchar*)str; + } + } hb_list_add( job->filters, &hb_filter_decomb ); } if( job->deinterlace ) { hb_filter_deinterlace.settings = (gchar*)ghb_settings_get_string(settings, "deinterlace"); + if (tweaks) + { + const gchar *str; + str = ghb_settings_get_string(settings, "tweak_deinterlace"); + if (str && str[0]) + { + hb_filter_deinterlace.settings = (gchar*)str; + } + } hb_list_add( job->filters, &hb_filter_deinterlace ); } if( ghb_settings_get_bool(settings, "deblock") ) { hb_filter_deblock.settings = NULL; + if (tweaks) + { + const gchar *str; + str = ghb_settings_get_string(settings, "tweak_deblock"); + if (str && str[0]) + { + hb_filter_deblock.settings = (gchar*)str; + } + } hb_list_add( job->filters, &hb_filter_deblock ); } gint denoise = ghb_settings_get_int(settings, "denoise"); if( denoise != 0 ) { hb_filter_denoise.settings = (gchar*)ghb_settings_get_string(settings, "denoise"); + if (tweaks) + { + const gchar *str; + str = ghb_settings_get_string(settings, "tweak_denoise"); + if (str && str[0]) + { + hb_filter_denoise.settings = (gchar*)str; + } + } hb_list_add( job->filters, &hb_filter_denoise ); } job->width = ghb_settings_get_int(settings, "scale_width"); diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 1b7e641c5..eaf4e4c56 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -118,6 +118,8 @@ gboolean ghb_validate_container(signal_user_data_t *ud); gboolean ghb_validate_vquality(GHashTable *settings); gboolean ghb_validate_audio(signal_user_data_t *ud); gboolean ghb_validate_video(signal_user_data_t *ud); +gboolean ghb_validate_filters(signal_user_data_t *ud); +gboolean ghb_validate_filter_string(const gchar *str, gint max_fields); void ghb_hb_cleanup(gboolean partial); gint ghb_lookup_acodec(const gchar *acodec); gint ghb_lookup_bitrate(const gchar *bitrate); diff --git a/gtk/src/internal_defaults b/gtk/src/internal_defaults index 19ac6fefe..4fb15f229 100644 --- a/gtk/src/internal_defaults +++ b/gtk/src/internal_defaults @@ -23,8 +23,13 @@ detelecine=enable decomb=enable deinterlace=none denoise=none -grayscale=disable deblock=disable +tweak_decomb= +tweak_detelecine= +tweak_deblock= +tweak_deinterlace= +tweak_denoise= +grayscale=disable video_codec=x264 two_pass=disable turbo=enable @@ -82,5 +87,5 @@ show_presets=enable linear_vquality=disable noscale=disable nocheckvquality=disable - +allow_tweaks=disable diff --git a/gtk/src/internal_defaults.h b/gtk/src/internal_defaults.h index 13ffbe144..fbd2d3506 100644 --- a/gtk/src/internal_defaults.h +++ b/gtk/src/internal_defaults.h @@ -23,8 +23,13 @@ "decomb=enable\n" "deinterlace=none\n" "denoise=none\n" -"grayscale=disable\n" "deblock=disable\n" +"tweak_decomb=\n" +"tweak_detelecine=\n" +"tweak_deblock=\n" +"tweak_deinterlace=\n" +"tweak_denoise=\n" +"grayscale=disable\n" "video_codec=x264\n" "two_pass=disable\n" "turbo=enable\n" @@ -82,5 +87,5 @@ "linear_vquality=disable\n" "noscale=disable\n" "nocheckvquality=disable\n" -"\n" +"allow_tweaks=disable\n" "\n" diff --git a/gtk/src/main.c b/gtk/src/main.c index 53b71d953..18d64da13 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -166,8 +166,10 @@ MyConnect( g_return_if_fail(handler_name != NULL); g_return_if_fail(signal_name != NULL); - g_debug("handler_name %s\n", handler_name); - g_debug("signal_name %s\n", signal_name); + //const gchar *name = gtk_widget_get_name((GtkWidget*)object); + //g_message("\n\nname %s", name); + g_debug("handler_name %s", handler_name); + g_debug("signal_name %s", signal_name); callback = self_symbol_lookup(handler_name); if (!callback) { -- cgit v1.2.3