/src/vlc/modules/demux/mp4/languages.h
Line | Count | Source (jump to first uncovered line) |
1 | | /***************************************************************************** |
2 | | * languages.h: Quicktime language codes and ISO-639-2/T conversion |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2014 VLC authors and VideoLAN |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify it |
7 | | * under the terms of the GNU Lesser General Public License as published by |
8 | | * the Free Software Foundation; either version 2.1 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
19 | | *****************************************************************************/ |
20 | | #ifndef VLC_MP4_LANGUAGES_H_ |
21 | | #define VLC_MP4_LANGUAGES_H_ |
22 | | |
23 | | static bool decodeQtLanguageCode( uint16_t i_language_code, char *psz_iso, |
24 | | bool *b_mactables ) |
25 | 22 | { |
26 | 22 | static const char * psz_qt_to_iso639_2T_lower = |
27 | 22 | "eng" "fra" "deu" "ita" "nld" |
28 | 22 | "swe" "spa" "dan" "por" "nor" /* 5-9 */ |
29 | 22 | "heb" "jpn" "ara" "fin" "gre" |
30 | 22 | "isl" "mlt" "tur" "hrv" "zho" /* 15-19 */ |
31 | 22 | "urd" "hin" "tha" "kor" "lit" |
32 | 22 | "pol" "hun" "est" "lav" "sme" /* 25-29 */ |
33 | 22 | "fao" "fas" "rus" "zho" "nld" /* nld==flemish */ |
34 | 22 | "gle" "sqi" "ron" "ces" "slk" /* 35-39 */ |
35 | 22 | "slv" "yid" "srp" "mkd" "bul" |
36 | 22 | "ukr" "bel" "uzb" "kaz" "aze" /* 45-49 */ |
37 | 22 | "aze" "hye" "kat" "mol" "kir" |
38 | 22 | "tgk" "tuk" "mon" "mon" "pus" /* 55-59 */ |
39 | 22 | "kur" "kas" "snd" "bod" "nep" |
40 | 22 | "san" "mar" "ben" "asm" "guj" /* 65-69 */ |
41 | 22 | "pan" "ori" "mal" "kan" "tam" |
42 | 22 | "tel" "sin" "mya" "khm" "lao" /* 75-79 */ |
43 | 22 | "vie" "ind" "tgl" "msa" "msa" |
44 | 22 | "amh" "tir" "orm" "som" "swa" /* 85-89 */ |
45 | 22 | "kin" "run" "nya" "mlg" "epo" /* 90-94 */ |
46 | 22 | ; |
47 | | |
48 | 22 | static const char * psz_qt_to_iso639_2T_upper = |
49 | 22 | "cym" "eus" "cat" "lat" "que" /* 128-132 */ |
50 | 22 | "grn" "aym" "tat" "uig" "dzo" |
51 | 22 | "jaw" "sun" "glg" "afr" "bre" /* 138-142 */ |
52 | 22 | "iku" "gla" "glv" "gle" "ton" |
53 | 22 | "gre" /* 148 */ |
54 | 22 | ; |
55 | | |
56 | 22 | if ( i_language_code < 0x400 || i_language_code == 0x7FFF ) |
57 | 21 | { |
58 | 21 | const void *p_data; |
59 | 21 | *b_mactables = true; |
60 | 21 | if ( i_language_code <= 94 ) |
61 | 21 | { |
62 | 21 | p_data = psz_qt_to_iso639_2T_lower + i_language_code * 3; |
63 | 21 | } |
64 | 0 | else if ( i_language_code >= 128 && i_language_code <= 148 ) |
65 | 0 | { |
66 | 0 | i_language_code -= 128; |
67 | 0 | p_data = psz_qt_to_iso639_2T_upper + i_language_code * 3; |
68 | 0 | } |
69 | 0 | else |
70 | 0 | return false; |
71 | 21 | memcpy( psz_iso, p_data, 3 ); |
72 | 21 | } |
73 | 1 | else |
74 | 1 | { |
75 | 1 | *b_mactables = false; |
76 | | /* |
77 | | * to build code: ( ( 'f' - 0x60 ) << 10 ) | ( ('r' - 0x60) << 5 ) | ('a' - 0x60) |
78 | | */ |
79 | 1 | if( i_language_code == 0x55C4 ) /* "und" */ |
80 | 1 | { |
81 | 1 | memset( psz_iso, 0, 3 ); |
82 | 1 | return false; |
83 | 1 | } |
84 | | |
85 | 0 | for( unsigned i = 0; i < 3; i++ ) |
86 | 0 | psz_iso[i] = ( ( i_language_code >> ( (2-i)*5 ) )&0x1f ) + 0x60; |
87 | 0 | } |
88 | 21 | return true; |
89 | 22 | } meta.c:decodeQtLanguageCode Line | Count | Source | 25 | 1 | { | 26 | 1 | static const char * psz_qt_to_iso639_2T_lower = | 27 | 1 | "eng" "fra" "deu" "ita" "nld" | 28 | 1 | "swe" "spa" "dan" "por" "nor" /* 5-9 */ | 29 | 1 | "heb" "jpn" "ara" "fin" "gre" | 30 | 1 | "isl" "mlt" "tur" "hrv" "zho" /* 15-19 */ | 31 | 1 | "urd" "hin" "tha" "kor" "lit" | 32 | 1 | "pol" "hun" "est" "lav" "sme" /* 25-29 */ | 33 | 1 | "fao" "fas" "rus" "zho" "nld" /* nld==flemish */ | 34 | 1 | "gle" "sqi" "ron" "ces" "slk" /* 35-39 */ | 35 | 1 | "slv" "yid" "srp" "mkd" "bul" | 36 | 1 | "ukr" "bel" "uzb" "kaz" "aze" /* 45-49 */ | 37 | 1 | "aze" "hye" "kat" "mol" "kir" | 38 | 1 | "tgk" "tuk" "mon" "mon" "pus" /* 55-59 */ | 39 | 1 | "kur" "kas" "snd" "bod" "nep" | 40 | 1 | "san" "mar" "ben" "asm" "guj" /* 65-69 */ | 41 | 1 | "pan" "ori" "mal" "kan" "tam" | 42 | 1 | "tel" "sin" "mya" "khm" "lao" /* 75-79 */ | 43 | 1 | "vie" "ind" "tgl" "msa" "msa" | 44 | 1 | "amh" "tir" "orm" "som" "swa" /* 85-89 */ | 45 | 1 | "kin" "run" "nya" "mlg" "epo" /* 90-94 */ | 46 | 1 | ; | 47 | | | 48 | 1 | static const char * psz_qt_to_iso639_2T_upper = | 49 | 1 | "cym" "eus" "cat" "lat" "que" /* 128-132 */ | 50 | 1 | "grn" "aym" "tat" "uig" "dzo" | 51 | 1 | "jaw" "sun" "glg" "afr" "bre" /* 138-142 */ | 52 | 1 | "iku" "gla" "glv" "gle" "ton" | 53 | 1 | "gre" /* 148 */ | 54 | 1 | ; | 55 | | | 56 | 1 | if ( i_language_code < 0x400 || i_language_code == 0x7FFF ) | 57 | 0 | { | 58 | 0 | const void *p_data; | 59 | 0 | *b_mactables = true; | 60 | 0 | if ( i_language_code <= 94 ) | 61 | 0 | { | 62 | 0 | p_data = psz_qt_to_iso639_2T_lower + i_language_code * 3; | 63 | 0 | } | 64 | 0 | else if ( i_language_code >= 128 && i_language_code <= 148 ) | 65 | 0 | { | 66 | 0 | i_language_code -= 128; | 67 | 0 | p_data = psz_qt_to_iso639_2T_upper + i_language_code * 3; | 68 | 0 | } | 69 | 0 | else | 70 | 0 | return false; | 71 | 0 | memcpy( psz_iso, p_data, 3 ); | 72 | 0 | } | 73 | 1 | else | 74 | 1 | { | 75 | 1 | *b_mactables = false; | 76 | | /* | 77 | | * to build code: ( ( 'f' - 0x60 ) << 10 ) | ( ('r' - 0x60) << 5 ) | ('a' - 0x60) | 78 | | */ | 79 | 1 | if( i_language_code == 0x55C4 ) /* "und" */ | 80 | 1 | { | 81 | 1 | memset( psz_iso, 0, 3 ); | 82 | 1 | return false; | 83 | 1 | } | 84 | | | 85 | 0 | for( unsigned i = 0; i < 3; i++ ) | 86 | 0 | psz_iso[i] = ( ( i_language_code >> ( (2-i)*5 ) )&0x1f ) + 0x60; | 87 | 0 | } | 88 | 0 | return true; | 89 | 1 | } |
libmp4.c:decodeQtLanguageCode Line | Count | Source | 25 | 21 | { | 26 | 21 | static const char * psz_qt_to_iso639_2T_lower = | 27 | 21 | "eng" "fra" "deu" "ita" "nld" | 28 | 21 | "swe" "spa" "dan" "por" "nor" /* 5-9 */ | 29 | 21 | "heb" "jpn" "ara" "fin" "gre" | 30 | 21 | "isl" "mlt" "tur" "hrv" "zho" /* 15-19 */ | 31 | 21 | "urd" "hin" "tha" "kor" "lit" | 32 | 21 | "pol" "hun" "est" "lav" "sme" /* 25-29 */ | 33 | 21 | "fao" "fas" "rus" "zho" "nld" /* nld==flemish */ | 34 | 21 | "gle" "sqi" "ron" "ces" "slk" /* 35-39 */ | 35 | 21 | "slv" "yid" "srp" "mkd" "bul" | 36 | 21 | "ukr" "bel" "uzb" "kaz" "aze" /* 45-49 */ | 37 | 21 | "aze" "hye" "kat" "mol" "kir" | 38 | 21 | "tgk" "tuk" "mon" "mon" "pus" /* 55-59 */ | 39 | 21 | "kur" "kas" "snd" "bod" "nep" | 40 | 21 | "san" "mar" "ben" "asm" "guj" /* 65-69 */ | 41 | 21 | "pan" "ori" "mal" "kan" "tam" | 42 | 21 | "tel" "sin" "mya" "khm" "lao" /* 75-79 */ | 43 | 21 | "vie" "ind" "tgl" "msa" "msa" | 44 | 21 | "amh" "tir" "orm" "som" "swa" /* 85-89 */ | 45 | 21 | "kin" "run" "nya" "mlg" "epo" /* 90-94 */ | 46 | 21 | ; | 47 | | | 48 | 21 | static const char * psz_qt_to_iso639_2T_upper = | 49 | 21 | "cym" "eus" "cat" "lat" "que" /* 128-132 */ | 50 | 21 | "grn" "aym" "tat" "uig" "dzo" | 51 | 21 | "jaw" "sun" "glg" "afr" "bre" /* 138-142 */ | 52 | 21 | "iku" "gla" "glv" "gle" "ton" | 53 | 21 | "gre" /* 148 */ | 54 | 21 | ; | 55 | | | 56 | 21 | if ( i_language_code < 0x400 || i_language_code == 0x7FFF ) | 57 | 21 | { | 58 | 21 | const void *p_data; | 59 | 21 | *b_mactables = true; | 60 | 21 | if ( i_language_code <= 94 ) | 61 | 21 | { | 62 | 21 | p_data = psz_qt_to_iso639_2T_lower + i_language_code * 3; | 63 | 21 | } | 64 | 0 | else if ( i_language_code >= 128 && i_language_code <= 148 ) | 65 | 0 | { | 66 | 0 | i_language_code -= 128; | 67 | 0 | p_data = psz_qt_to_iso639_2T_upper + i_language_code * 3; | 68 | 0 | } | 69 | 0 | else | 70 | 0 | return false; | 71 | 21 | memcpy( psz_iso, p_data, 3 ); | 72 | 21 | } | 73 | 0 | else | 74 | 0 | { | 75 | 0 | *b_mactables = false; | 76 | | /* | 77 | | * to build code: ( ( 'f' - 0x60 ) << 10 ) | ( ('r' - 0x60) << 5 ) | ('a' - 0x60) | 78 | | */ | 79 | 0 | if( i_language_code == 0x55C4 ) /* "und" */ | 80 | 0 | { | 81 | 0 | memset( psz_iso, 0, 3 ); | 82 | 0 | return false; | 83 | 0 | } | 84 | | | 85 | 0 | for( unsigned i = 0; i < 3; i++ ) | 86 | 0 | psz_iso[i] = ( ( i_language_code >> ( (2-i)*5 ) )&0x1f ) + 0x60; | 87 | 0 | } | 88 | 21 | return true; | 89 | 21 | } |
|
90 | | |
91 | | #endif |