diff options
author | jstebbins <[email protected]> | 2014-02-23 18:59:42 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2014-02-23 18:59:42 +0000 |
commit | 45bee35a201f51f72c62ee89fa4b287ea35493d5 (patch) | |
tree | 0a50bf18aace48db349e5fbf196823e12fbc4568 /gtk/src | |
parent | 4107d15473cc537593d6d7b74cb8bc54e834c8e7 (diff) |
LinGui: rework how hb containers are refrenced from lingui
Cleans up the interface and fixes failure to use fallbacks properly.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6067 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/audiohandler.c | 53 | ||||
-rw-r--r-- | gtk/src/callbacks.c | 29 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 192 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 3 | ||||
-rw-r--r-- | gtk/src/preset_xlat.c | 627 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 14 | ||||
-rw-r--r-- | gtk/src/subtitlehandler.c | 78 | ||||
-rw-r--r-- | gtk/src/widgetdeps.c | 142 |
8 files changed, 162 insertions, 976 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index 49fb770d3..c5586b926 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -191,9 +191,14 @@ int ghb_select_fallback(GValue *settings, int acodec) default: { - int mux = ghb_settings_combo_int(settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); + fallback = ghb_settings_combo_int(settings, "AudioEncoderFallback"); - return hb_autopassthru_get_encoder(acodec, 0, fallback, mux); + return hb_autopassthru_get_encoder(acodec, 0, fallback, mux->format); } } } @@ -205,12 +210,15 @@ audio_sanitize_settings(GValue *settings, GValue *asettings) gint titleindex, track, acodec, select_acodec, mix; const hb_title_t *title; hb_audio_config_t *aconfig; - gint mux; gint bitrate; gint sr; - g_debug("ghb_santiize_audio ()"); - mux = ghb_settings_combo_int(settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); + title_id = ghb_settings_get_int(settings, "title"); title = ghb_lookup_title(title_id, &titleindex); track = ghb_settings_get_int(asettings, "AudioTrack"); @@ -226,7 +234,7 @@ audio_sanitize_settings(GValue *settings, GValue *asettings) } gint fallback = ghb_select_fallback(settings, acodec); gint copy_mask = ghb_get_copy_mask(settings); - select_acodec = ghb_select_audio_codec(mux, aconfig, acodec, + select_acodec = ghb_select_audio_codec(mux->format, aconfig, acodec, fallback, copy_mask); if (ghb_audio_is_passthru (select_acodec)) { @@ -277,12 +285,15 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) hb_audio_config_t *aconfig; GtkWidget *widget; GValue *gval; - gint mux; gint bitrate; gint sr = 48000; - g_debug("ghb_adjust_audio_rate_combos ()"); - mux = ghb_settings_combo_int(ud->settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); + title_id = ghb_settings_get_int(ud->settings, "title"); title = ghb_lookup_title(title_id, &titleindex); @@ -318,7 +329,8 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) } gint fallback = ghb_select_fallback(ud->settings, acodec); gint copy_mask = ghb_get_copy_mask(ud->settings); - select_acodec = ghb_select_audio_codec(mux, aconfig, acodec, fallback, copy_mask); + select_acodec = ghb_select_audio_codec(mux->format, aconfig, acodec, + fallback, copy_mask); gboolean codec_defined_bitrate = FALSE; if (ghb_audio_is_passthru (select_acodec)) { @@ -504,12 +516,17 @@ audio_select_and_add_track( GValue *audio, *asettings = NULL; gdouble drc, gain, quality; gboolean enable_quality; - gint track, mux, acodec, bitrate, samplerate, mix; + gint track, acodec, bitrate, samplerate, mix; gint select_acodec; gint fallback; - mux = ghb_settings_combo_int(settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); + gint copy_mask = ghb_get_copy_mask(settings); audio = ghb_array_get_nth(pref_audio, pref_index); @@ -535,7 +552,7 @@ audio_select_and_add_track( hb_audio_config_t *aconfig; aconfig = hb_list_audio_config_item(title->list_audio, track); select_acodec = ghb_select_audio_codec( - mux, aconfig, acodec, fallback, copy_mask); + mux->format, aconfig, acodec, fallback, copy_mask); asettings = audio_add_track(settings, title, track, select_acodec, enable_quality, quality, bitrate, @@ -554,11 +571,15 @@ static void set_pref_audio_with_lang( { const GValue *pref_audio, *audio_list; int count, ii, track, track_count, audio_count; - gint mux; audio_list = ghb_settings_get_value(settings, "audio_list"); - mux = ghb_settings_combo_int(settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); + pref_audio = ghb_settings_get_value(settings, "AudioList"); audio_count = hb_list_count(title->list_audio); count = ghb_array_len(pref_audio); @@ -596,7 +617,7 @@ static void set_pref_audio_with_lang( hb_audio_config_t *aconfig; aconfig = hb_list_audio_config_item(title->list_audio, track); select_acodec = ghb_select_audio_codec( - mux, aconfig, acodec, fallback, copy_mask); + mux->format, aconfig, acodec, fallback, copy_mask); // Was the source track already encoded // with the selected encode settings. diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 061e10bbc..412185548 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -548,19 +548,18 @@ ghb_cache_volnames(signal_user_data_t *ud) static const gchar* get_extension(signal_user_data_t *ud, GValue *settings) { - int container; - const gchar *extension; + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); - container = ghb_settings_combo_int(settings, "FileFormat"); - if ((container & HB_MUX_MASK_MP4) && + if ((mux->format & HB_MUX_MASK_MP4) && ghb_settings_get_boolean(ud->prefs, "UseM4v")) { return "m4v"; } - extension = hb_container_get_default_extension(container); - if (extension == NULL) - extension = "error"; - return extension; + return mux->default_extension; } static void @@ -925,12 +924,18 @@ static void show_container_options(signal_user_data_t *ud) w2 = GHB_WIDGET(ud->builder, "Mp4HttpOptimize"); w3 = GHB_WIDGET(ud->builder, "Mp4iPodCompatible"); - gint mux = ghb_settings_combo_int(ud->settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); + gint enc = ghb_settings_combo_int(ud->settings, "VideoEncoder"); - gtk_widget_set_visible(w1, (mux == HB_MUX_MP4V2)); - gtk_widget_set_visible(w2, (mux & HB_MUX_MASK_MP4)); - gtk_widget_set_visible(w3, (mux & HB_MUX_MASK_MP4) && (enc == HB_VCODEC_X264)); + gtk_widget_set_visible(w1, (mux->format == HB_MUX_MP4V2)); + gtk_widget_set_visible(w2, (mux->format & HB_MUX_MASK_MP4)); + gtk_widget_set_visible(w3, (mux->format & HB_MUX_MASK_MP4) && + (enc == HB_VCODEC_X264)); } static void diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index be3dede7c..63c52b699 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -1317,76 +1317,6 @@ lookup_mixdown_value(gint imix) return ghb_string_value_new(mix->short_name); return NULL; } -static const hb_container_t * -lookup_container_by_int(int imux) -{ - const hb_container_t *mux; - for (mux = hb_container_get_next(NULL); mux != NULL; - mux = hb_container_get_next(mux)) - { - if (mux->format == imux) - { - return mux; - } - } - return NULL; -} - -static const hb_container_t * -lookup_container(const GValue *gmux) -{ - const hb_container_t *mux; - - if (G_VALUE_TYPE(gmux) == G_TYPE_STRING) - { - gchar *str = ghb_value_string(gmux); - for (mux = hb_container_get_next(NULL); mux != NULL; - mux = hb_container_get_next(mux)) - { - if (strcmp(mux->name, str) == 0 || - strcmp(mux->short_name, str) == 0) - { - g_free(str); - return mux; - } - } - g_free(str); - } - else if (G_VALUE_TYPE(gmux) == G_TYPE_INT || - G_VALUE_TYPE(gmux) == G_TYPE_INT64 || - G_VALUE_TYPE(gmux) == G_TYPE_DOUBLE) - { - return lookup_container_by_int(ghb_value_int(gmux)); - } - return NULL; -} - -static gint -lookup_container_int(const GValue *gmux) -{ - const hb_container_t *mux = lookup_container(gmux); - if (mux != NULL) - return mux->format; - return 0; -} - -static const gchar* -lookup_container_option(const GValue *gmux) -{ - const hb_container_t *mux = lookup_container(gmux); - if (mux != NULL) - return mux->name; - return 0; -} - -static const gchar* -lookup_container_string(const GValue *gmux) -{ - const hb_container_t *mux = lookup_container(gmux); - if (mux != NULL) - return mux->short_name; - return 0; -} // Handle for libhb. Gets set by ghb_backend_init() static hb_handle_t * h_scan = NULL; @@ -1528,7 +1458,7 @@ void ghb_grey_combo_options(signal_user_data_t *ud) { GtkWidget *widget; - gint mux, track, title_id, titleindex, acodec, fallback; + gint track, title_id, titleindex, acodec, fallback; const hb_title_t *title; hb_audio_config_t *aconfig = NULL; GValue *gval; @@ -1543,10 +1473,12 @@ ghb_grey_combo_options(signal_user_data_t *ud) track = ghb_lookup_combo_int("AudioTrack", gval); ghb_value_free(gval); aconfig = ghb_get_audio_info(title, track); - widget = GHB_WIDGET (ud->builder, "FileFormat"); - gval = ghb_widget_value(widget); - mux = ghb_lookup_combo_int("FileFormat", gval); - ghb_value_free(gval); + + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); grey_builder_combo_box_item(ud->builder, "x264_analyse", 4, TRUE); @@ -1554,7 +1486,7 @@ ghb_grey_combo_options(signal_user_data_t *ud) for (enc = hb_audio_encoder_get_next(NULL); enc != NULL; enc = hb_audio_encoder_get_next(enc)) { - if (!(mux & enc->muxers)) + if (!(mux->format & enc->muxers)) { grey_builder_combo_box_item(ud->builder, "AudioEncoder", enc->codec, TRUE); @@ -1572,7 +1504,7 @@ ghb_grey_combo_options(signal_user_data_t *ud) for (enc = hb_video_encoder_get_next(NULL); enc != NULL; enc = hb_video_encoder_get_next(enc)) { - if (!(mux & enc->muxers)) + if (!(mux->format & enc->muxers)) { grey_builder_combo_box_item(ud->builder, "VideoEncoder", enc->codec, TRUE); @@ -1613,7 +1545,8 @@ ghb_grey_combo_options(signal_user_data_t *ud) gint64 layout = aconfig != NULL ? aconfig->in.channel_layout : ~0; fallback = ghb_select_fallback(ud->settings, acodec); gint copy_mask = ghb_get_copy_mask(ud->settings); - acodec = ghb_select_audio_codec(mux, aconfig, acodec, fallback, copy_mask); + acodec = ghb_select_audio_codec(mux->format, aconfig, acodec, + fallback, copy_mask); grey_mix_opts(ud, acodec, layout); } @@ -2037,20 +1970,24 @@ container_opts_set( } } -const hb_container_t * -ghb_lookup_container(const gchar *name) +const hb_container_t* +ghb_lookup_container_by_name(const gchar *name) { - const hb_container_t *mux; - for (mux = hb_container_get_next(NULL); mux != NULL; + // First find an enabled muxer + int format = hb_container_get_from_name(name); + + // Now find the matching muxer info + const hb_container_t *mux, *first; + for (first = mux = hb_container_get_next(NULL); mux != NULL; mux = hb_container_get_next(mux)) { - if (!strncmp(mux->short_name, name, 80) || - !strncmp(mux->name, name, 80)) + if (format == mux->format) { return mux; } } - return NULL; + // Return a default container if nothing matches + return first; } static void @@ -2764,8 +2701,6 @@ ghb_lookup_combo_int(const gchar *name, const GValue *gval) return lookup_audio_encoder_int(gval); else if (strcmp(name, "AudioEncoderFallback") == 0) return lookup_audio_encoder_int(gval); - else if (strcmp(name, "FileFormat") == 0) - return lookup_container_int(gval); else { return lookup_generic_int(find_combo_table(name), gval); @@ -2795,8 +2730,6 @@ ghb_lookup_combo_double(const gchar *name, const GValue *gval) return lookup_audio_encoder_int(gval); else if (strcmp(name, "AudioEncoderFallback") == 0) return lookup_audio_encoder_int(gval); - else if (strcmp(name, "FileFormat") == 0) - return lookup_container_int(gval); else { return lookup_generic_double(find_combo_table(name), gval); @@ -2826,8 +2759,6 @@ ghb_lookup_combo_option(const gchar *name, const GValue *gval) return lookup_audio_encoder_option(gval); else if (strcmp(name, "AudioEncoderFallback") == 0) return lookup_audio_encoder_option(gval); - else if (strcmp(name, "FileFormat") == 0) - return lookup_container_option(gval); else { return lookup_generic_option(find_combo_table(name), gval); @@ -2857,8 +2788,6 @@ ghb_lookup_combo_string(const gchar *name, const GValue *gval) return lookup_audio_encoder_string(gval); else if (strcmp(name, "AudioEncoderFallback") == 0) return lookup_audio_encoder_string(gval); - else if (strcmp(name, "FileFormat") == 0) - return lookup_container_string(gval); else { return lookup_generic_string(find_combo_table(name), gval); @@ -2867,54 +2796,6 @@ ghb_lookup_combo_string(const gchar *name, const GValue *gval) return NULL; } -#if 0 -static gboolean acodec_list_box_filter(GtkListBoxRow *row, gpointer data) -{ - GValue *settings = (GValue*)data; - - int mux = ghb_settings_combo_int(settings, "FileFormat"); - - GtkWidget *label = gtk_bin_get_child(GTK_BIN(row)); - int codec = (intptr_t)g_object_get_data(G_OBJECT(label), "codec"); - - const hb_encoder_t *enc; - for (enc = hb_audio_encoder_get_next(NULL); enc != NULL; - enc = hb_audio_encoder_get_next(enc)) - { - if (enc->codec == codec && (mux & enc->muxers)) - { - return TRUE; - } - } - return FALSE; -} - -void ghb_update_acodec_list_box(GtkListBox *list_box) -{ - gtk_list_box_invalidate_filter(list_box); -} - -void ghb_init_acodec_list_box(GtkListBox *list_box, GValue *settings) -{ - int mux = ghb_settings_combo_int(settings, "FileFormat"); - - const hb_encoder_t *enc; - for (enc = hb_audio_encoder_get_next(NULL); enc != NULL; - enc = hb_audio_encoder_get_next(enc)) - { - if (mux & enc->muxers) - { - GtkWidget *label = gtk_label_new(enc->name); - g_object_set_data(G_OBJECT(label), "codec", (gpointer)(intptr_t)enc->codec); - gtk_widget_show(label); - gtk_list_box_insert(list_box, label, -1); - } - } - gtk_list_box_set_filter_func(list_box, acodec_list_box_filter, - settings, NULL); -} -#endif - void ghb_init_lang_list_box(GtkListBox *list_box) { int ii; @@ -4366,12 +4247,16 @@ ghb_validate_filters(GValue *settings) gboolean ghb_validate_video(GValue *settings) { - gint vcodec, mux; + gint vcodec; gchar *message; + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); - mux = ghb_settings_combo_int(settings, "FileFormat"); vcodec = ghb_settings_combo_int(settings, "VideoEncoder"); - if ((mux & HB_MUX_MASK_MP4) && (vcodec == HB_VCODEC_THEORA)) + if ((mux->format & HB_MUX_MASK_MP4) && (vcodec == HB_VCODEC_THEORA)) { // mp4/theora combination is not supported. message = g_strdup_printf( @@ -4477,7 +4362,12 @@ ghb_validate_audio(GValue *settings) g_message("No title found.\n"); return FALSE; } - gint mux = ghb_settings_combo_int(settings, "FileFormat"); + + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); const GValue *audio_list; gint count, ii; @@ -4517,7 +4407,7 @@ ghb_validate_audio(GValue *settings) { codec = HB_ACODEC_AC3; } - else if (mux & HB_MUX_MASK_MKV) + else if (mux->format & HB_MUX_MASK_MKV) { codec = HB_ACODEC_LAME; } @@ -4530,7 +4420,7 @@ ghb_validate_audio(GValue *settings) } gchar *a_unsup = NULL; gchar *mux_s = NULL; - if (mux & HB_MUX_MASK_MP4) + if (mux->format & HB_MUX_MASK_MP4) { mux_s = "MP4"; // mp4/vorbis|DTS combination is not supported. @@ -4697,7 +4587,13 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) job->pts_to_stop = ghb_settings_get_int(prefs, "live_duration") * 90000LL; } - job->mux = ghb_settings_combo_int(js, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(js, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); + + job->mux = mux->format; if (job->mux & HB_MUX_MASK_MP4) { job->largeFileSize = ghb_settings_get_boolean(js, "Mp4LargeFile"); diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 3ee1e5a1d..26dce0eda 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -170,6 +170,9 @@ int ghb_lookup_audio_lang(const GValue *glang); const iso639_lang_t* ghb_iso639_lookup_by_int(int idx); void ghb_update_display_aspect_label(signal_user_data_t *ud); gchar* ghb_create_title_label(const hb_title_t *title); + +// libhb lookup helpers const hb_title_t* ghb_lookup_title(int title_id, int *index); +const hb_container_t* ghb_lookup_container_by_name(const gchar *name); #endif // _HBBACKEND_H_ diff --git a/gtk/src/preset_xlat.c b/gtk/src/preset_xlat.c deleted file mode 100644 index f9bcca8f0..000000000 --- a/gtk/src/preset_xlat.c +++ /dev/null @@ -1,627 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <glib.h> -#include <glib/gstdio.h> -#include "plist.h" -#include "values.h" - -static GValue *defaults; - -typedef struct -{ - gchar *mac_val; - gchar *lin_val; -} value_map_t; - -#if 0 -static value_map_t subtitle_xlat[] = -{ - { "None", "none" }, - { "Auto", "auto" }, - { "Any", "und" }, - { "Afar", "aar" }, - { "Abkhazian", "abk" }, - { "Afrikaans", "afr" }, - { "Akan", "aka" }, - { "Albanian", "sqi" }, - { "Amharic", "amh" }, - { "Arabic", "ara" }, - { "Aragonese", "arg" }, - { "Armenian", "hye" }, - { "Assamese", "asm" }, - { "Avaric", "ava" }, - { "Avestan", "ave" }, - { "Aymara", "aym" }, - { "Azerbaijani", "aze" }, - { "Bashkir", "bak" }, - { "Bambara", "bam" }, - { "Basque", "eus" }, - { "Belarusian", "bel" }, - { "Bengali", "ben" }, - { "Bihari", "bih" }, - { "Bislama", "bis" }, - { "Bosnian", "bos" }, - { "Breton", "bre" }, - { "Bulgarian", "bul" }, - { "Burmese", "mya" }, - { "Catalan", "cat" }, - { "Chamorro", "cha" }, - { "Chechen", "che" }, - { "Chinese", "zho" }, - { "Church Slavic", "chu" }, - { "Chuvash", "chv" }, - { "Cornish", "cor" }, - { "Corsican", "cos" }, - { "Cree", "cre" }, - { "Czech", "ces" }, - { "Danish", "dan" }, - { "Divehi", "div" }, - { "Dutch", "nld" }, - { "Dzongkha", "dzo" }, - { "English", "eng" }, - { "Esperanto", "epo" }, - { "Estonian", "est" }, - { "Ewe", "ewe" }, - { "Faroese", "fao" }, - { "Fijian", "fij" }, - { "Finnish", "fin" }, - { "French", "fra" }, - { "Western Frisian", "fry" }, - { "Fulah", "ful" }, - { "Georgian", "kat" }, - { "German", "deu" }, - { "Gaelic (Scots)", "gla" }, - { "Irish", "gle" }, - { "Galician", "glg" }, - { "Manx", "glv" }, - { "Greek, Modern", "ell" }, - { "Guarani", "grn" }, - { "Gujarati", "guj" }, - { "Haitian", "hat" }, - { "Hausa", "hau" }, - { "Hebrew", "heb" }, - { "Herero", "her" }, - { "Hindi", "hin" }, - { "Hiri Motu", "hmo" }, - { "Hungarian", "hun" }, - { "Igbo", "ibo" }, - { "Icelandic", "isl" }, - { "Ido", "ido" }, - { "Sichuan Yi", "iii" }, - { "Inuktitut", "iku" }, - { "Interlingue", "ile" }, - { "Interlingua", "ina" }, - { "Indonesian", "ind" }, - { "Inupiaq", "ipk" }, - { "Italian", "ita" }, - { "Javanese", "jav" }, - { "Japanese", "jpn" }, - { "Kalaallisut", "kal" }, - { "Kannada", "kan" }, - { "Kashmiri", "kas" }, - { "Kanuri", "kau" }, - { "Kazakh", "kaz" }, - { "Central Khmer", "khm" }, - { "Kikuyu", "kik" }, - { "Kinyarwanda", "kin" }, - { "Kirghiz", "kir" }, - { "Komi", "kom" }, - { "Kongo", "kon" }, - { "Korean", "kor" }, - { "Kuanyama", "kua" }, - { "Kurdish", "kur" }, - { "Lao", "lao" }, - { "Latin", "lat" }, - { "Latvian", "lav" }, - { "Limburgan", "lim" }, - { "Lingala", "lin" }, - { "Lithuanian", "lit" }, - { "Luxembourgish", "ltz" }, - { "Luba-Katanga", "lub" }, - { "Ganda", "lug" }, - { "Macedonian", "mkd" }, - { "Marshallese", "mah" }, - { "Malayalam", "mal" }, - { "Maori", "mri" }, - { "Marathi", "mar" }, - { "Malay", "msa" }, - { "Malagasy", "mlg" }, - { "Maltese", "mlt" }, - { "Moldavian", "mol" }, - { "Mongolian", "mon" }, - { "Nauru", "nau" }, - { "Navajo", "nav" }, - { "Ndebele, South", "nbl" }, - { "Ndebele, North", "nde" }, - { "Ndonga", "ndo" }, - { "Nepali", "nep" }, - { "Norwegian Nynorsk", "nno" }, - { "Norwegian Bokmål", "nob" }, - { "Norwegian", "nor" }, - { "Chichewa; Nyanja", "nya" }, - { "Occitan", "oci" }, - { "Ojibwa", "oji" }, - { "Oriya", "ori" }, - { "Oromo", "orm" }, - { "Ossetian", "oss" }, - { "Panjabi", "pan" }, - { "Persian", "fas" }, - { "Pali", "pli" }, - { "Polish", "pol" }, - { "Portuguese", "por" }, - { "Pushto", "pus" }, - { "Quechua", "que" }, - { "Romansh", "roh" }, - { "Romanian", "ron" }, - { "Rundi", "run" }, - { "Russian", "rus" }, - { "Sango", "sag" }, - { "Sanskrit", "san" }, - { "Serbian", "srp" }, - { "Croatian", "hrv" }, - { "Sinhala", "sin" }, - { "Slovak", "slk" }, - { "Slovenian", "slv" }, - { "Northern Sami", "sme" }, - { "Samoan", "smo" }, - { "Shona", "sna" }, - { "Sindhi", "snd" }, - { "Somali", "som" }, - { "Sotho, Southern", "sot" }, - { "Spanish", "spa" }, - { "Sardinian", "srd" }, - { "Swati", "ssw" }, - { "Sundanese", "sun" }, - { "Swahili", "swa" }, - { "Swedish", "swe" }, - { "Tahitian", "tah" }, - { "Tamil", "tam" }, - { "Tatar", "tat" }, - { "Telugu", "tel" }, - { "Tajik", "tgk" }, - { "Tagalog", "tgl" }, - { "Thai", "tha" }, - { "Tibetan", "bod" }, - { "Tigrinya", "tir" }, - { "Tonga", "ton" }, - { "Tswana", "tsn" }, - { "Tsonga", "tso" }, - { "Turkmen", "tuk" }, - { "Turkish", "tur" }, - { "Twi", "twi" }, - { "Uighur", "uig" }, - { "Ukrainian", "ukr" }, - { "Urdu", "urd" }, - { "Uzbek", "uzb" }, - { "Venda", "ven" }, - { "Vietnamese", "vie" }, - { "Volapük", "vol" }, - { "Welsh", "cym" }, - { "Walloon", "wln" }, - { "Wolof", "wol" }, - { "Xhosa", "xho" }, - { "Yiddish", "yid" }, - { "Yoruba", "yor" }, - { "Zhuang", "zha" }, - { "Zulu", "zul" }, - {NULL, NULL} -}; - -static value_map_t vcodec_xlat[] = -{ - {"MPEG-4 (FFmpeg)", "ffmpeg"}, - {"MPEG-4 (XviD)", "ffmpeg"}, - {"H.264 (x264)", "x264"}, - {"VP3 (Theora)", "theora"}, - {NULL,NULL} -}; - -value_map_t container_xlat[] = -{ - {"MP4 file", "mp4"}, - {"M4V file", "m4v"}, - {"MKV file", "mkv"}, - {"AVI file", "avi"}, - {"OGM file", "ogm"}, - {NULL, NULL} -}; - -value_map_t framerate_xlat[] = -{ - {"Same as source", "source"}, - {"5", "5"}, - {"10", "10"}, - {"12", "12"}, - {"15", "15"}, - {"23.976", "23.976"}, - {"24", "24"}, - {"25", "25"}, - {"29.97", "29.97"}, - {NULL, NULL} -}; - -value_map_t deint_xlat[] = -{ - {"0", "none"}, - {"1", "fast"}, - {"2", "slow"}, - {"3", "slower"}, - {NULL, NULL} -}; - -value_map_t denoise_xlat[] = -{ - {"0", "none"}, - {"1", "weak"}, - {"2", "medium"}, - {"3", "strong"}, - {NULL, NULL} -}; - -static value_map_t acodec_xlat[] = -{ - {"AAC (faac)", "faac"}, - {"AC3 Passthru", "ac3"}, - {"MP3 (lame)", "lame"}, - {"Vorbis (vorbis)", "vorbis"}, - {NULL,NULL} -}; - -value_map_t samplerate_xlat[] = -{ - {"Auto", "source"}, - {"22.05", "22.05"}, - {"24", "24"}, - {"32", "32"}, - {"44.1", "44.1"}, - {"48", "48"}, - {NULL, NULL} -}; - -value_map_t mix_xlat[] = -{ - {"Mono", "mono"}, - {"Stereo", "stereo"}, - {"Dolby Surround", "dpl1"}, - {"Dolby Pro Logic II", "dpl2"}, - {"6-channel discrete", "6ch"}, - {"AC3 Passthru", "none"}, - {NULL, NULL} -}; -#endif - -typedef struct -{ - gchar *mac_key; - gchar *lin_key; - value_map_t *value_map; - gboolean same; - gboolean ignore; -} key_map_t; - -key_map_t key_map[] = -{ - {"Audio1Bitrate", NULL, NULL, FALSE, FALSE}, - {"Audio1Encoder", NULL, NULL, FALSE, FALSE}, - {"Audio1Mixdown", NULL, NULL, FALSE, FALSE}, - {"Audio1Samplerate", NULL, NULL, FALSE, FALSE}, - {"Audio1Track", NULL, NULL, FALSE, FALSE}, - {"Audio1TrackDescription", NULL, NULL, FALSE, FALSE}, - {"Audio1TrackDRCSlider", NULL, NULL, FALSE, FALSE}, - {"Audio2Bitrate", NULL, NULL, FALSE, FALSE}, - {"Audio2Encoder", NULL, NULL, FALSE, FALSE}, - {"Audio2Mixdown", NULL, NULL, FALSE, FALSE}, - {"Audio2Samplerate", NULL, NULL, FALSE, FALSE}, - {"Audio2Track", NULL, NULL, FALSE, FALSE}, - {"Audio2TrackDescription", NULL, NULL, FALSE, FALSE}, - {"Audio2TrackDRCSlider", NULL, NULL, FALSE, FALSE}, - {"ChapterMarkers", NULL, NULL, TRUE, FALSE}, - {"Default", NULL, NULL, TRUE, FALSE}, - {"FileFormat", NULL, NULL, TRUE, FALSE}, - {"Folder", NULL, NULL, TRUE, FALSE}, - {"Mp4HttpOptimize", NULL, NULL, TRUE, FALSE}, - {"Mp4iPodCompatible", NULL, NULL, TRUE, FALSE}, - {"Mp4LargeFile", NULL, NULL, TRUE, FALSE}, - {"PictureAutoCrop", NULL, NULL, TRUE, FALSE}, - {"PictureBottomCrop", NULL, NULL, TRUE, FALSE}, - {"PictureDeblock", NULL, NULL, TRUE, FALSE}, - {"PictureDecomb", NULL, NULL, TRUE, FALSE}, - {"PictureDeinterlace", NULL, NULL, TRUE, FALSE}, - {"PictureDenoise", NULL, NULL, TRUE, FALSE}, - {"PictureDetelecine", NULL, NULL, TRUE, FALSE}, - {"PictureHeight", NULL, NULL, TRUE, FALSE}, - {"PictureKeepRatio", NULL, NULL, TRUE, FALSE}, - {"PictureLeftCrop", NULL, NULL, TRUE, FALSE}, - {"PicturePAR", NULL, NULL, TRUE, FALSE}, - {"PictureRightCrop", NULL, NULL, TRUE, FALSE}, - {"PictureTopCrop", NULL, NULL, TRUE, FALSE}, - {"PictureWidth", NULL, NULL, TRUE, FALSE}, - {"PresetDescription", NULL, NULL, TRUE, FALSE}, - {"PresetName", NULL, NULL, TRUE, FALSE}, - {"Subtitles", NULL, NULL, TRUE, FALSE}, - {"SubtitlesForced", NULL, NULL, TRUE, FALSE}, - {"Type", NULL, NULL, TRUE, FALSE}, - {"UsesMaxPictureSettings", NULL, NULL, TRUE, FALSE}, - {"UsesPictureFilters", NULL, NULL, TRUE, FALSE}, - {"UsesPictureSettings", NULL, NULL, TRUE, FALSE}, - {"VFR", NULL, NULL, FALSE, TRUE}, - {"VideoAvgBitrate", NULL, NULL, TRUE, FALSE}, - {"VideoEncoder", NULL, NULL, TRUE, FALSE}, - {"VideoFramerate", NULL, NULL, TRUE, FALSE}, - {"VideoGrayScale", NULL, NULL, TRUE, FALSE}, - {"VideoQualitySlider", NULL, NULL, TRUE, FALSE}, - {"VideoQualityType", NULL, NULL, TRUE, FALSE}, - {"VideoTargetSize", NULL, NULL, TRUE, FALSE}, - {"VideoTwoPass", NULL, NULL, TRUE, FALSE}, - {"VideoTurboTwoPass", NULL, NULL, TRUE, FALSE}, - {"x264Option", NULL, NULL, TRUE, FALSE}, - {NULL, NULL} -}; - -const gint -key_xlat(key_map_t *key_map, const gchar *mac_key) -{ - gint ii; - - for (ii = 0; key_map[ii].mac_key; ii++) - { - if (strcmp(mac_key, key_map[ii].mac_key) == 0) - { - if (key_map[ii].ignore) - return -1; - return ii; - } - } - g_warning("Unrecognized key: (%s)", mac_key); - return -1; -} - -static GValue* -value_xlat( - GValue *defaults, - key_map_t *key_map, - gint key_index, - GValue *mac_val) -{ - GValue *gval, *def_val; - const gchar *lin_key; - if (key_map[key_index].same) - lin_key = key_map[key_index].mac_key; - else - lin_key = key_map[key_index].lin_key; - value_map_t *value_map = key_map[key_index].value_map; - - def_val = ghb_dict_lookup(defaults, lin_key); - if (def_val) - { - if (value_map) - { - gint ii; - gchar *str; - GValue *sval; - - str = ghb_value_string(mac_val); - for (ii = 0; value_map[ii].mac_val; ii++) - { - if (strcmp(str, value_map[ii].mac_val) == 0) - { - sval = ghb_string_value_new(value_map[ii].lin_val); - g_free(str); - gval = ghb_value_new(G_VALUE_TYPE(def_val)); - if (!g_value_transform(sval, gval)) - { - g_warning("1 can't transform"); - ghb_value_free(gval); - ghb_value_free(sval); - return NULL; - } - ghb_value_free(sval); - return gval; - } - } - g_warning("Can't map value: (%s)", str); - g_free(str); - } - else - { - gval = ghb_value_new(G_VALUE_TYPE(def_val)); - if (!g_value_transform(mac_val, gval)) - { - g_warning("2 can't transform"); - ghb_value_free(gval); - return NULL; - } - return gval; - } - } - else - { - g_warning("Bad key: (%s)", lin_key); - return NULL; - } - return NULL; -} - -key_map_t audio_key_map[] = -{ - {"Audio1Bitrate", "AudioBitrate", NULL, FALSE, FALSE}, - {"Audio1Encoder", "AudioEncoder", NULL, FALSE, FALSE}, - {"Audio1Mixdown", "AudioMixdown", NULL, FALSE}, - {"Audio1Samplerate", "AudioSamplerate", NULL, FALSE, FALSE}, - {"Audio1Track", "AudioTrack", NULL, FALSE, FALSE}, - {"Audio1TrackDescription", "AudioTrackDescription", NULL, FALSE, FALSE}, - {"Audio1TrackDRCSlider", "AudioTrackDRCSlider", NULL, FALSE, FALSE}, - {"Audio2Bitrate", "AudioBitrate", NULL, FALSE, FALSE}, - {"Audio2Encoder", "AudioEncoder", NULL, FALSE, FALSE}, - {"Audio2Mixdown", "AudioMixdown", NULL, FALSE, FALSE}, - {"Audio2Samplerate", "AudioSamplerate", NULL, FALSE, FALSE}, - {"Audio2Track", "AudioTrack", NULL, FALSE, FALSE}, - {"Audio2TrackDescription", "AudioTrackDescription", NULL, FALSE, FALSE}, - {"Audio2TrackDRCSlider", "AudioTrackDRCSlider", NULL, FALSE, FALSE}, - {NULL, NULL} -}; - -static void -hard_value_xlat(GValue *lin_dict, const gchar *mac_key, GValue *mac_val) -{ - { - gint key_index; - GValue *audio_defaults; - - audio_defaults = ghb_array_get_nth( - ghb_dict_lookup(defaults, "AudioList"), 0); - key_index = key_xlat(audio_key_map, mac_key); - if (key_index >= 0) - { - gint audio_index, count, ii; - GValue *alist, *adict, *val; - const gchar *lin_key; - - if (audio_key_map[key_index].same) - lin_key = audio_key_map[key_index].mac_key; - else - lin_key = audio_key_map[key_index].lin_key; - audio_index = mac_key[5] - '1'; - alist = ghb_dict_lookup(lin_dict, "AudioList"); - if (alist == NULL) - { - alist = ghb_array_value_new(8); - ghb_dict_insert(lin_dict, "AudioList", alist); - } - count = ghb_array_len(alist); - for (ii = count; ii <= audio_index; ii++) - { - adict = ghb_value_dup(audio_defaults); - ghb_array_append(alist, adict); - } - adict = ghb_array_get_nth(alist, audio_index); - val = value_xlat(audio_defaults, audio_key_map, key_index, mac_val); - if (val) - { - ghb_dict_insert(adict, g_strdup(lin_key), val); - } - } - } -} - -static void -parse_preset_dict(GValue *mac_dict, GValue *lin_dict) -{ - GHashTableIter iter; - gchar *key; - GValue *mac_val, *val; - - ghb_dict_iter_init(&iter, mac_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*)&mac_val)) - { - gint key_index; - - key_index = key_xlat(key_map, key); - if (key_index >= 0) - { // The simple translations - const gchar *lin_key; - - if (key_map[key_index].same) - lin_key = key_map[key_index].mac_key; - else - lin_key = key_map[key_index].lin_key; - if (lin_key) - { - val = value_xlat(defaults, key_map, key_index, mac_val); - if (val) - { - ghb_dict_insert(lin_dict, g_strdup(lin_key), val); - } - } - else - { - hard_value_xlat(lin_dict, key, mac_val); - } - } - } -} - -static void -parse_preset_array(GValue *mac_array, GValue *lin_array) -{ - gint count, ii; - GValue *mac_dict, *lin_dict, *gval; - - count = ghb_array_len(mac_array); - for (ii = 0; ii < count; ii++) - { - mac_dict = ghb_array_get_nth(mac_array, ii); - - // Only process builtin types - if (ghb_value_int(ghb_dict_lookup(mac_dict, "Type")) != 0) - continue; - - lin_dict = ghb_dict_value_new(); - ghb_array_append(lin_array, lin_dict); - gval = ghb_dict_lookup(mac_dict, "PresetName"); - if (gval) - { - ghb_dict_insert(lin_dict, g_strdup("PresetName"), - ghb_value_dup(gval)); - } - gval = ghb_dict_lookup(mac_dict, "PresetDescription"); - if (gval) - { - ghb_dict_insert(lin_dict, g_strdup("PresetDescription"), - ghb_value_dup(gval)); - } - gval = ghb_dict_lookup(mac_dict, "Folder"); - if (gval && ghb_value_boolean(gval)) - { // Folder - GValue *mval, *lval; - - mval = ghb_dict_lookup(mac_dict, "ChildrenArray"); - lval = ghb_array_value_new(32); - ghb_dict_insert(lin_dict, g_strdup("ChildrenArray"), lval); - ghb_dict_insert(lin_dict, g_strdup("Folder"), - ghb_boolean_value_new(TRUE)); - ghb_dict_insert(lin_dict, g_strdup("Type"), - ghb_int_value_new(0)); - parse_preset_array(mval, lval); - } - else - { // Normal preset - ghb_dict_insert(lin_dict, g_strdup("Type"), - ghb_int_value_new(0)); - parse_preset_dict(mac_dict, lin_dict); - } - } -} - -static void -xlat(GValue *mac, GValue *lin) -{ - return parse_preset_array(mac, lin); -} - -gint -main(gint argc, gchar *argv[]) -{ - GValue *mac_plist, *lin_plist; - GValue *internal; - - if (argc < 3) - { - fprintf(stderr, "Usage: <mac plist> <lin plist>\n"); - return 1; - } - g_type_init(); - - ghb_register_transforms(); - internal = ghb_plist_parse_file("internal_defaults.xml"); - defaults = ghb_dict_lookup(internal, "Presets"); - mac_plist = ghb_plist_parse_file(argv[1]); - lin_plist = ghb_array_value_new(32); - xlat(mac_plist, lin_plist); - ghb_plist_write_file(argv[2], lin_plist); - return 0; -} - diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 11980dc2c..2979d09aa 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -156,12 +156,14 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) gchar *preset; gboolean markers; gboolean preset_modified; - gint mux; const GValue *path; - const gchar *container; - container = ghb_settings_combo_option(settings, "FileFormat"); - mux = ghb_settings_combo_int(settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); + preset_modified = ghb_settings_get_boolean(settings, "preset_modified"); path = ghb_settings_get_value(settings, "preset"); preset = ghb_preset_path_string(path); @@ -179,12 +181,12 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) // Next line in the display (Container type) // Format: XXX Container - XPRINT("<b>Format:</b> <small>%s Container</small>\n", container); + XPRINT("<b>Format:</b> <small>%s Container</small>\n", mux->name); // Next line in the display (Container options) // Container Options: - Chapter Markers gboolean ipod = FALSE, http = FALSE, large = FALSE; - if (mux & HB_MUX_MASK_MP4) + if (mux->format & HB_MUX_MASK_MP4) { ipod = ghb_settings_get_boolean(settings, "Mp4iPodCompatible"); http = ghb_settings_get_boolean(settings, "Mp4HttpOptimize"); diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c index cba0cbf54..cc792d7dd 100644 --- a/gtk/src/subtitlehandler.c +++ b/gtk/src/subtitlehandler.c @@ -224,7 +224,7 @@ subtitle_add_to_settings(GValue *settings, GValue *subsettings) GValue *subtitle_list; gint count; gboolean burned, forced, def; - gint source, mux; + gint source; subtitle_list = ghb_settings_get_value(settings, "subtitle_list"); if (subtitle_list == NULL) @@ -234,7 +234,12 @@ subtitle_add_to_settings(GValue *settings, GValue *subsettings) } // Validate some settings - mux = ghb_settings_combo_int(settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); + source = ghb_settings_get_int(subsettings, "SubtitleSource"); burned = ghb_settings_get_boolean(subsettings, "SubtitleBurned"); if (burned && !hb_subtitle_can_burn(source)) @@ -242,7 +247,7 @@ subtitle_add_to_settings(GValue *settings, GValue *subsettings) burned = FALSE; ghb_settings_set_boolean(subsettings, "SubtitleBurned", burned); } - if (!burned && !hb_subtitle_can_pass(source, mux)) + if (!burned && !hb_subtitle_can_pass(source, mux->format)) { burned = TRUE; ghb_settings_set_boolean(subsettings, "SubtitleBurned", burned); @@ -410,7 +415,7 @@ ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, const GValue *lang_list; gint lang_count, sub_count, ii; - int behavior, mux; + int behavior; behavior = ghb_settings_combo_int(settings, "SubtitleTrackSelectionBehavior"); @@ -429,7 +434,11 @@ ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, return; } - mux = ghb_settings_combo_int(settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); // Check to see if we need to add a subtitle track for foreign audio // language films. A subtitle track will be added if: @@ -468,7 +477,7 @@ ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, if (track > 0) { used[track] = TRUE; - subtitle_add_track(ud, settings, title, track, mux, + subtitle_add_track(ud, settings, title, track, mux->format, TRUE, FALSE, &one_burned); } } @@ -477,7 +486,7 @@ ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, (audio_lang != NULL && !strncmp(audio_lang, pref_lang, 4))) { // Add search for foreign audio segments - subtitle_add_track(ud, settings, title, -1, mux, + subtitle_add_track(ud, settings, title, -1, mux->format, TRUE, FALSE, &one_burned); } @@ -496,7 +505,7 @@ ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, if (!used[track]) { used[track] = TRUE; - subtitle_add_track(ud, settings, title, track, mux, + subtitle_add_track(ud, settings, title, track, mux->format, FALSE, FALSE, &one_burned); } next_track = track + 1; @@ -524,7 +533,7 @@ ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, if (track < sub_count && !used[track]) { used[track] = TRUE; - subtitle_add_track(ud, settings, title, track, mux, + subtitle_add_track(ud, settings, title, track, mux->format, FALSE, FALSE, &one_burned); } } @@ -629,7 +638,12 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GValue *subsettings) // Update widgets with subsettings gboolean burn, force, def; - int mux = ghb_settings_combo_int(ud->settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); + int source = ghb_settings_get_int(subsettings, "SubtitleSource"); ghb_ui_update_from_settings(ud, "SubtitleTrack", subsettings); @@ -648,12 +662,13 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GValue *subsettings) } widget = GHB_WIDGET(ud->builder, "SubtitleBurned"); - gtk_widget_set_sensitive(widget, - hb_subtitle_can_burn(source) && hb_subtitle_can_pass(source, mux)); + gtk_widget_set_sensitive(widget, hb_subtitle_can_burn(source) && + hb_subtitle_can_pass(source, mux->format)); widget = GHB_WIDGET(ud->builder, "SubtitleForced"); gtk_widget_set_sensitive(widget, hb_subtitle_can_force(source)); widget = GHB_WIDGET(ud->builder, "SubtitleDefaultTrack"); - gtk_widget_set_sensitive(widget, hb_subtitle_can_pass(source, mux)); + gtk_widget_set_sensitive(widget, + hb_subtitle_can_pass(source, mux->format)); burn = ghb_settings_get_int(subsettings, "SubtitleBurned"); force = ghb_settings_get_int(subsettings, "SubtitleForced"); @@ -667,7 +682,7 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GValue *subsettings) { force = FALSE; } - if (!hb_subtitle_can_pass(source, mux)) + if (!hb_subtitle_can_pass(source, mux->format)) { def = FALSE; burn = TRUE; @@ -1046,7 +1061,7 @@ subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) // Add the current subtitle settings to the list. GValue *subsettings, *backup; gboolean one_burned; - gint track, mux; + gint track; int title_id, titleindex; const hb_title_t *title; @@ -1063,19 +1078,24 @@ subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) ghb_settings_get_value(ud->settings, "subtitle_list")); one_burned = subtitle_is_one_burned(ud->settings); - mux = ghb_settings_combo_int(ud->settings, "FileFormat"); + + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); int count = hb_list_count(title->list_subtitle); for (subsettings = NULL, track = 0; subsettings == NULL && track < count; track++) { - subsettings = subtitle_add_track(ud, ud->settings, title, track, mux, - FALSE, FALSE, &one_burned); + subsettings = subtitle_add_track(ud, ud->settings, title, track, + mux->format, FALSE, FALSE, &one_burned); } if (subsettings == NULL) { - subsettings = subtitle_add_track(ud, ud->settings, title, 0, mux, - FALSE, TRUE, &one_burned); + subsettings = subtitle_add_track(ud, ud->settings, title, 0, + mux->format, FALSE, TRUE, &one_burned); } ghb_add_subtitle_to_ui(ud, subsettings); @@ -1108,7 +1128,7 @@ subtitle_add_all_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { // Add the current subtitle settings to the list. gboolean one_burned = FALSE; - gint track, mux; + gint track; const hb_title_t *title; int title_id, titleindex; @@ -1122,12 +1142,16 @@ subtitle_add_all_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) ghb_clear_subtitle_list_settings(ud->settings); ghb_clear_subtitle_list_ui(ud->builder); - mux = ghb_settings_combo_int(ud->settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); int count = hb_list_count(title->list_subtitle); for (track = 0; track < count; track++) { - subtitle_add_track(ud, ud->settings, title, track, mux, + subtitle_add_track(ud, ud->settings, title, track, mux->format, FALSE, FALSE, &one_burned); } subtitle_refresh_list_ui(ud); @@ -1157,7 +1181,11 @@ ghb_subtitle_prune(signal_user_data_t *ud) if (subtitle_list == NULL) return; - int mux = ghb_settings_combo_int(ud->settings, "FileFormat"); + const char *mux_id; + const hb_container_t *mux; + + mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat"); + mux = ghb_lookup_container_by_name(mux_id); for (ii = 0; ii < ghb_array_len(subtitle_list); ) { @@ -1167,7 +1195,7 @@ ghb_subtitle_prune(signal_user_data_t *ud) subsettings = ghb_array_get_nth(subtitle_list, ii); burned = ghb_settings_get_boolean(subsettings, "SubtitleBurned"); source = ghb_settings_get_boolean(subsettings, "SubtitleSource"); - burned = burned || !hb_subtitle_can_pass(source, mux); + burned = burned || !hb_subtitle_can_pass(source, mux->format); if (burned && one_burned) { GValue *gsub = ghb_array_get_nth(subtitle_list, ii); diff --git a/gtk/src/widgetdeps.c b/gtk/src/widgetdeps.c deleted file mode 100644 index 059390d7b..000000000 --- a/gtk/src/widgetdeps.c +++ /dev/null @@ -1,142 +0,0 @@ -#include <glib.h> -#include <glib-object.h> -#include <glib/gstdio.h> -#include <string.h> -#include "values.h" -#include "plist.h" - -typedef struct -{ - const gchar *widget_name; - const gchar *dep_name; - const gchar *enable_value; - const gboolean disable_if_equal; - const gboolean hide; -} dependency_t; - -static dependency_t dep_map[] = -{ - {"title", "queue_add", "none", TRUE, FALSE}, - {"title", "queue_add_menu", "none", TRUE, FALSE}, - {"title", "preview_frame", "none", TRUE, FALSE}, - {"title", "picture_label", "none", TRUE, FALSE}, - {"title", "picture_tab", "none", TRUE, FALSE}, - {"title", "chapters_label", "none", TRUE, FALSE}, - {"title", "chapters_tab", "none", TRUE, FALSE}, - {"title", "start_point", "none", TRUE, FALSE}, - {"title", "end_point", "none", TRUE, FALSE}, - {"title", "angle", "none", TRUE, FALSE}, - {"title", "angle_label", "1", TRUE, FALSE}, - {"use_dvdnav", "angle", "FALSE", TRUE, TRUE}, - {"use_dvdnav", "angle_label", "FALSE", TRUE, TRUE}, - {"angle_count", "angle", "1", TRUE, TRUE}, - {"angle_count", "angle_label", "1", TRUE, TRUE}, - {"vquality_type_bitrate", "VideoAvgBitrate", "TRUE", FALSE, FALSE}, - {"vquality_type_target", "VideoTargetSize", "TRUE", FALSE, FALSE}, - {"vquality_type_constant", "VideoQualitySlider", "TRUE", FALSE, FALSE}, - {"vquality_type_constant", "VideoTwoPass", "TRUE", TRUE, FALSE}, - {"vquality_type_constant", "VideoTurboTwoPass", "TRUE", TRUE, FALSE}, - {"VideoTwoPass", "VideoTurboTwoPass", "TRUE", FALSE, FALSE}, - {"FileFormat", "Mp4LargeFile", "mp4", FALSE, TRUE}, - {"FileFormat", "Mp4HttpOptimize", "mp4", FALSE, TRUE}, - {"FileFormat", "Mp4iPodCompatible", "mp4", FALSE, TRUE}, - {"PictureDecombDeinterlace", "PictureDeinterlace", "TRUE", TRUE, TRUE}, - {"PictureDecombDeinterlace", "PictureDeinterlaceCustom", "TRUE", TRUE, TRUE}, - {"PictureDecombDeinterlace", "PictureDeinterlaceLabel", "TRUE", TRUE, TRUE}, - {"PictureDecombDeinterlace", "PictureDecomb", "FALSE", TRUE, TRUE}, - {"PictureDecombDeinterlace", "PictureDecombCustom", "FALSE", TRUE, TRUE}, - {"PictureDecombDeinterlace", "PictureDecombLabel", "FALSE", TRUE, TRUE}, - {"PictureDeinterlace", "PictureDeinterlaceCustom", "custom", FALSE, TRUE}, - {"PictureDenoise", "PictureDenoiseCustom", "custom", FALSE, TRUE}, - {"PictureDecomb", "PictureDecombCustom", "custom", FALSE, TRUE}, - {"PictureDetelecine", "PictureDetelecineCustom", "custom", FALSE, TRUE}, - {"PictureAutoCrop", "PictureTopCrop", "FALSE", FALSE, FALSE}, - {"PictureAutoCrop", "PictureBottomCrop", "FALSE", FALSE, FALSE}, - {"PictureAutoCrop", "PictureLeftCrop", "FALSE", FALSE, FALSE}, - {"PictureAutoCrop", "PictureRightCrop", "FALSE", FALSE, FALSE}, - {"VideoEncoder", "x264_tab", "x264", FALSE, FALSE}, - {"VideoEncoder", "x264_tab_label", "x264", FALSE, FALSE}, - {"VideoEncoder", "Mp4iPodCompatible", "x264", FALSE, FALSE}, - {"AudioEncoder", "AudioBitrate", "ac3|dts", TRUE, FALSE}, - {"AudioEncoder", "AudioSamplerate", "ac3|dts", TRUE, FALSE}, - {"AudioEncoder", "AudioMixdown", "ac3|dts", TRUE, FALSE}, - {"AudioEncoder", "AudioTrackDRCSlider", "ac3|dts", TRUE, FALSE}, - {"AudioEncoder", "drc_label", "ac3|dts", TRUE, FALSE}, - {"x264_bframes", "x264_bpyramid", "<2", TRUE, FALSE}, - {"x264_bframes", "x264_direct", "0", TRUE, FALSE}, - {"x264_bframes", "x264_b_adapt", "0", TRUE, FALSE}, - {"x264_cabac", "x264_trellis", "TRUE", FALSE, FALSE}, - {"x264_subme", "x264_psy_rd", "<6", TRUE, FALSE}, - {"x264_subme", "x264_psy_trell", "<6", TRUE, FALSE}, - {"x264_cabac", "x264_psy_trell", "TRUE", FALSE, FALSE}, - {"x264_trellis", "x264_psy_trell", "0", TRUE, FALSE}, - {"ChapterMarkers", "chapters_list", "TRUE", FALSE, FALSE}, - {"use_source_name", "chapters_in_destination", "TRUE", FALSE, FALSE}, - {"use_source_name", "title_no_in_destination", "TRUE", FALSE, FALSE}, -}; - -int -main(gint argc, gchar *argv[]) -{ - gint ii, jj; - GValue *top; - gint count = sizeof(dep_map) / sizeof(dependency_t); - - g_type_init(); - - top = ghb_dict_value_new(); - for (ii = 0; ii < count; ii++) - { - const gchar *name; - GValue *array; - - name = dep_map[ii].widget_name; - if (ghb_dict_lookup(top, name)) - continue; - array = ghb_array_value_new(8); - for (jj = 0; jj < count; jj++) - { - if (strcmp(name, dep_map[jj].widget_name) == 0) - { - ghb_array_append(array, - ghb_value_dup(ghb_string_value(dep_map[jj].dep_name))); - } - } - ghb_dict_insert(top, g_strdup(name), array); - } - ghb_plist_write_file("widget.deps", top); - - // reverse map - top = ghb_dict_value_new(); - for (ii = 0; ii < count; ii++) - { - const gchar *name; - GValue *array; - - name = dep_map[ii].dep_name; - if (ghb_dict_lookup(top, name)) - continue; - array = ghb_array_value_new(8); - for (jj = 0; jj < count; jj++) - { - if (strcmp(name, dep_map[jj].dep_name) == 0) - { - GValue *data; - data = ghb_array_value_new(3); - ghb_array_append(data, ghb_value_dup( - ghb_string_value(dep_map[jj].widget_name))); - ghb_array_append(data, ghb_value_dup( - ghb_string_value(dep_map[jj].enable_value))); - ghb_array_append(data, ghb_value_dup( - ghb_boolean_value(dep_map[jj].disable_if_equal))); - ghb_array_append(data, ghb_value_dup( - ghb_boolean_value(dep_map[jj].hide))); - ghb_array_append(array, data); - } - } - ghb_dict_insert(top, g_strdup(name), array); - } - ghb_plist_write_file("widget_reverse.deps", top); - return 0; -} - |