[vlc-commits] demux: mp4: add new language conversion tables

Francois Cartegnie git at videolan.org
Sun Sep 28 07:18:47 CEST 2014


vlc/vlc-2.2 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Sep 26 15:57:27 2014 +0200| [42100068b054f248a8e271c826086bfdcc0ed2e1] | committer: Jean-Baptiste Kempf

demux: mp4: add new language conversion tables

(cherry picked from commit 2a3c52805fe2527c97310c7a7f59178633a1da1e)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=42100068b054f248a8e271c826086bfdcc0ed2e1
---

 modules/demux/Makefile.am     |    3 +-
 modules/demux/mp4/languages.h |   91 +++++++++++++++++++++++++++++++++++++++++
 modules/demux/mp4/libmp4.c    |    1 +
 3 files changed, 94 insertions(+), 1 deletion(-)

diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index 75f5b52..995c6d9 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -187,7 +187,8 @@ demux_LTLIBRARIES += $(LTLIBmkv)
 EXTRA_LTLIBRARIES += libmkv_plugin.la
 
 libmp4_plugin_la_SOURCES = demux/mp4/mp4.c demux/mp4/mp4.h \
-                           demux/mp4/libmp4.c demux/mp4/libmp4.h demux/mp4/id3genres.h
+                           demux/mp4/libmp4.c demux/mp4/libmp4.h \
+                           demux/mp4/id3genres.h demux/mp4/languages.h
 libmp4_plugin_la_LIBADD = $(LIBM)
 libmp4_plugin_la_LDFLAGS = $(AM_LDFLAGS)
 if HAVE_ZLIB
diff --git a/modules/demux/mp4/languages.h b/modules/demux/mp4/languages.h
new file mode 100644
index 0000000..de7b04a
--- /dev/null
+++ b/modules/demux/mp4/languages.h
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * languages.h: Quicktime language codes and ISO-639-2/T conversion
+ *****************************************************************************
+ * Copyright (C) 2014 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+#ifndef _VLC_MP4_LANGUAGES_H
+#define _VLC_MP4_LANGUAGES_H 1
+
+static bool decodeQtLanguageCode( uint16_t i_language_code, char *psz_iso,
+                                  bool *b_mactables )
+{
+    static const char * psz_qt_to_iso639_2T_lower =
+            "eng"    "fra"    "deu"    "ita"    "nld"
+            "swe"    "spa"    "dan"    "por"    "nor" /* 5-9 */
+            "heb"    "jpn"    "ara"    "fin"    "gre"
+            "isl"    "mlt"    "tur"    "hrv"    "zho" /* 15-19 */
+            "urd"    "hin"    "tha"    "kor"    "lit"
+            "pol"    "hun"    "est"    "lav"    "sme" /* 25-29 */
+            "fao"    "fas"    "rus"    "zho"    "nld" /* nld==flemish */
+            "gle"    "sqi"    "ron"    "ces"    "slk" /* 35-39 */
+            "slv"    "yid"    "srp"    "mkd"    "bul"
+            "ukr"    "bel"    "uzb"    "kaz"    "aze" /* 45-49 */
+            "aze"    "hye"    "kat"    "mol"    "kir"
+            "tgk"    "tuk"    "mon"    "mon"    "pus" /* 55-59 */
+            "kur"    "kas"    "snd"    "bod"    "nep"
+            "san"    "mar"    "ben"    "asm"    "guj" /* 65-69 */
+            "pan"    "ori"    "mal"    "kan"    "tam"
+            "tel"    "sin"    "mya"    "khm"    "lao" /* 75-79 */
+            "vie"    "ind"    "tgl"    "msa"    "msa"
+            "amh"    "tir"    "orm"    "som"    "swa" /* 85-89 */
+            "kin"    "run"    "nya"    "mlg"    "epo" /* 90-94 */
+            ;
+
+    static const char * psz_qt_to_iso639_2T_upper =
+            "cym"    "eus"    "cat"    "lat"    "que" /* 128-132 */
+            "grn"    "aym"    "tat"    "uig"    "dzo"
+            "jaw"    "sun"    "glg"    "afr"    "bre" /* 138-142 */
+            "iku"    "gla"    "glv"    "gle"    "ton"
+            "gre"                                     /* 148 */
+            ;
+
+    if ( i_language_code < 0x400 || i_language_code == 0x7FFF )
+    {
+        const void *p_data;
+        *b_mactables = true;
+        if ( i_language_code <= 94 )
+        {
+            p_data = psz_qt_to_iso639_2T_lower + i_language_code * 3;
+        }
+        else if ( i_language_code >= 128 && i_language_code <= 148 )
+        {
+            i_language_code -= 128;
+            p_data = psz_qt_to_iso639_2T_upper + i_language_code * 3;
+        }
+        else
+            return false;
+        memcpy( psz_iso, p_data, 3 );
+    }
+    else
+    {
+        *b_mactables = false;
+        /*
+         * to build code: ( ( 'f' - 0x60 ) << 10 ) | ( ('r' - 0x60) << 5 ) | ('a' - 0x60)
+         */
+        if( i_language_code == 0x55C4 ) /* "und" */
+        {
+            memset( psz_iso, 0, 3 );
+            return false;
+        }
+
+        for( unsigned i = 0; i < 3; i++ )
+            psz_iso[i] = ( ( i_language_code >> ( (2-i)*5 ) )&0x1f ) + 0x60;
+    }
+    return true;
+}
+
+#endif
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index eaca2e6..5754b7f 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -32,6 +32,7 @@
 #endif
 
 #include "libmp4.h"
+#include "languages.h"
 #include <math.h>
 
 /* Some assumptions:



More information about the vlc-commits mailing list