diff options
author | saintdev <[email protected]> | 2007-03-26 19:38:24 +0000 |
---|---|---|
committer | saintdev <[email protected]> | 2007-03-26 19:38:24 +0000 |
commit | 5b4288a0466445f060e9897ead19a970724dc8c1 (patch) | |
tree | b7db565592eefdc51db8d448fc9cd23d9d4cf73a | |
parent | 03670893ccd2c2c20081cf57797bf925503762ee (diff) |
Keep the language id for each audio track when using MP4.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@454 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/common.h | 2 | ||||
-rw-r--r-- | libhb/dvd.c | 24 | ||||
-rw-r--r-- | libhb/lang.h | 362 | ||||
-rw-r--r-- | libhb/muxmp4.c | 8 |
4 files changed, 217 insertions, 179 deletions
diff --git a/libhb/common.h b/libhb/common.h index 14f0719a8..d09c2d279 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -221,6 +221,7 @@ struct hb_audio_s int id; char lang[1024]; char lang_simple[1024]; + char iso639_2[4]; int codec; int rate; int bitrate; @@ -267,6 +268,7 @@ struct hb_subtitle_s { int id; char lang[1024]; + char iso639_2[4]; #ifdef __LIBHB__ /* Internal data */ diff --git a/libhb/dvd.c b/libhb/dvd.c index a9bf4309f..9b4ba3fe7 100644 --- a/libhb/dvd.c +++ b/libhb/dvd.c @@ -213,6 +213,7 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t ) hb_audio_t * audio, * audio_tmp; int audio_format, lang_code, audio_control, position, j; + iso639_lang_t * lang; hb_log( "scan: checking audio %d", i + 1 ); @@ -280,15 +281,19 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t ) continue; } + lang = lang_for_code( vts->vtsi_mat->vts_audio_attr[i].lang_code ); + snprintf( audio->lang, sizeof( audio->lang ), "%s (%s)", - lang_for_code( vts->vtsi_mat->vts_audio_attr[i].lang_code ), + strlen(lang->native_name) ? lang->native_name : lang->eng_name, audio->codec == HB_ACODEC_AC3 ? "AC3" : ( audio->codec == HB_ACODEC_MPGA ? "MPEG" : "LPCM" ) ); snprintf( audio->lang_simple, sizeof( audio->lang_simple ), "%s", - lang_for_code( vts->vtsi_mat->vts_audio_attr[i].lang_code ) ); + strlen(lang->native_name) ? lang->native_name : lang->eng_name ); + snprintf( audio->iso639_2, sizeof( audio->iso639_2 ), "%s", + lang->iso639_2); - hb_log( "scan: id=%x, lang=%s", audio->id, - audio->lang ); + hb_log( "scan: id=%x, lang=%s, 3cc=%s", audio->id, + audio->lang, audio->iso639_2 ); hb_list_add( title->list_audio, audio ); } @@ -309,6 +314,7 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t ) hb_subtitle_t * subtitle; int spu_control; int position; + iso639_lang_t * lang; hb_log( "scan: checking subtitle %d", i + 1 ); @@ -340,13 +346,17 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t ) position = ( spu_control >> 24 ) & 0x7F; } + lang = lang_for_code( vts->vtsi_mat->vts_subp_attr[i].lang_code ); + subtitle = calloc( sizeof( hb_subtitle_t ), 1 ); subtitle->id = ( ( 0x20 + position ) << 8 ) | 0xbd; snprintf( subtitle->lang, sizeof( subtitle->lang ), "%s", - lang_for_code( vts->vtsi_mat->vts_subp_attr[i].lang_code ) ); + strlen(lang->native_name) ? lang->native_name : lang->eng_name); + snprintf( subtitle->iso639_2, sizeof( subtitle->iso639_2 ), "%s", + lang->iso639_2); - hb_log( "scan: id=%x, lang=%s", subtitle->id, - subtitle->lang ); + hb_log( "scan: id=%x, lang=%s, 3cc=%s", subtitle->id, + subtitle->lang, subtitle->iso639_2 ); hb_list_add( title->list_subtitle, subtitle ); } diff --git a/libhb/lang.h b/libhb/lang.h index f88f539ff..ac734a7b1 100644 --- a/libhb/lang.h +++ b/libhb/lang.h @@ -12,177 +12,200 @@ typedef struct iso639_lang_t char * eng_name; /* Description in English */ char * native_name; /* Description in native language */ char * iso639_1; /* ISO-639-1 (2 characters) code */ + char * iso639_2; /* ISO-639-2 (3 character) code */ } iso639_lang_t; static const iso639_lang_t languages[] = -{ { "Afar", "", "aa" }, - { "Abkhazian", "", "ab" }, - { "Afrikaans", "", "af" }, - { "Albanian", "", "sq" }, - { "Amharic", "", "am" }, - { "Arabic", "", "ar" }, - { "Armenian", "", "hy" }, - { "Assamese", "", "as" }, - { "Avestan", "", "ae" }, - { "Aymara", "", "ay" }, - { "Azerbaijani", "", "az" }, - { "Bashkir", "", "ba" }, - { "Basque", "", "eu" }, - { "Belarusian", "", "be" }, - { "Bengali", "", "bn" }, - { "Bihari", "", "bh" }, - { "Bislama", "", "bi" }, - { "Bosnian", "", "bs" }, - { "Breton", "", "br" }, - { "Bulgarian", "", "bg" }, - { "Burmese", "", "my" }, - { "Catalan", "", "ca" }, - { "Chamorro", "", "ch" }, - { "Chechen", "", "ce" }, - { "Chinese", "", "zh" }, - { "Church Slavic", "", "cu" }, - { "Chuvash", "", "cv" }, - { "Cornish", "", "kw" }, - { "Corsican", "", "co" }, - { "Czech", "", "cs" }, - { "Danish", "Dansk", "da" }, - { "Dutch", "Nederlands", "nl" }, - { "Dzongkha", "", "dz" }, - { "English", "English", "en" }, - { "Esperanto", "", "eo" }, - { "Estonian", "", "et" }, - { "Faroese", "", "fo" }, - { "Fijian", "", "fj" }, - { "Finnish", "Suomi", "fi" }, - { "French", "Francais", "fr" }, - { "Frisian", "", "fy" }, - { "Georgian", "", "ka" }, - { "German", "Deutsch", "de" }, - { "Gaelic (Scots)", "", "gd" }, - { "Irish", "", "ga" }, - { "Gallegan", "", "gl" }, - { "Manx", "", "gv" }, - { "Greek, Modern ()", "", "el" }, - { "Guarani", "", "gn" }, - { "Gujarati", "", "gu" }, - { "Hebrew", "", "he" }, - { "Herero", "", "hz" }, - { "Hindi", "", "hi" }, - { "Hiri Motu", "", "ho" }, - { "Hungarian", "Magyar", "hu" }, - { "Icelandic", "Islenska", "is" }, - { "Inuktitut", "", "iu" }, - { "Interlingue", "", "ie" }, - { "Interlingua", "", "ia" }, - { "Indonesian", "", "id" }, - { "Inupiaq", "", "ik" }, - { "Italian", "Italiano", "it" }, - { "Javanese", "", "jv" }, - { "Japanese", "", "ja" }, - { "Kalaallisut (Greenlandic)", "", "kl" }, - { "Kannada", "", "kn" }, - { "Kashmiri", "", "ks" }, - { "Kazakh", "", "kk" }, - { "Khmer", "", "km" }, - { "Kikuyu", "", "ki" }, - { "Kinyarwanda", "", "rw" }, - { "Kirghiz", "", "ky" }, - { "Komi", "", "kv" }, - { "Korean", "", "ko" }, - { "Kuanyama", "", "kj" }, - { "Kurdish", "", "ku" }, - { "Lao", "", "lo" }, - { "Latin", "", "la" }, - { "Latvian", "", "lv" }, - { "Lingala", "", "ln" }, - { "Lithuanian", "", "lt" }, - { "Letzeburgesch", "", "lb" }, - { "Macedonian", "", "mk" }, - { "Marshall", "", "mh" }, - { "Malayalam", "", "ml" }, - { "Maori", "", "mi" }, - { "Marathi", "", "mr" }, - { "Malay", "", "ms" }, - { "Malagasy", "", "mg" }, - { "Maltese", "", "mt" }, - { "Moldavian", "", "mo" }, - { "Mongolian", "", "mn" }, - { "Nauru", "", "na" }, - { "Navajo", "", "nv" }, - { "Ndebele, South", "", "nr" }, - { "Ndebele, North", "", "nd" }, - { "Ndonga", "", "ng" }, - { "Nepali", "", "ne" }, - { "Norwegian", "Norsk", "no" }, - { "Norwegian Nynorsk", "", "nn" }, - { "Norwegian Bokmål", "", "nb" }, - { "Chichewa; Nyanja", "", "ny" }, - { "Occitan (post 1500); Provençal", "", "oc" }, - { "Oriya", "", "or" }, - { "Oromo", "", "om" }, - { "Ossetian; Ossetic", "", "os" }, - { "Panjabi", "", "pa" }, - { "Persian", "", "fa" }, - { "Pali", "", "pi" }, - { "Polish", "", "pl" }, - { "Portuguese", "Portugues", "pt" }, - { "Pushto", "", "ps" }, - { "Quechua", "", "qu" }, - { "Raeto-Romance", "", "rm" }, - { "Romanian", "", "ro" }, - { "Rundi", "", "rn" }, - { "Russian", "", "ru" }, - { "Sango", "", "sg" }, - { "Sanskrit", "", "sa" }, - { "Serbian", "", "sr" }, - { "Croatian", "Hrvatski", "hr" }, - { "Sinhalese", "", "si" }, - { "Slovak", "", "sk" }, - { "Slovenian", "", "sl" }, - { "Northern Sami", "", "se" }, - { "Samoan", "", "sm" }, - { "Shona", "", "sn" }, - { "Sindhi", "", "sd" }, - { "Somali", "", "so" }, - { "Sotho, Southern", "", "st" }, - { "Spanish", "Espanol", "es" }, - { "Sardinian", "", "sc" }, - { "Swati", "", "ss" }, - { "Sundanese", "", "su" }, - { "Swahili", "", "sw" }, - { "Swedish", "Svenska", "sv" }, - { "Tahitian", "", "ty" }, - { "Tamil", "", "ta" }, - { "Tatar", "", "tt" }, - { "Telugu", "", "te" }, - { "Tajik", "", "tg" }, - { "Tagalog", "", "tl" }, - { "Thai", "", "th" }, - { "Tibetan", "", "bo" }, - { "Tigrinya", "", "ti" }, - { "Tonga (Tonga Islands)", "", "to" }, - { "Tswana", "", "tn" }, - { "Tsonga", "", "ts" }, - { "Turkish", "", "tr" }, - { "Turkmen", "", "tk" }, - { "Twi", "", "tw" }, - { "Uighur", "", "ug" }, - { "Ukrainian", "", "uk" }, - { "Urdu", "", "ur" }, - { "Uzbek", "", "uz" }, - { "Vietnamese", "", "vi" }, - { "Volapük", "", "vo" }, - { "Welsh", "", "cy" }, - { "Wolof", "", "wo" }, - { "Xhosa", "", "xh" }, - { "Yiddish", "", "yi" }, - { "Yoruba", "", "yo" }, - { "Zhuang", "", "za" }, - { "Zulu", "", "zu" }, +{ { "Unknown", "", "", "und" }, + { "Afar", "", "aa", "aar" }, + { "Abkhazian", "", "ab", "abk" }, + { "Afrikaans", "", "af", "afr" }, + { "Akan", "", "ak", "aka" }, + { "Albanian", "", "sq", "alb" }, + { "Amharic", "", "am", "amh" }, + { "Arabic", "", "ar", "ara" }, + { "Aragonese", "", "an", "arg" }, + { "Armenian", "", "hy", "arm" }, + { "Assamese", "", "as", "asm" }, + { "Avaric", "", "av", "ava" }, + { "Avestan", "", "ae", "ave" }, + { "Aymara", "", "ay", "aym" }, + { "Azerbaijani", "", "az", "aze" }, + { "Bashkir", "", "ba", "bak" }, + { "Bambara", "", "bm", "bam" }, + { "Basque", "", "eu", "baq" }, + { "Belarusian", "", "be", "bel" }, + { "Bengali", "", "bn", "ben" }, + { "Bihari", "", "bh", "bih" }, + { "Bislama", "", "bi", "bis" }, + { "Bosnian", "", "bs", "bos" }, + { "Breton", "", "br", "bre" }, + { "Bulgarian", "", "bg", "bul" }, + { "Burmese", "", "my", "bur" }, + { "Catalan", "", "ca", "cat" }, + { "Chamorro", "", "ch", "cha" }, + { "Chechen", "", "ce", "che" }, + { "Chinese", "", "zh", "chi" }, + { "Church Slavic", "", "cu", "chu" }, + { "Chuvash", "", "cv", "chv" }, + { "Cornish", "", "kw", "cor" }, + { "Corsican", "", "co", "cos" }, + { "Cree", "", "cr", "cre" }, + { "Czech", "", "cs", "cze" }, + { "Danish", "Dansk", "da", "dan" }, + { "Divehi", "", "dv", "div" }, + { "Dutch", "Nederlands", "nl", "dut" }, + { "Dzongkha", "", "dz", "dzo" }, + { "English", "English", "en", "eng" }, + { "Esperanto", "", "eo", "epo" }, + { "Estonian", "", "et", "est" }, + { "Ewe", "", "ee", "ewe" }, + { "Faroese", "", "fo", "fao" }, + { "Fijian", "", "fj", "fij" }, + { "Finnish", "Suomi", "fi", "fin" }, + { "French", "Francais", "fr", "fre" }, + { "Western Frisian", "", "fy", "fry" }, + { "Fulah", "", "ff", "ful" }, + { "Georgian", "", "ka", "geo" }, + { "German", "Deutsch", "de", "ger" }, + { "Gaelic (Scots)", "", "gd", "gla" }, + { "Irish", "", "ga", "gle" }, + { "Galician", "", "gl", "glg" }, + { "Manx", "", "gv", "glv" }, + { "Greek, Modern", "", "el", "gre" }, + { "Guarani", "", "gn", "grn" }, + { "Gujarati", "", "gu", "guj" }, + { "Haitian", "", "ht", "hat" }, + { "Hausa", "", "ha", "hau" }, + { "Hebrew", "", "he", "heb" }, + { "Herero", "", "hz", "her" }, + { "Hindi", "", "hi", "hin" }, + { "Hiri Motu", "", "ho", "hmo" }, + { "Hungarian", "Magyar", "hu", "hun" }, + { "Igbo", "", "ig", "ibo" }, + { "Icelandic", "Islenska", "is", "ice" }, + { "Ido", "", "io", "ido" }, + { "Sichuan Yi", "", "ii", "iii" }, + { "Inuktitut", "", "iu", "iku" }, + { "Interlingue", "", "ie", "ile" }, + { "Interlingua", "", "ia", "ina" }, + { "Indonesian", "", "id", "ind" }, + { "Inupiaq", "", "ik", "ipk" }, + { "Italian", "Italiano", "it", "ita" }, + { "Javanese", "", "jv", "jav" }, + { "Japanese", "", "ja", "jpn" }, + { "Kalaallisut (Greenlandic)", "", "kl", "kal" }, + { "Kannada", "", "kn", "kan" }, + { "Kashmiri", "", "ks", "kas" }, + { "Kanuri", "", "kr", "kau" }, + { "Kazakh", "", "kk", "kaz" }, + { "Central Khmer", "", "km", "khm" }, + { "Kikuyu", "", "ki", "kik" }, + { "Kinyarwanda", "", "rw", "kin" }, + { "Kirghiz", "", "ky", "kir" }, + { "Komi", "", "kv", "kom" }, + { "Kongo", "", "kg", "kon" }, + { "Korean", "", "ko", "kor" }, + { "Kuanyama", "", "kj", "kua" }, + { "Kurdish", "", "ku", "kur" }, + { "Lao", "", "lo", "lao" }, + { "Latin", "", "la", "lat" }, + { "Latvian", "", "lv", "lav" }, + { "Limburgan", "", "li", "lim" }, + { "Lingala", "", "ln", "lin" }, + { "Lithuanian", "", "lt", "lit" }, + { "Luxembourgish", "", "lb", "ltz" }, + { "Luba-Katanga", "", "lu", "lub" }, + { "Ganda", "", "lg", "lug" }, + { "Macedonian", "", "mk", "mac" }, + { "Marshallese", "", "mh", "mah" }, + { "Malayalam", "", "ml", "mal" }, + { "Maori", "", "mi", "mao" }, + { "Marathi", "", "mr", "mar" }, + { "Malay", "", "ms", "may" }, + { "Malagasy", "", "mg", "mlg" }, + { "Maltese", "", "mt", "mlt" }, + { "Moldavian", "", "mo", "mol" }, + { "Mongolian", "", "mn", "mon" }, + { "Nauru", "", "na", "nau" }, + { "Navajo", "", "nv", "nav" }, + { "Ndebele, South", "", "nr", "nbl" }, + { "Ndebele, North", "", "nd", "nde" }, + { "Ndonga", "", "ng", "ndo" }, + { "Nepali", "", "ne", "nep" }, + { "Norwegian Nynorsk", "", "nn", "nno" }, + { "Norwegian Bokmål", "", "nb", "nob" }, + { "Norwegian", "Norsk", "no", "nor" }, + { "Chichewa; Nyanja", "", "ny", "nya" }, + { "Occitan (post 1500); Provençal", "", "oc", "oci" }, + { "Ojibwa", "", "oj", "oji" }, + { "Oriya", "", "or", "ori" }, + { "Oromo", "", "om", "orm" }, + { "Ossetian; Ossetic", "", "os", "oss" }, + { "Panjabi", "", "pa", "pan" }, + { "Persian", "", "fa", "per" }, + { "Pali", "", "pi", "pli" }, + { "Polish", "", "pl", "pol" }, + { "Portuguese", "Portugues", "pt", "por" }, + { "Pushto", "", "ps", "pus" }, + { "Quechua", "", "qu", "que" }, + { "Romansh", "", "rm", "roh" }, + { "Romanian", "", "ro", "rum" }, + { "Rundi", "", "rn", "run" }, + { "Russian", "", "ru", "rus" }, + { "Sango", "", "sg", "sag" }, + { "Sanskrit", "", "sa", "san" }, + { "Serbian", "", "sr", "scc" }, + { "Croatian", "Hrvatski", "hr", "scr" }, + { "Sinhala", "", "si", "sin" }, + { "Slovak", "", "sk", "slo" }, + { "Slovenian", "", "sl", "slv" }, + { "Northern Sami", "", "se", "sme" }, + { "Samoan", "", "sm", "smo" }, + { "Shona", "", "sn", "sna" }, + { "Sindhi", "", "sd", "snd" }, + { "Somali", "", "so", "som" }, + { "Sotho, Southern", "", "st", "sot" }, + { "Spanish", "Espanol", "es", "spa" }, + { "Sardinian", "", "sc", "srd" }, + { "Swati", "", "ss", "ssw" }, + { "Sundanese", "", "su", "sun" }, + { "Swahili", "", "sw", "swa" }, + { "Swedish", "Svenska", "sv", "swe" }, + { "Tahitian", "", "ty", "tah" }, + { "Tamil", "", "ta", "tam" }, + { "Tatar", "", "tt", "tat" }, + { "Telugu", "", "te", "tel" }, + { "Tajik", "", "tg", "tgk" }, + { "Tagalog", "", "tl", "tgl" }, + { "Thai", "", "th", "tha" }, + { "Tibetan", "", "bo", "tib" }, + { "Tigrinya", "", "ti", "tir" }, + { "Tonga (Tonga Islands)", "", "to", "ton" }, + { "Tswana", "", "tn", "tsn" }, + { "Tsonga", "", "ts", "tso" }, + { "Turkmen", "", "tk", "tuk" }, + { "Turkish", "", "tr", "tur" }, + { "Twi", "", "tw", "twi" }, + { "Uighur", "", "ug", "uig" }, + { "Ukrainian", "", "uk", "ukr" }, + { "Urdu", "", "ur", "urd" }, + { "Uzbek", "", "uz", "uzb" }, + { "Venda", "", "ve", "ven" }, + { "Vietnamese", "", "vi", "vie" }, + { "Volapük", "", "vo", "vol" }, + { "Welsh", "", "cy", "wel" }, + { "Walloon", "", "wa", "wln" }, + { "Wolof", "", "wo", "wol" }, + { "Xhosa", "", "xh", "xho" }, + { "Yiddish", "", "yi", "yid" }, + { "Yoruba", "", "yo", "yor" }, + { "Zhuang", "", "za", "zha" }, + { "Zulu", "", "zu", "zul" }, { NULL, NULL, NULL } }; -static char * lang_for_code( int code ) +iso639_lang_t * lang_for_code( int code ) { char code_string[2]; iso639_lang_t * lang; @@ -194,16 +217,11 @@ static char * lang_for_code( int code ) { if( !strncmp( lang->iso639_1, code_string, 2 ) ) { - if( *lang->native_name ) - { - return lang->native_name; - } - - return lang->eng_name; + return lang; } } - return "Unknown"; + return (iso639_lang_t*) languages; } #endif diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c index 458de7be3..f06527295 100644 --- a/libhb/muxmp4.c +++ b/libhb/muxmp4.c @@ -44,6 +44,7 @@ static int MP4Init( hb_mux_object_t * m ) hb_audio_t * audio; hb_mux_data_t * mux_data; int i; + u_int16_t language_code; /* Create an empty mp4 file */ m->file = MP4Create( job->file, MP4_DETAILS_ERROR, 0 ); @@ -164,6 +165,13 @@ static int MP4Init( hb_mux_object_t * m ) MP4SetAudioProfileLevel( m->file, 0x0F ); MP4SetTrackESConfiguration( m->file, mux_data->track, audio->config.aac.bytes, audio->config.aac.length ); + + /* Set the language for this track */ + /* The language is stored as 5-bit text - 0x60 */ + language_code = audio->iso639_2[0] - 0x60; language_code <<= 5; + language_code |= audio->iso639_2[1] - 0x60; language_code <<= 5; + language_code |= audio->iso639_2[2] - 0x60; + MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.mdhd.language", language_code); /* store a reference to the first audio track, so we can use it to feed the chapter text track's sample rate */ |