OSDN Git Service

LinGui: don't disable subme 10 when psy-rd is 0
[handbrake-jp/handbrake-jp-git.git] / gtk / src / hb-backend.c
index eca539e..65f553f 100644 (file)
@@ -31,6 +31,7 @@
 #include "settings.h"
 #include "callbacks.h"
 #include "subtitlehandler.h"
+#include "audiohandler.h"
 #include "x264handler.h"
 #include "preview.h"
 #include "values.h"
@@ -299,6 +300,7 @@ static options_map_t d_subme_opts[] =
        {"7", "7", 7, "7"},
        {"8", "8", 8, "8"},
        {"9", "9", 9, "9"},
+       {"10", "10", 10, "10"},
 };
 combo_opts_t subme_opts =
 {
@@ -415,7 +417,11 @@ const gchar *srt_codeset_table[] =
        "UTF-7",
        "UTF-8",
        "UTF-16",
+       "UTF-16LE",
+       "UTF-16BE",
        "UTF-32",
+       "UTF-32LE",
+       "UTF-32BE",
        NULL
 };
 #define        SRT_TABLE_SIZE (sizeof(srt_codeset_table)/ sizeof(char*)-1)
@@ -470,21 +476,20 @@ const iso639_lang_t ghb_language_table[] =
        { "Cree", "", "cr", "cre" },
        { "Czech", "", "cs", "ces", "cze" },
        { "Danish", "Dansk", "da", "dan" },
+       { "German", "Deutsch", "de", "deu", "ger" },
        { "Divehi", "", "dv", "div" },
-       { "Dutch", "Nederlands", "nl", "nld", "dut" },
        { "Dzongkha", "", "dz", "dzo" },
        { "English", "English", "en", "eng" },
+       { "Spanish", "Espanol", "es", "spa" },
        { "Esperanto", "", "eo", "epo" },
        { "Estonian", "", "et", "est" },
        { "Ewe", "", "ee", "ewe" },
        { "Faroese", "", "fo", "fao" },
        { "Fijian", "", "fj", "fij" },
-       { "Finnish", "Suomi", "fi", "fin" },
        { "French", "Francais", "fr", "fra", "fre" },
        { "Western Frisian", "", "fy", "fry" },
        { "Fulah", "", "ff", "ful" },
        { "Georgian", "", "ka", "kat", "geo" },
-       { "German", "Deutsch", "de", "deu", "ger" },
        { "Gaelic (Scots)", "", "gd", "gla" },
        { "Irish", "", "ga", "gle" },
        { "Galician", "", "gl", "glg" },
@@ -498,10 +503,10 @@ const iso639_lang_t ghb_language_table[] =
        { "Herero", "", "hz", "her" },
        { "Hindi", "", "hi", "hin" },
        { "Hiri Motu", "", "ho", "hmo" },
-       { "Hungarian", "Magyar", "hu", "hun" },
+       { "Croatian", "Hrvatski", "hr", "hrv", "scr" },
        { "Igbo", "", "ig", "ibo" },
-       { "Icelandic", "Islenska", "is", "isl", "ice" },
        { "Ido", "", "io", "ido" },
+       { "Icelandic", "Islenska", "is", "isl", "ice" },
        { "Sichuan Yi", "", "ii", "iii" },
        { "Inuktitut", "", "iu", "iku" },
        { "Interlingue", "", "ie", "ile" },
@@ -535,6 +540,7 @@ const iso639_lang_t ghb_language_table[] =
        { "Luba-Katanga", "", "lu", "lub" },
        { "Ganda", "", "lg", "lug" },
        { "Macedonian", "", "mk", "mkd", "mac" },
+       { "Hungarian", "Magyar", "hu", "hun" },
        { "Marshallese", "", "mh", "mah" },
        { "Malayalam", "", "ml", "mal" },
        { "Maori", "", "mi", "mri", "mao" },
@@ -546,13 +552,14 @@ const iso639_lang_t ghb_language_table[] =
        { "Mongolian", "", "mn", "mon" },
        { "Nauru", "", "na", "nau" },
        { "Navajo", "", "nv", "nav" },
