home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 September / PC-WELT 9-2001.ISO / software / hw / brennen / flask_src.exe / Input / IFOParser / decode_lang.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-07  |  6.7 KB  |  330 lines

  1.  
  2. /*
  3.  *
  4.  * Copyright (C) 1998,1999  Thomas Mirlacher
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 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 General Public License for more details.
  15.  * 
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  * 
  20.  * The author may be reached as dent@cosy.sbg.ac.at, or
  21.  * Thomas Mirlacher, Jakob-Haringerstr. 2, A-5020 Salzburg,
  22.  * Austria
  23.  *
  24.  *------------------------------------------------------------
  25.  *
  26.  */
  27.  
  28.  
  29. #include <stdio.h>
  30. #include <sys/types.h>
  31. #include "ifo.h"
  32.  
  33. static struct {
  34.         u_short descr : 16;
  35.         char lang_long[20];
  36. } lang_tbl[] = {
  37.  
  38. /* The ISO 639 language codes.
  39.  * Language names with * prefix are not spelled in their own language 
  40.  *
  41.  */
  42.     {0x00, "Not Specified"},
  43.     {'  ', "Not Specified"},
  44.     {'aa', "Afar"},
  45.     {'ab', "Abkhazian"},
  46.     {'af', "Afrikaans"},
  47.     {'am', "Amharic"},
  48.     {'ar', "Arabic"},
  49.     {'as', "Assamese"},
  50.     {'ay', "Aymara"},
  51.     {'az', "Azerbaijani"},
  52.     {'ba', "Bashkir"},
  53.     {'be', "Byelorussian"},
  54.     {'bg', "Bulgarian"},
  55.     {'bh', "Bihari"},
  56.     {'bi', "Bislama"},
  57.     {'bn', "Bengali; Bangla"},
  58.     {'bo', "Tibetan"},
  59.     {'br', "Breton"},
  60.     {'ca', "Catalα"},
  61.     {'co', "Corsican"},
  62.     {'cs', "Czech(Ceske)"},
  63.     {'cy', "Welsh"},
  64.     {'da', "Dansk"},
  65.     {'de', "Deutsch"},
  66.     {'dz', "Bhutani"},
  67.     {'el', "Greek"},
  68.     {'en', "English"},
  69.     {'eo', "Esperanto"},
  70.     {'es', "Espa±ol"},
  71.     {'et', "Estonian"},
  72.     {'eu', "Basque"},
  73.     {'fa', "Persian"},
  74.     {'fi', "Suomi"},
  75.     {'fj', "Fiji"},
  76.     {'fo', "Faroese"},
  77.     {'fr', "Franτais"},
  78.     {'fy', "Frisian"},
  79.     {'ga', "Irish"},
  80.     {'gd', "Scots Gaelic"},
  81.     {'gl', "Galician"},
  82.     {'gn', "Guarani"},
  83.     {'gu', "Gujarati"},
  84.     {'ha', "Hausa"},
  85.     {'he', "Hebrew"},                // formerly iw
  86.     {'hi', "Hindi"},
  87.     {'hr', "Hrvatski"},                // Croatian
  88.     {'hu', "Magyar"},
  89.     {'hy', "Armenian"},
  90.     {'ia', "Interlingua"},
  91.     {'id', "Indonesian"},                // formerly in
  92.     {'ie', "Interlingue"},
  93.     {'ik', "Inupiak"},
  94.     {'in', "Indonesian"},                // replaced by id
  95.     {'is', "Islenska"},
  96.     {'it', "Italiano"},
  97.     {'iu', "Inuktitut"},
  98.     {'iw', "Hebrew"},                // replaced by he
  99.     {'ja', "Japanese"},
  100.     {'ji', "Yiddish"},                // replaced by yi
  101.     {'jw', "Javanese"},
  102.     {'ka', "Georgian"},
  103.     {'kk', "Kazakh"},
  104.     {'kl', "Greenlandic"},
  105.     {'km', "Cambodian"},
  106.     {'kn', "Kannada"},
  107.     {'ko', "Korean"},
  108.     {'ks', "Kashmiri"},
  109.     {'ku', "Kurdish"},
  110.     {'ky', "Kirghiz"},
  111.     {'la', "Latin"},
  112.     {'ln', "Lingala"},
  113.     {'lo', "Laothian"},
  114.     {'lt', "Lithuanian"},
  115.     {'lv', "Latvian, Lettish"},
  116.     {'mg', "Malagasy"},
  117.     {'mi', "Maori"},
  118.     {'mk', "Macedonian"},
  119.     {'ml', "Malayalam"},
  120.     {'mn', "Mongolian"},
  121.     {'mo', "Moldavian"},
  122.     {'mr', "Marathi"},
  123.     {'ms', "Malay"},
  124.     {'mt', "Maltese"},
  125.     {'my', "Burmese"},
  126.     {'na', "Nauru"},
  127.     {'ne', "Nepali"},
  128.     {'nl', "Nederlands"},
  129.     {'no', "Norsk"},
  130.     {'oc', "Occitan"},
  131.     {'om', "(Afan) Oromo"},
  132.     {'or', "Oriya"},
  133.     {'pa', "Punjabi"},
  134.     {'pl', "Polish"},
  135.     {'ps', "Pashto, Pushto"},
  136.     {'pt', "Portugues"},
  137.     {'qu', "Quechua"},
  138.     {'rm', "Rhaeto-Romance"},
  139.     {'rn', "Kirundi"},
  140.     {'ro', "Romanian"},
  141.     {'ru', "Russian"},
  142.     {'rw', "Kinyarwanda"},
  143.     {'sa', "Sanskrit"},
  144.     {'sd', "Sindhi"},
  145.     {'sg', "Sangho"},
  146.     {'sh', "Serbo-Croatian"},
  147.     {'si', "Sinhalese"},
  148.     {'sk', "Slovak"},
  149.     {'sl', "Slovenian"},
  150.     {'sm', "Samoan"},
  151.     {'sn', "Shona"},
  152.     {'so', "Somali"},
  153.     {'sq', "Albanian"},
  154.     {'sr', "Serbian"},
  155.     {'ss', "Siswati"},
  156.     {'st', "Sesotho"},
  157.     {'su', "Sundanese"},
  158.     {'sv', "Svenska"},
  159.     {'sw', "Swahili"},
  160.     {'ta', "Tamil"},
  161.     {'te', "Telugu"},
  162.     {'tg', "Tajik"},
  163.     {'th', "Thai"},
  164.     {'ti', "Tigrinya"},
  165.     {'tk', "Turkmen"},
  166.     {'tl', "Tagalog"},
  167.     {'tn', "Setswana"},
  168.     {'to', "Tonga"},
  169.     {'tr', "Turkish"},
  170.     {'ts', "Tsonga"},
  171.     {'tt', "Tatar"},
  172.     {'tw', "Twi"},
  173.     {'ug', "Uighur"},
  174.     {'uk', "Ukrainian"},
  175.     {'ur', "Urdu"},
  176.     {'uz', "Uzbek"},
  177.     {'vi', "Vietnamese"},
  178.     {'vo', "Volapuk"},
  179.     {'wo', "Wolof"},
  180.     {'xh', "Xhosa"},
  181.     {'yi', "Yiddish"},                // formerly ji
  182.     {'yo', "Yoruba"},
  183.     {'za', "Zhuang"},
  184.     {'zh', "Chinese"},
  185.     {'zu', "Zulu"},
  186.     {0, ""}
  187. };
  188.  
  189.  
  190. /**
  191.  *
  192.  */
  193.  
  194. char *ifoDecodeLang (u_short descr)
  195. {
  196.         int i;
  197.  
  198. // swap bytes (for i386 at least)
  199.         descr = ((descr>>8)&0xff) | ((descr&0xff)<<8);
  200.  
  201.         for (i=0; lang_tbl[i].lang_long[0]; i++) {
  202.                 if (descr == lang_tbl[i].descr) {
  203.                         return (char *) lang_tbl[i].lang_long;
  204.                 }
  205.         }
  206.  
  207.         printf ("descr: %x%x\n", (descr>>8)&0xff, descr&0xff);
  208.         return lang_tbl[i].lang_long;
  209. }
  210.  
  211.  
  212. static struct {
  213.         u_short descr;
  214.         char descr_long[50];
  215. } videomode_tbl[] = {
  216.     {0x01, "Never The Same Color 29.97fps"},
  217.     {0x02, "Never The Same Color 30fps"},
  218.     {0x03, "PAL-B, D, G, H, I, 25 fps"},
  219.     {0x04, "PAL-M 29.97 fps"},
  220.     {0x05, "PAL-M 30 fps"},
  221.     {0x06, "PAL-N 25 fps"},
  222.     {0x07, "PAL-Nc 25 fps"},
  223.     {0x08, "PAL 30 fps"},
  224.     {0, ""}
  225. };
  226.  
  227.  
  228. /**
  229.  *
  230.  */
  231.  
  232. char *decode_videomode (u_short descr)
  233. {
  234.         int i;
  235.  
  236.         for (i=0; videomode_tbl[i].descr; i++) {
  237.                 if (descr == videomode_tbl[i].descr) {
  238.                         return (char *) videomode_tbl[i].descr_long;
  239.                 }
  240.         }
  241.  
  242.         fprintf (stderr, "VIDEO 0x%0X", descr);
  243.         return NULL;
  244. }
  245.  
  246.  
  247. /**
  248.  *
  249.  */
  250.  
  251. char *decode_audiomode (u_short descr)
  252. {
  253.     static char audio_coding_mode[][9] = {
  254.         "AC3",
  255.         "MPEG1",
  256.         "MPEG2ext",
  257.         "LPCM",
  258.         "DTS",
  259.         "SDDS"
  260.     };
  261.  
  262.     return audio_coding_mode[descr&0x07];
  263. }
  264.  
  265.  
  266. /**
  267.  *
  268.  */
  269.  
  270. char *decode_audiomodeappl (u_char descr)
  271. {
  272.     static char audio_appl_mode[][15] = {
  273.         "Not Specified",
  274.         "Karaoke",
  275.         "Surround Sound"
  276.     };
  277.  
  278.     return audio_appl_mode[descr&0x02];
  279. }
  280.  
  281.  
  282. static struct {
  283.     u_char descr;
  284.     char descr_long[25];
  285. } audiocaption_tbl[] = {
  286.     {0x01, "Normal Caption"},
  287.     {0x03, "Directors Comments"},
  288.     {0, ""}
  289. };
  290.  
  291.  
  292. /**
  293.  *
  294.  */
  295.  
  296. char *decode_caption (u_char descr)
  297. {
  298.     int i;
  299.  
  300.     for (i=0; audiocaption_tbl[i].descr; i++) {
  301.         if (descr == audiocaption_tbl[i].descr) {
  302.             return (char *) audiocaption_tbl[i].descr_long;
  303.         }
  304.     }
  305.  
  306.     return NULL;
  307. }
  308.  
  309.  
  310. static char menu_id[][14] = {
  311.         "-0-",
  312.         "-1-",
  313.         "Title",
  314.         "Root",
  315.         "Sub-Picture",
  316.         "Audio",
  317.         "Angle",
  318.         "Part of Title",
  319. };
  320.  
  321.  
  322. /**
  323.  *
  324.  */
  325.  
  326. char *decode_menuname (u_char index)
  327. {
  328.     return menu_id[index&0x07];
  329. }
  330.