Coverage Report

Created: 2025-10-12 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/modules/demux/mp4/languages.h
Line
Count
Source
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
8.04k
{
26
8.04k
    static const char * psz_qt_to_iso639_2T_lower =
27
8.04k
            "eng"    "fra"    "deu"    "ita"    "nld"
28
8.04k
            "swe"    "spa"    "dan"    "por"    "nor" /* 5-9 */
29
8.04k
            "heb"    "jpn"    "ara"    "fin"    "gre"
30
8.04k
            "isl"    "mlt"    "tur"    "hrv"    "zho" /* 15-19 */
31
8.04k
            "urd"    "hin"    "tha"    "kor"    "lit"
32
8.04k
            "pol"    "hun"    "est"    "lav"    "sme" /* 25-29 */
33
8.04k
            "fao"    "fas"    "rus"    "zho"    "nld" /* nld==flemish */
34
8.04k
            "gle"    "sqi"    "ron"    "ces"    "slk" /* 35-39 */
35
8.04k
            "slv"    "yid"    "srp"    "mkd"    "bul"
36
8.04k
            "ukr"    "bel"    "uzb"    "kaz"    "aze" /* 45-49 */
37
8.04k
            "aze"    "hye"    "kat"    "mol"    "kir"
38
8.04k
            "tgk"    "tuk"    "mon"    "mon"    "pus" /* 55-59 */
39
8.04k
            "kur"    "kas"    "snd"    "bod"    "nep"
40
8.04k
            "san"    "mar"    "ben"    "asm"    "guj" /* 65-69 */
41
8.04k
            "pan"    "ori"    "mal"    "kan"    "tam"
42
8.04k
            "tel"    "sin"    "mya"    "khm"    "lao" /* 75-79 */
43
8.04k
            "vie"    "ind"    "tgl"    "msa"    "msa"
44
8.04k
            "amh"    "tir"    "orm"    "som"    "swa" /* 85-89 */
45
8.04k
            "kin"    "run"    "nya"    "mlg"    "epo" /* 90-94 */
46
8.04k
            ;
47
48
8.04k
    static const char * psz_qt_to_iso639_2T_upper =
49
8.04k
            "cym"    "eus"    "cat"    "lat"    "que" /* 128-132 */
50
8.04k
            "grn"    "aym"    "tat"    "uig"    "dzo"
51
8.04k
            "jaw"    "sun"    "glg"    "afr"    "bre" /* 138-142 */
52
8.04k
            "iku"    "gla"    "glv"    "gle"    "ton"
53
8.04k
            "gre"                                     /* 148 */
54
8.04k
            ;
55
56
8.04k
    if ( i_language_code < 0x400 || i_language_code == 0x7FFF )
57
3.93k
    {
58
3.93k
        const void *p_data;
59
3.93k
        *b_mactables = true;
60
3.93k
        if ( i_language_code <= 94 )
61
3.51k
        {
62
3.51k
            p_data = psz_qt_to_iso639_2T_lower + i_language_code * 3;
63
3.51k
        }
64
425
        else if ( i_language_code >= 128 && i_language_code <= 148 )
65
42
        {
66
42
            i_language_code -= 128;
67
42
            p_data = psz_qt_to_iso639_2T_upper + i_language_code * 3;
68
42
        }
69
383
        else
70
383
            return false;
71
3.55k
        memcpy( psz_iso, p_data, 3 );
72
3.55k
    }
73
4.10k
    else
74
4.10k
    {
75
4.10k
        *b_mactables = false;
76
        /*
77
         * to build code: ( ( 'f' - 0x60 ) << 10 ) | ( ('r' - 0x60) << 5 ) | ('a' - 0x60)
78
         */
79
4.10k
        if( i_language_code == 0x55C4 ) /* "und" */
80
2.27k
        {
81
2.27k
            memset( psz_iso, 0, 3 );
82
2.27k
            return false;
83
2.27k
        }
84
85
7.31k
        for( unsigned i = 0; i < 3; i++ )
86
5.48k
            psz_iso[i] = ( ( i_language_code >> ( (2-i)*5 ) )&0x1f ) + 0x60;
87
1.82k
    }
88
5.38k
    return true;
89
8.04k
}
meta.c:decodeQtLanguageCode
Line
Count
Source
25
1.45k
{
26
1.45k
    static const char * psz_qt_to_iso639_2T_lower =
27
1.45k
            "eng"    "fra"    "deu"    "ita"    "nld"
28
1.45k
            "swe"    "spa"    "dan"    "por"    "nor" /* 5-9 */
29
1.45k
            "heb"    "jpn"    "ara"    "fin"    "gre"
30
1.45k
            "isl"    "mlt"    "tur"    "hrv"    "zho" /* 15-19 */
31
1.45k
            "urd"    "hin"    "tha"    "kor"    "lit"
32
1.45k
            "pol"    "hun"    "est"    "lav"    "sme" /* 25-29 */
33
1.45k
            "fao"    "fas"    "rus"    "zho"    "nld" /* nld==flemish */
34
1.45k
            "gle"    "sqi"    "ron"    "ces"    "slk" /* 35-39 */
35
1.45k
            "slv"    "yid"    "srp"    "mkd"    "bul"
36
1.45k
            "ukr"    "bel"    "uzb"    "kaz"    "aze" /* 45-49 */
37
1.45k
            "aze"    "hye"    "kat"    "mol"    "kir"
38
1.45k
            "tgk"    "tuk"    "mon"    "mon"    "pus" /* 55-59 */
39
1.45k
            "kur"    "kas"    "snd"    "bod"    "nep"
40
1.45k
            "san"    "mar"    "ben"    "asm"    "guj" /* 65-69 */
41
1.45k
            "pan"    "ori"    "mal"    "kan"    "tam"
42
1.45k
            "tel"    "sin"    "mya"    "khm"    "lao" /* 75-79 */
43
1.45k
            "vie"    "ind"    "tgl"    "msa"    "msa"
44
1.45k
            "amh"    "tir"    "orm"    "som"    "swa" /* 85-89 */
45
1.45k
            "kin"    "run"    "nya"    "mlg"    "epo" /* 90-94 */
46
1.45k
            ;
47
48
1.45k
    static const char * psz_qt_to_iso639_2T_upper =
49
1.45k
            "cym"    "eus"    "cat"    "lat"    "que" /* 128-132 */
50
1.45k
            "grn"    "aym"    "tat"    "uig"    "dzo"
51
1.45k
            "jaw"    "sun"    "glg"    "afr"    "bre" /* 138-142 */
52
1.45k
            "iku"    "gla"    "glv"    "gle"    "ton"
53
1.45k
            "gre"                                     /* 148 */
54
1.45k
            ;
55
56
1.45k
    if ( i_language_code < 0x400 || i_language_code == 0x7FFF )
57
625
    {
58
625
        const void *p_data;
59
625
        *b_mactables = true;
60
625
        if ( i_language_code <= 94 )
61
463
        {
62
463
            p_data = psz_qt_to_iso639_2T_lower + i_language_code * 3;
63
463
        }
64
162
        else if ( i_language_code >= 128 && i_language_code <= 148 )
65
18
        {
66
18
            i_language_code -= 128;
67
18
            p_data = psz_qt_to_iso639_2T_upper + i_language_code * 3;
68
18
        }
69
144
        else
70
144
            return false;
71
481
        memcpy( psz_iso, p_data, 3 );
72
481
    }
73
825
    else
74
825
    {
75
825
        *b_mactables = false;
76
        /*
77
         * to build code: ( ( 'f' - 0x60 ) << 10 ) | ( ('r' - 0x60) << 5 ) | ('a' - 0x60)
78
         */
79
825
        if( i_language_code == 0x55C4 ) /* "und" */
80
4
        {
81
4
            memset( psz_iso, 0, 3 );
82
4
            return false;
83
4
        }
84
85
3.28k
        for( unsigned i = 0; i < 3; i++ )
86
2.46k
            psz_iso[i] = ( ( i_language_code >> ( (2-i)*5 ) )&0x1f ) + 0x60;
87
821
    }
88
1.30k
    return true;
89
1.45k
}
libmp4.c:decodeQtLanguageCode
Line
Count
Source
25
6.59k
{
26
6.59k
    static const char * psz_qt_to_iso639_2T_lower =
27
6.59k
            "eng"    "fra"    "deu"    "ita"    "nld"
28
6.59k
            "swe"    "spa"    "dan"    "por"    "nor" /* 5-9 */
29
6.59k
            "heb"    "jpn"    "ara"    "fin"    "gre"
30
6.59k
            "isl"    "mlt"    "tur"    "hrv"    "zho" /* 15-19 */
31
6.59k
            "urd"    "hin"    "tha"    "kor"    "lit"
32
6.59k
            "pol"    "hun"    "est"    "lav"    "sme" /* 25-29 */
33
6.59k
            "fao"    "fas"    "rus"    "zho"    "nld" /* nld==flemish */
34
6.59k
            "gle"    "sqi"    "ron"    "ces"    "slk" /* 35-39 */
35
6.59k
            "slv"    "yid"    "srp"    "mkd"    "bul"
36
6.59k
            "ukr"    "bel"    "uzb"    "kaz"    "aze" /* 45-49 */
37
6.59k
            "aze"    "hye"    "kat"    "mol"    "kir"
38
6.59k
            "tgk"    "tuk"    "mon"    "mon"    "pus" /* 55-59 */
39
6.59k
            "kur"    "kas"    "snd"    "bod"    "nep"
40
6.59k
            "san"    "mar"    "ben"    "asm"    "guj" /* 65-69 */
41
6.59k
            "pan"    "ori"    "mal"    "kan"    "tam"
42
6.59k
            "tel"    "sin"    "mya"    "khm"    "lao" /* 75-79 */
43
6.59k
            "vie"    "ind"    "tgl"    "msa"    "msa"
44
6.59k
            "amh"    "tir"    "orm"    "som"    "swa" /* 85-89 */
45
6.59k
            "kin"    "run"    "nya"    "mlg"    "epo" /* 90-94 */
46
6.59k
            ;
47
48
6.59k
    static const char * psz_qt_to_iso639_2T_upper =
49
6.59k
            "cym"    "eus"    "cat"    "lat"    "que" /* 128-132 */
50
6.59k
            "grn"    "aym"    "tat"    "uig"    "dzo"
51
6.59k
            "jaw"    "sun"    "glg"    "afr"    "bre" /* 138-142 */
52
6.59k
            "iku"    "gla"    "glv"    "gle"    "ton"
53
6.59k
            "gre"                                     /* 148 */
54
6.59k
            ;
55
56
6.59k
    if ( i_language_code < 0x400 || i_language_code == 0x7FFF )
57
3.31k
    {
58
3.31k
        const void *p_data;
59
3.31k
        *b_mactables = true;
60
3.31k
        if ( i_language_code <= 94 )
61
3.04k
        {
62
3.04k
            p_data = psz_qt_to_iso639_2T_lower + i_language_code * 3;
63
3.04k
        }
64
263
        else if ( i_language_code >= 128 && i_language_code <= 148 )
65
24
        {
66
24
            i_language_code -= 128;
67
24
            p_data = psz_qt_to_iso639_2T_upper + i_language_code * 3;
68
24
        }
69
239
        else
70
239
            return false;
71
3.07k
        memcpy( psz_iso, p_data, 3 );
72
3.07k
    }
73
3.28k
    else
74
3.28k
    {
75
3.28k
        *b_mactables = false;
76
        /*
77
         * to build code: ( ( 'f' - 0x60 ) << 10 ) | ( ('r' - 0x60) << 5 ) | ('a' - 0x60)
78
         */
79
3.28k
        if( i_language_code == 0x55C4 ) /* "und" */
80
2.27k
        {
81
2.27k
            memset( psz_iso, 0, 3 );
82
2.27k
            return false;
83
2.27k
        }
84
85
4.02k
        for( unsigned i = 0; i < 3; i++ )
86
3.02k
            psz_iso[i] = ( ( i_language_code >> ( (2-i)*5 ) )&0x1f ) + 0x60;
87
1.00k
    }
88
4.07k
    return true;
89
6.59k
}
90
91
#endif