+       { "Dutch", "Nederlands", "nl", "nld", "dut" },
        { "Ndebele, South", "", "nr", "nbl" },
        { "Ndebele, North", "", "nd", "nde" },
        { "Ndonga", "", "ng", "ndo" },
        { "Nepali", "", "ne", "nep" },
+       { "Norwegian", "Norsk", "no", "nor" },
        { "Norwegian Nynorsk", "", "nn", "nno" },
        { "Norwegian Bokmål", "", "nb", "nob" },
-       { "Norwegian", "Norsk", "no", "nor" },
        { "Chichewa; Nyanja", "", "ny", "nya" },
        { "Occitan", "", "oc", "oci" },
        { "Ojibwa", "", "oj", "oji" },
@@ -573,7 +580,6 @@ const iso639_lang_t ghb_language_table[] =
        { "Sango", "", "sg", "sag" },
        { "Sanskrit", "", "sa", "san" },
        { "Serbian", "", "sr", "srp", "scc" },
-       { "Croatian", "Hrvatski", "hr", "hrv", "scr" },
        { "Sinhala", "", "si", "sin" },
        { "Slovak", "", "sk", "slk", "slo" },
        { "Slovenian", "", "sl", "slv" },
@@ -583,10 +589,10 @@ const iso639_lang_t ghb_language_table[] =
        { "Sindhi", "", "sd", "snd" },
        { "Somali", "", "so", "som" },
        { "Sotho, Southern", "", "st", "sot" },
-       { "Spanish", "Espanol", "es", "spa" },
        { "Sardinian", "", "sc", "srd" },
        { "Swati", "", "ss", "ssw" },
        { "Sundanese", "", "su", "sun" },
+       { "Finnish", "Suomi", "fi", "fin" },
        { "Swahili", "", "sw", "swa" },
        { "Swedish", "Svenska", "sv", "swe" },
        { "Tahitian", "", "ty", "tah" },
@@ -1000,7 +1006,10 @@ lookup_audio_lang_option(const GValue *rate)
        {
                if (strcmp(ghb_language_table[ii].iso639_2, str) == 0)
                {
-                       result = ghb_language_table[ii].eng_name;
+                       if (ghb_language_table[ii].native_name[0] != 0)
+                               result = ghb_language_table[ii].native_name;
+                       else
+                               result = ghb_language_table[ii].eng_name;
                        break;
                }
        }
@@ -1158,6 +1167,42 @@ done:
        return name;
 }
 
+gchar*
+ghb_subtitle_track_lang(signal_user_data_t *ud, gint track)
+{
+       gint titleindex;
+
+       titleindex = ghb_settings_combo_int(ud->settings, "title");
+       if (titleindex < 0)
+               goto fail;
+       if (track == -1)
+               return ghb_get_user_audio_lang(ud, titleindex, 0);
+       if (track < 0)
+               goto fail;
+
+       hb_list_t  * list;
+       hb_title_t * title;
+       hb_subtitle_t * sub;
+       
+       if (h_scan == NULL)
+               goto fail;
+
+       list = hb_get_titles( h_scan );
+       if( !hb_list_count( list ) )
+       {
+               /* No valid title, stop right there */
+               goto fail;
+       }
+       title = hb_list_item( list, titleindex );
+       if (title == NULL)      // Bad titleindex
+               goto fail;
+       sub = hb_list_item( title->list_subtitle, track);
+       if (sub != NULL)
+               return g_strdup(sub->iso639_2);
+
+fail:
+       return g_strdup("und");
+}
 
 gint
 ghb_get_title_number(gint titleindex)
@@ -1605,9 +1650,16 @@ language_opts_set(GtkBuilder *builder, const gchar *name)
        gtk_list_store_clear(store);
        for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
        {
+               const gchar *lang;
+
+               if (ghb_language_table[ii].native_name[0] != 0)
+                       lang = ghb_language_table[ii].native_name;
+               else
+                       lang = ghb_language_table[ii].eng_name;
+               
                gtk_list_store_append(store, &iter);
                gtk_list_store_set(store, &iter, 
-                                                  0, ghb_language_table[ii].eng_name, 
+                                                  0, lang,
                                                   1, TRUE, 
                                                   2, ghb_language_table[ii].iso639_2, 
                                                   3, (gdouble)ii, 
@@ -1867,13 +1919,20 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
                index_str_init(LANG_TABLE_SIZE-1);
                for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
                {
-                       subtitle_opts.map[ii+1].option = ghb_language_table[ii].eng_name;
+                       const gchar *lang;
+
+                       if (ghb_language_table[ii].native_name[0] != 0)
+                               lang = ghb_language_table[ii].native_name;
+                       else
+                               lang = ghb_language_table[ii].eng_name;
+
+                       subtitle_opts.map[ii+1].option = lang;
                        subtitle_opts.map[ii+1].shortOpt = index_str[ii];
                        subtitle_opts.map[ii+1].ivalue = ii;
                        subtitle_opts.map[ii+1].svalue = ghb_language_table[ii].iso639_2;
                        gtk_list_store_append(store, &iter);
                        gtk_list_store_set(store, &iter, 
-                                       0, ghb_language_table[ii].eng_name, 
+                                       0, lang,
                                        1, TRUE, 
                                        2, index_str[ii],
                                        3, (gdouble)ii, 
@@ -2109,6 +2168,32 @@ ghb_find_pref_subtitle_track(const gchar *lang)
 }
 
 gint
+ghb_find_cc_track(gint titleindex)
+{
+       hb_list_t  * list;
+       hb_title_t * title;
+       hb_subtitle_t * subtitle;
+       gint count, ii;
+       
+       g_debug("ghb_find_cc_track ()\n");
+       if (h_scan == NULL) return -2;
+       list = hb_get_titles( h_scan );
+       title = (hb_title_t*)hb_list_item( list, titleindex );
+       if (title != NULL)
+       {
+               count = hb_list_count( title->list_subtitle );
+               // Try to find an item that matches the preferred language
+               for (ii = 0; ii < count; ii++)
+               {
+                       subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
+                       if (subtitle->source == CC608SUB || subtitle->source == CC708SUB)
+                               return ii;
+               }
+       }
+       return -2;
+}
+
+gint
 ghb_find_subtitle_track(
        gint titleindex, 
        const gchar *lang, 
@@ -3163,9 +3248,7 @@ ghb_set_scale(signal_user_data_t *ud, gint mode)
                                job->anamorphic.dar_width = 
                                        ghb_settings_get_int(ud->settings, 
                                                                                "PictureDisplayWidth");
-                               job->anamorphic.dar_height =
-                                       ghb_settings_get_int(ud->settings, 
-                                                                               "PictureDisplayHeight");
+                               job->anamorphic.dar_height = height;
                        }
                }
                else
@@ -3380,7 +3463,7 @@ ghb_validate_filters(signal_user_data_t *ud)
        gint index;
        gchar *message;
 
-       // deinte 4
+       // deinte
        index = ghb_settings_combo_int(ud->settings, "PictureDeinterlace");
        if (index == 1)
        {
@@ -3414,12 +3497,12 @@ ghb_validate_filters(signal_user_data_t *ud)
                }
                g_free(str);
        }
-       // decomb 4
+       // decomb
        index = ghb_settings_combo_int(ud->settings, "PictureDecomb");
        if (index == 1)
        {
                str = ghb_settings_get_string(ud->settings, "PictureDecombCustom");
-               if (!ghb_validate_filter_string(str, 7))
+               if (!ghb_validate_filter_string(str, 15))
                {
                        message = g_strdup_printf(
                                                "Invalid Decomb Settings:\n\n%s\n",
@@ -3431,7 +3514,7 @@ ghb_validate_filters(signal_user_data_t *ud)
                }
                g_free(str);
        }
-       // denois 4
+       // denois
        index = ghb_settings_combo_int(ud->settings, "PictureDenoise");
        if (index == 1)
        {
@@ -4491,11 +4574,13 @@ ghb_pause_queue()
 
     if( s.state == HB_STATE_PAUSED )
     {
-        hb_resume( h_queue );
+               hb_status.queue.state &= ~GHB_STATE_PAUSED;
+               hb_resume( h_queue );
     }
     else
     {
-        hb_pause( h_queue );
+               hb_status.queue.state |= GHB_STATE_PAUSED;
+               hb_pause( h_queue );
     }
 }