| 1 | /** |
|---|
| 2 | @file |
|---|
| 3 | DLIB_PSI_Utils.c |
|---|
| 4 | |
|---|
| 5 | @brief |
|---|
| 6 | PHOENIX HAL library |
|---|
| 7 | |
|---|
| 8 | ÀÌ ¸ðµâ¿¡ ´ëÇÑ °£´ÜÇÑ ¼³¸í.. |
|---|
| 9 | ex: AudioVideo decoding/capture/output implementation |
|---|
| 10 | |
|---|
| 11 | Copyright 2006~2010 Digital STREAM Technology, Inc. |
|---|
| 12 | All Rights Reserved |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | #include "DHL_Types.h" |
|---|
| 17 | #include "DHL_DBG.h" |
|---|
| 18 | |
|---|
| 19 | #include "DLIB_PSIP.h" |
|---|
| 20 | #include "DLIB_PSI_Utils.h" |
|---|
| 21 | #include "DLIB_PSI_Parser.h" |
|---|
| 22 | #include "DLIB_PSIP_Parser.h" |
|---|
| 23 | |
|---|
| 24 | //#include <ctype.h> |
|---|
| 25 | ////#include <string.h> |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | #ifndef min |
|---|
| 29 | #define min(a,b) ((a)<(b)?(a):(b)) |
|---|
| 30 | #endif |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | /* |
|---|
| 34 | ¸ðµç Çì´õ ÆÄÀÏÀ» Æ÷ÇÔÇÏÁö´Â ¾ÊÀ¸¸ç, compile timeÀ» ÁÙÀ̱â À§ÇØ |
|---|
| 35 | °¢ ¸ðµâÀº ÇÊ¿äÇÑ ¸¸ÅÀÇ Çì´õ¸¦ ¼±¾ðÇϵµ·Ï ÇÔ. |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | /* |
|---|
| 41 | DHL µð¹ö±× ¸ðµâ À̸§ Á¤ÀÇ ·ê Âü°í: |
|---|
| 42 | |
|---|
| 43 | DHL ¸ðµâµéÀº ¸ðµÎ * ·Î ½ÃÀÛ. |
|---|
| 44 | API´Â ´ë¹®ÀÚ, Platform ¹× ±âŸ´Â ¼Ò¹®ÀÚ »ç¿ë. |
|---|
| 45 | |
|---|
| 46 | µðÆúÆ® ·¹º§Àº 0À¸·Î ¼³Á¤ÇÑ´Ù. (0: ¿¡·¯ ¸Þ½ÃÁö¸¸ Ãâ·Â) |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | */ |
|---|
| 50 | |
|---|
| 51 | DHL_MODULE("*MMM", 0); |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | #if COMMENT |
|---|
| 56 | ____Config____(){} |
|---|
| 57 | #endif |
|---|
| 58 | |
|---|
| 59 | /* |
|---|
| 60 | ÀÌ ¸ðµâ ³»ºÎ¿¡¼ »ç¿ëµÇ´Â °¢Á¾ configuration Á¤ÀÇ. |
|---|
| 61 | */ |
|---|
| 62 | |
|---|
| 63 | #define _U 0x01 /* upper */ |
|---|
| 64 | #define _L 0x02 /* lower */ |
|---|
| 65 | #define _D 0x04 /* digit */ |
|---|
| 66 | #define _C 0x08 /* cntrl */ |
|---|
| 67 | #define _P 0x10 /* punct */ |
|---|
| 68 | #define _S 0x20 /* white space (space/lf/tab) */ |
|---|
| 69 | #define _X 0x40 /* hex digit */ |
|---|
| 70 | #define _SP 0x80 /* hard space (0x20) */ |
|---|
| 71 | |
|---|
| 72 | extern unsigned char _ctype[]; |
|---|
| 73 | |
|---|
| 74 | #define __ismask(x) (_ctype[(int)(unsigned char)(x)]) |
|---|
| 75 | |
|---|
| 76 | #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0) |
|---|
| 77 | #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0) |
|---|
| 78 | #define iscntrl(c) ((__ismask(c)&(_C)) != 0) |
|---|
| 79 | #define isdigit(c) ((__ismask(c)&(_D)) != 0) |
|---|
| 80 | #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0) |
|---|
| 81 | #define islower(c) ((__ismask(c)&(_L)) != 0) |
|---|
| 82 | #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) |
|---|
| 83 | #define ispunct(c) ((__ismask(c)&(_P)) != 0) |
|---|
| 84 | #define isspace(c) ((__ismask(c)&(_S)) != 0) |
|---|
| 85 | #define isupper(c) ((__ismask(c)&(_U)) != 0) |
|---|
| 86 | #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) |
|---|
| 87 | |
|---|
| 88 | #define isascii(c) (((unsigned char)(c))<=0x7f) |
|---|
| 89 | #define toascii(c) (((unsigned char)(c))&0x7f) |
|---|
| 90 | |
|---|
| 91 | static inline unsigned char __tolower(unsigned char c) |
|---|
| 92 | { |
|---|
| 93 | if (isupper(c)) |
|---|
| 94 | c -= 'A'-'a'; |
|---|
| 95 | return c; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | static inline unsigned char __toupper(unsigned char c) |
|---|
| 99 | { |
|---|
| 100 | if (islower(c)) |
|---|
| 101 | c -= 'a'-'A'; |
|---|
| 102 | return c; |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | #define tolower(c) __tolower(c) |
|---|
| 106 | #ifdef toupper |
|---|
| 107 | #undef toupper |
|---|
| 108 | #endif |
|---|
| 109 | #define toupper(c) __toupper(c) |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | /* #define SUPPORT_FAST_SWITCHING_OPTIMIZATION 1 */ |
|---|
| 114 | /* #define FUNC_MONITOR_TIMER_ID TIMER_ID_FUNC_MONITOR */ |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | /* |
|---|
| 118 | DLIB Àº DMW Äڵ带 ÂüÁ¶ÇÏ¸é ¾ÈµÇ´Âµ¥, ¾ÆÁ÷ Æ÷ÆÃÀÌ ¿ÏÀüÇÏÁö ¾ÊÀº »óŶó¼ |
|---|
| 119 | ÀϺΠÇÔ¼ö¸¦ Âü°íÇϰí ÀÖÀ½. |
|---|
| 120 | |
|---|
| 121 | todo: CodeConv ÀÚüµµ DLIB À¸·Î ¿Å±â´Â °ÍÀÌ ¹Ù¶÷Á÷ÇØ º¸ÀÓ. |
|---|
| 122 | */ |
|---|
| 123 | extern UINT16 *DMW_GetKs2UcTable(void); |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | #if COMMENT |
|---|
| 128 | ____Types____(){} |
|---|
| 129 | #endif |
|---|
| 130 | |
|---|
| 131 | /* |
|---|
| 132 | ÀÌ ¸ðµâ ³»ºÎ¿¡¼ »ç¿ëµÇ´Â structure ¹× enumerations. |
|---|
| 133 | */ |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | #if COMMENT |
|---|
| 138 | ____Variables____(){} |
|---|
| 139 | #endif |
|---|
| 140 | |
|---|
| 141 | /* |
|---|
| 142 | global·Î Àû¿ëµÇ´Â variable Á¤ÀÇ. |
|---|
| 143 | °¢ function º°·Î Ư¼öÇÑ ¿ëµµÀÇ variableÀº °¢ functionX block ¿¡¼ Á¤ÀÇ °¡´É. |
|---|
| 144 | */ |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | #if COMMENT |
|---|
| 150 | ____Group1____(){} |
|---|
| 151 | #endif |
|---|
| 152 | |
|---|
| 153 | /* |
|---|
| 154 | // 000 - 000, alb, bre, cat, scr, |
|---|
| 155 | // 005 - cym, ces, dan, deu, eng, |
|---|
| 156 | // 010 - esl, epo, est, baq, fao, |
|---|
| 157 | // 015 - fra, fry, gai, gae, 001, |
|---|
| 158 | // 020 - ice, ita, 002, lat, lav, |
|---|
| 159 | // 025 - 003, lit, hun, mlt, dut, |
|---|
| 160 | // 030 - nor, 004, pol, por, ron, |
|---|
| 161 | // 035 - 005, 006, slk, 007, fin, |
|---|
| 162 | // 040 - sve, tur, 008, 009, und, |
|---|
| 163 | // 045 - mis, mul, ina, xxx, xxx, |
|---|
| 164 | // 050 - xxx, xxx, xxx, xxx, xxx, |
|---|
| 165 | // 055 - xxx, xxx, xxx, xxx, xxx, |
|---|
| 166 | // 060 - xxx, xxx, xxx, xxx, xxx, |
|---|
| 167 | // 065 - int, art, fre, zho, zul, |
|---|
| 168 | // 070 - vie, uzb, urd, ukr, tha, |
|---|
| 169 | // 075 - tel, tat, tam, xxx, swa, |
|---|
| 170 | // 080 - xxx, som, xxx, sna, scr, |
|---|
| 171 | // 085 - xxx, rus, que, pus, pan, |
|---|
| 172 | // 090 - fas, xxx, ori, nep, nde, |
|---|
| 173 | // 095 - mar, mol, xxx, mlg, mac, |
|---|
| 174 | // 100 - xxx, kor, khm, kaz, kan, |
|---|
| 175 | // 105 - jpn, ind, hin, heb, hau, |
|---|
| 176 | // 110 - grn, guj, ell, geo, xxx, |
|---|
| 177 | // 115 - xxx, xxx, chi, bur, bul, |
|---|
| 178 | // 120 - ben, xxx, bam, aze, asm, |
|---|
| 179 | // 125 - arm, ara, amh, <-- up to here, within spec. |
|---|
| 180 | // spa, nno, <-- from here, this is out of spec. |
|---|
| 181 | // 130 - nla, ger, gre, iri, isl, |
|---|
| 182 | // 135 - wel, haw, inc, peo, ota, |
|---|
| 183 | // 140 - swe, per, rum, sqi, abk, |
|---|
| 184 | // 145 - ace, ach, ada, aar, afh, |
|---|
| 185 | // 150 - afr, afa, aka, akk, ale, |
|---|
| 186 | // 155 - alg, tut, apa, arc, arp, |
|---|
| 187 | // 160 - arn, arw, hye, ath, map, |
|---|
| 188 | // 165 - ava, ave, awa, aym, nah, |
|---|
| 189 | // 170 - ban, bat, bal, bai, bad, |
|---|
| 190 | // 175 - bnt, bas, bak, eus, bej, |
|---|
| 191 | // 180 - bem, ber, bho, bih, bik, |
|---|
| 192 | // 185 - bin, bis, bra, bug, bua, |
|---|
| 193 | // 190 - mya, bel, cad, car, cau, |
|---|
| 194 | // 195 - ceb, cel, cai, chg, cha, |
|---|
| 195 | // 200 - che, chr, chy, cnb, chn, |
|---|
| 196 | // 205 - cho, chu, chv, cop, cor, |
|---|
| 197 | // 210 - cos, cre, mus, crp, cpe, |
|---|
| 198 | // 215 - cpf, cpp, cus, cze, dak, |
|---|
| 199 | // 220 - del, din, div, doi, dra, |
|---|
| 200 | // 225 - dua, dum, dyu, dzo, efi, |
|---|
| 201 | // 230 - egy, eka, elx, enm, ang, |
|---|
| 202 | // 235 - esk, ewe, ewo, fan, fat, |
|---|
| 203 | // 240 - fij, fiu, fon, frm, fro, |
|---|
| 204 | // 245 - ful, gaa, gdh, glg, lug, |
|---|
| 205 | // 250 - gay, gez, kat, gmh, goh, |
|---|
| 206 | // 255 - gem, gil, gon, got, grc, |
|---|
| 207 | // 260 - grb, kal, hai, her, hil, |
|---|
| 208 | // 265 - him, hmo, hup, iba, ibo, |
|---|
| 209 | // 270 - ijo, ilo, ine, iku, ipk, |
|---|
| 210 | // 275 - ira, sga, mga, iro, jav, |
|---|
| 211 | // 280 - jaw, jrb, jpr, kab, kac, |
|---|
| 212 | // 285 - kam, kau, kaa, kar, kas, |
|---|
| 213 | // 290 - kaw, kha, khi, kho, kik, |
|---|
| 214 | // 295 - kin, kir, kom, kon, kok, |
|---|
| 215 | // 300 - kpe, kro, kua, kum, kur, |
|---|
| 216 | // 305 - kru, kus, kut, lad, lah, |
|---|
| 217 | // 310 - lam, oci, lao, ltz, lez, |
|---|
| 218 | // 315 - lin, loz, lub, lui, lun, |
|---|
| 219 | // 320 - luo, mak, mad, mag, mai, |
|---|
| 220 | // 325 - mak, may, msa, mal, man, |
|---|
| 221 | // 330 - mni, mno, max, mao, mri, |
|---|
| 222 | // 335 - chm, mah, mwr, mas, myn, |
|---|
| 223 | // 340 - men, mic, min, moh, mkh, |
|---|
| 224 | // 345 - lol, mon, mos, mun, nau, |
|---|
| 225 | // 350 - nav, nbl, ndo, new, nic, |
|---|
| 226 | // 355 - ssa, niu, non, nai, nub, |
|---|
| 227 | // 360 - nym, nya, nyn, nyo, nzi, |
|---|
| 228 | // 365 - oji, orm, osa, oss, oto, |
|---|
| 229 | // 370 - pal, pau, pli, pam, pag, |
|---|
| 230 | // 375 - pap, paa, phn, pon, pra, |
|---|
| 231 | // 380 - pro, roh, raj, rar, roa, |
|---|
| 232 | // 385 - rom, run, sal, sam, smi, |
|---|
| 233 | // 390 - smo, sad, sag, san, srd, |
|---|
| 234 | // 395 - sco, sel, sem, srr, shn, |
|---|
| 235 | // 400 - sid, bla, snd, sin, sit, |
|---|
| 236 | // 405 - sio, sla, ssw, slo, slv, |
|---|
| 237 | // 410 - sog, son, wen, nso, sot, |
|---|
| 238 | // 415 - sai, suk, sux, sun, sus, |
|---|
| 239 | // 420 - ssw, syr, tgl, tah, tgk, |
|---|
| 240 | // 425 - tmh, ter, bod, tib, tig, |
|---|
| 241 | // 430 - tir, tem, tiv, tli, tog, |
|---|
| 242 | // 435 - ton, tru, tsi, tso, tsn, |
|---|
| 243 | // 440 - tum, tuk, tyv, twi, uga, |
|---|
| 244 | // 445 - uig, umb, vai, ven, vol, |
|---|
| 245 | // 450 - vot, wak, wal, war, was, |
|---|
| 246 | // 455 - wol, xho, sah, yao, yap, |
|---|
| 247 | // 460 - yid, yor, zap, zen, zha, |
|---|
| 248 | // 465 - zun, SPA |
|---|
| 249 | */ |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | |
|---|
| 253 | static UINT32 ac3lang_to_iso639[] = { |
|---|
| 254 | |
|---|
| 255 | /* 000 */ |
|---|
| 256 | 0x000000, 0x616c62, 0x627265, 0x636174, 0x736372, |
|---|
| 257 | /* 005 */ |
|---|
| 258 | 0x63796d, 0x636573, 0x64616e, 0x646575, 0x656e67, |
|---|
| 259 | /* 010 */ |
|---|
| 260 | 0x65736c, 0x65706f, 0x657374, 0x626171, 0x66616f, |
|---|
| 261 | /* 015 */ |
|---|
| 262 | 0x667261, 0x667279, 0x676169, 0x676165, 0x000001, |
|---|
| 263 | /* 020 */ |
|---|
| 264 | 0x696365, 0x697461, 0x000002, 0x6c6174, 0x6c6176, |
|---|
| 265 | /* 025 */ |
|---|
| 266 | 0x000003, 0x6c6974, 0x68756e, 0x6d6c74, 0x647574, |
|---|
| 267 | /* 030 */ |
|---|
| 268 | 0x6e6f72, 0x000004, 0x706f6c, 0x706f72, 0x726f6e, |
|---|
| 269 | /* 035 */ |
|---|
| 270 | 0x000005, 0x000006, 0x736c6b, 0x000007, 0x66696e, |
|---|
| 271 | /* 040 */ |
|---|
| 272 | 0x737665, 0x747572, 0x000008, 0x000009, 0x756e64, |
|---|
| 273 | /* 045 */ |
|---|
| 274 | 0x6d6973, 0x6d756c, 0x696e61, 0x787878, 0x787878, |
|---|
| 275 | /* 050 */ |
|---|
| 276 | 0x787878, 0x787878, 0x787878, 0x787878, 0x787878, |
|---|
| 277 | /* 055 */ |
|---|
| 278 | 0x787878, 0x787878, 0x787878, 0x787878, 0x787878, |
|---|
| 279 | /* 060 */ |
|---|
| 280 | 0x787878, 0x787878, 0x787878, 0x787878, 0x787878, |
|---|
| 281 | /* 065 */ |
|---|
| 282 | 0x696e74, 0x617274, 0x667265, 0x7a686f, 0x7a756c, |
|---|
| 283 | /* 070 */ |
|---|
| 284 | 0x766965, 0x757a62, 0x757264, 0x756b72, 0x746861, |
|---|
| 285 | /* 075 */ |
|---|
| 286 | 0x74656c, 0x746174, 0x74616d, 0x787878, 0x737761, |
|---|
| 287 | /* 080 */ |
|---|
| 288 | 0x787878, 0x736f6d, 0x787878, 0x736e61, 0x736372, |
|---|
| 289 | /* 085 */ |
|---|
| 290 | 0x787878, 0x727573, 0x717565, 0x707573, 0x70616e, |
|---|
| 291 | /* 090 */ |
|---|
| 292 | 0x666173, 0x787878, 0x6f7269, 0x6e6570, 0x6e6465, |
|---|
| 293 | /* 095 */ |
|---|
| 294 | 0x6d6172, 0x6d6f6c, 0x787878, 0x6d6c67, 0x6d6163, |
|---|
| 295 | /* 100 */ |
|---|
| 296 | 0x787878, 0x6b6f72, 0x6b686d, 0x6b617a, 0x6b616e, |
|---|
| 297 | /* 105 */ |
|---|
| 298 | 0x6a706e, 0x696e64, 0x68696e, 0x686562, 0x686175, |
|---|
| 299 | /* 110 */ |
|---|
| 300 | 0x67726e, 0x67756a, 0x656c6c, 0x67656f, 0x787878, |
|---|
| 301 | /* 115 */ |
|---|
| 302 | 0x787878, 0x787878, 0x636869, 0x627572, 0x62756c, |
|---|
| 303 | /* 120 */ |
|---|
| 304 | 0x62656e, 0x787878, 0x62616d, 0x617a65, 0x61736d, |
|---|
| 305 | /* 125 */ |
|---|
| 306 | 0x61726d, 0x617261, 0x616d68, 0x737061, 0x6e6e6f, |
|---|
| 307 | /* 130 */ |
|---|
| 308 | 0x6e6c61, 0x676572, 0x677265, 0x697269, 0x69736c, |
|---|
| 309 | /* 135 */ |
|---|
| 310 | 0x77656c, 0x686177, 0x696e63, 0x70656f, 0x6f7461, |
|---|
| 311 | /* 140 */ |
|---|
| 312 | 0x737765, 0x706572, 0x72756d, 0x737169, 0x61626b, |
|---|
| 313 | /* 145 */ |
|---|
| 314 | 0x616365, 0x616368, 0x616461, 0x616172, 0x616668, |
|---|
| 315 | /* 150 */ |
|---|
| 316 | 0x616672, 0x616661, 0x616b61, 0x616b6b, 0x616c65, |
|---|
| 317 | /* 155 */ |
|---|
| 318 | 0x616c67, 0x747574, 0x617061, 0x617263, 0x617270, |
|---|
| 319 | /* 160 */ |
|---|
| 320 | 0x61726e, 0x617277, 0x687965, 0x617468, 0x6d6170, |
|---|
| 321 | /* 165 */ |
|---|
| 322 | 0x617661, 0x617665, 0x617761, 0x61796d, 0x6e6168, |
|---|
| 323 | /* 170 */ |
|---|
| 324 | 0x62616e, 0x626174, 0x62616c, 0x626169, 0x626164, |
|---|
| 325 | /* 175 */ |
|---|
| 326 | 0x626e74, 0x626173, 0x62616b, 0x657573, 0x62656a, |
|---|
| 327 | /* 180 */ |
|---|
| 328 | 0x62656d, 0x626572, 0x62686f, 0x626968, 0x62696b, |
|---|
| 329 | /* 185 */ |
|---|
| 330 | 0x62696e, 0x626973, 0x627261, 0x627567, 0x627561, |
|---|
| 331 | /* 190 */ |
|---|
| 332 | 0x6d7961, 0x62656c, 0x636164, 0x636172, 0x636175, |
|---|
| 333 | /* 195 */ |
|---|
| 334 | 0x636562, 0x63656c, 0x636169, 0x636867, 0x636861, |
|---|
| 335 | /* 200 */ |
|---|
| 336 | 0x636865, 0x636872, 0x636879, 0x636e62, 0x63686e, |
|---|
| 337 | /* 205 */ |
|---|
| 338 | 0x63686f, 0x636875, 0x636876, 0x636f70, 0x636f72, |
|---|
| 339 | /* 210 */ |
|---|
| 340 | 0x636f73, 0x637265, 0x6d7573, 0x637270, 0x637065, |
|---|
| 341 | /* 215 */ |
|---|
| 342 | 0x637066, 0x637070, 0x637573, 0x637a65, 0x64616b, |
|---|
| 343 | /* 220 */ |
|---|
| 344 | 0x64656c, 0x64696e, 0x646976, 0x646f69, 0x647261, |
|---|
| 345 | /* 225 */ |
|---|
| 346 | 0x647561, 0x64756d, 0x647975, 0x647a6f, 0x656669, |
|---|
| 347 | /* 230 */ |
|---|
| 348 | 0x656779, 0x656b61, 0x656c78, 0x656e6d, 0x616e67, |
|---|
| 349 | /* 235 */ |
|---|
| 350 | 0x65736b, 0x657765, 0x65776f, 0x66616e, 0x666174, |
|---|
| 351 | /* 240 */ |
|---|
| 352 | 0x66696a, 0x666975, 0x666f6e, 0x66726d, 0x66726f, |
|---|
| 353 | /* 245 */ |
|---|
| 354 | 0x66756c, 0x676161, 0x676468, 0x676c67, 0x6c7567, |
|---|
| 355 | /* 250 */ |
|---|
| 356 | 0x676179, 0x67657a, 0x6b6174, 0x676d68, 0x676f68, |
|---|
| 357 | /* 255 */ |
|---|
| 358 | 0x67656d, 0x67696c, 0x676f6e, 0x676f74, 0x677263, |
|---|
| 359 | /* 260 */ |
|---|
| 360 | 0x677262, 0x6b616c, 0x686169, 0x686572, 0x68696c, |
|---|
| 361 | /* 265 */ |
|---|
| 362 | 0x68696d, 0x686d6f, 0x687570, 0x696261, 0x69626f, |
|---|
| 363 | /* 270 */ |
|---|
| 364 | 0x696a6f, 0x696c6f, 0x696e65, 0x696b75, 0x69706b, |
|---|
| 365 | /* 275 */ |
|---|
| 366 | 0x697261, 0x736761, 0x6d6761, 0x69726f, 0x6a6176, |
|---|
| 367 | /* 280 */ |
|---|
| 368 | 0x6a6177, 0x6a7262, 0x6a7072, 0x6b6162, 0x6b6163, |
|---|
| 369 | /* 285 */ |
|---|
| 370 | 0x6b616d, 0x6b6175, 0x6b6161, 0x6b6172, 0x6b6173, |
|---|
| 371 | /* 290 */ |
|---|
| 372 | 0x6b6177, 0x6b6861, 0x6b6869, 0x6b686f, 0x6b696b, |
|---|
| 373 | /* 295 */ |
|---|
| 374 | 0x6b696e, 0x6b6972, 0x6b6f6d, 0x6b6f6e, 0x6b6f6b, |
|---|
| 375 | /* 300 */ |
|---|
| 376 | 0x6b7065, 0x6b726f, 0x6b7561, 0x6b756d, 0x6b7572, |
|---|
| 377 | /* 305 */ |
|---|
| 378 | 0x6b7275, 0x6b7573, 0x6b7574, 0x6c6164, 0x6c6168, |
|---|
| 379 | /* 310 */ |
|---|
| 380 | 0x6c616d, 0x6f6369, 0x6c616f, 0x6c747a, 0x6c657a, |
|---|
| 381 | /* 315 */ |
|---|
| 382 | 0x6c696e, 0x6c6f7a, 0x6c7562, 0x6c7569, 0x6c756e, |
|---|
| 383 | /* 320 */ |
|---|
| 384 | 0x6c756f, 0x6d616b, 0x6d6164, 0x6d6167, 0x6d6169, |
|---|
| 385 | /* 325 */ |
|---|
| 386 | 0x6d616b, 0x6d6179, 0x6d7361, 0x6d616c, 0x6d616e, |
|---|
| 387 | /* 330 */ |
|---|
| 388 | 0x6d6e69, 0x6d6e6f, 0x6d6178, 0x6d616f, 0x6d7269, |
|---|
| 389 | /* 335 */ |
|---|
| 390 | 0x63686d, 0x6d6168, 0x6d7772, 0x6d6173, 0x6d796e, |
|---|
| 391 | /* 340 */ |
|---|
| 392 | 0x6d656e, 0x6d6963, 0x6d696e, 0x6d6f68, 0x6d6b68, |
|---|
| 393 | /* 345 */ |
|---|
| 394 | 0x6c6f6c, 0x6d6f6e, 0x6d6f73, 0x6d756e, 0x6e6175, |
|---|
| 395 | /* 350 */ |
|---|
| 396 | 0x6e6176, 0x6e626c, 0x6e646f, 0x6e6577, 0x6e6963, |
|---|
| 397 | /* 355 */ |
|---|
| 398 | 0x737361, 0x6e6975, 0x6e6f6e, 0x6e6169, 0x6e7562, |
|---|
| 399 | /* 360 */ |
|---|
| 400 | 0x6e796d, 0x6e7961, 0x6e796e, 0x6e796f, 0x6e7a69, |
|---|
| 401 | /* 365 */ |
|---|
| 402 | 0x6f6a69, 0x6f726d, 0x6f7361, 0x6f7373, 0x6f746f, |
|---|
| 403 | /* 370 */ |
|---|
| 404 | 0x70616c, 0x706175, 0x706c69, 0x70616d, 0x706167, |
|---|
| 405 | /* 375 */ |
|---|
| 406 | 0x706170, 0x706161, 0x70686e, 0x706f6e, 0x707261, |
|---|
| 407 | /* 380 */ |
|---|
| 408 | 0x70726f, 0x726f68, 0x72616a, 0x726172, 0x726f61, |
|---|
| 409 | /* 385 */ |
|---|
| 410 | 0x726f6d, 0x72756e, 0x73616c, 0x73616d, 0x736d69, |
|---|
| 411 | /* 390 */ |
|---|
| 412 | 0x736d6f, 0x736164, 0x736167, 0x73616e, 0x737264, |
|---|
| 413 | /* 395 */ |
|---|
| 414 | 0x73636f, 0x73656c, 0x73656d, 0x737272, 0x73686e, |
|---|
| 415 | /* 400 */ |
|---|
| 416 | 0x736964, 0x626c61, 0x736e64, 0x73696e, 0x736974, |
|---|
| 417 | /* 405 */ |
|---|
| 418 | 0x73696f, 0x736c61, 0x737377, 0x736c6f, 0x736c76, |
|---|
| 419 | /* 410 */ |
|---|
| 420 | 0x736f67, 0x736f6e, 0x77656e, 0x6e736f, 0x736f74, |
|---|
| 421 | /* 415 */ |
|---|
| 422 | 0x736169, 0x73756b, 0x737578, 0x73756e, 0x737573, |
|---|
| 423 | /* 420 */ |
|---|
| 424 | 0x737377, 0x737972, 0x74676c, 0x746168, 0x74676b, |
|---|
| 425 | /* 425 */ |
|---|
| 426 | 0x746d68, 0x746572, 0x626f64, 0x746962, 0x746967, |
|---|
| 427 | /* 430 */ |
|---|
| 428 | 0x746972, 0x74656d, 0x746976, 0x746c69, 0x746f67, |
|---|
| 429 | /* 435 */ |
|---|
| 430 | 0x746f6e, 0x747275, 0x747369, 0x74736f, 0x74736e, |
|---|
| 431 | /* 440 */ |
|---|
| 432 | 0x74756d, 0x74756b, 0x747976, 0x747769, 0x756761, |
|---|
| 433 | /* 445 */ |
|---|
| 434 | 0x756967, 0x756d62, 0x766169, 0x76656e, 0x766f6c, |
|---|
| 435 | /* 450 */ |
|---|
| 436 | 0x766f74, 0x77616b, 0x77616c, 0x776172, 0x776173, |
|---|
| 437 | /* 455 */ |
|---|
| 438 | 0x776f6c, 0x78686f, 0x736168, 0x79616f, 0x796170, |
|---|
| 439 | /* 460 */ |
|---|
| 440 | 0x796964, 0x796f72, 0x7a6170, 0x7a656e, 0x7a6861, |
|---|
| 441 | /* 465 */ |
|---|
| 442 | 0x7a756e |
|---|
| 443 | |
|---|
| 444 | }; |
|---|
| 445 | |
|---|
| 446 | |
|---|
| 447 | |
|---|
| 448 | #if COMMENT |
|---|
| 449 | ____Group1____(){} |
|---|
| 450 | #endif |
|---|
| 451 | |
|---|
| 452 | |
|---|
| 453 | #define StreamTypeToAudioType(t) ( \ |
|---|
| 454 | (t) == StreamType_AC3Audio ? eDHL_AUDIO_TYPE_AC3: \ |
|---|
| 455 | (t) == StreamType_MPEG2Audio ? eDHL_AUDIO_TYPE_MPEG_2 : eDHL_AUDIO_TYPE_UNKNOWN ) |
|---|
| 456 | |
|---|
| 457 | |
|---|
| 458 | /* cafrii 050816 add |
|---|
| 459 | cafrii 061214 add comment |
|---|
| 460 | 0x00, 0x2C~0x44 ´Â AC3 spec (A/52, 1995)¿¡¼ reserved Á¤ÀǵǾî ÀÖ°í, |
|---|
| 461 | 0x80~ ÀÌ»óÀÇ °ªÀº »ç¿ëµÇÁö ¾Ê´Â´Ù. |
|---|
| 462 | 0x80~Àº ac3lang_to_iso639 table¿¡´Â Á¤ÀÇÇØ ³õ¾ÒÁö¸¸ ÀÓÀÇ ¹èÄ¡¿¡ Áö³ªÁö ¾ÊÀ½. |
|---|
| 463 | */ |
|---|
| 464 | static BOOL IsValidAc3LangCode(int code) |
|---|
| 465 | { |
|---|
| 466 | if ((code == 0x00) || |
|---|
| 467 | (code >= 0x2c && code <= 0x44) || |
|---|
| 468 | (code >= 0x80)) |
|---|
| 469 | return FALSE; /* invalid.. */ |
|---|
| 470 | |
|---|
| 471 | return TRUE; |
|---|
| 472 | } |
|---|
| 473 | |
|---|
| 474 | |
|---|
| 475 | |
|---|
| 476 | #if COMMENT |
|---|
| 477 | ____API____(){} |
|---|
| 478 | #endif |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | /* |
|---|
| 482 | descriptor list ¿¡¼ language °ü·Ã Á¤º¸¸¦ ÃßÃâÇÏ¿© ¸®ÅÏÇÑ´Ù. |
|---|
| 483 | |
|---|
| 484 | audio play¸¦ ½ÃÀÛÇÒ ¶§ audio language ¼±ÅÃÀ» ÇÒ ¶§ »ç¿ëµÈ´Ù. |
|---|
| 485 | |
|---|
| 486 | Rule |
|---|
| 487 | - µÎ°³ÀÇ descriptor¸¦ ÂüÁ¶ÇÑ´Ù. ISO 639, AC3 Audio |
|---|
| 488 | - µÎ descriptor Áß¿¡ ¿ì¼± ¼øÀ§´Â ¾ø´Ù. ¸ÕÀú ¹ß°ßµÇ´Â °ÍºÎÅÍ instance ¹øÈ£ ÇÒ´ç. |
|---|
| 489 | - 639 language code 0Àº ¾ø´Â °ÍÀ¸·Î °£ÁֵȴÙ. |
|---|
| 490 | - AC3 langcode 0µµ ¾ø´Â °ÍÀ¸·Î °£ÁֵȴÙ. |
|---|
| 491 | */ |
|---|
| 492 | DHL_RESULT DLIB_PSI_GetLanguageCodeFromDescriptors(UINT8 *pDescriptors, int nDescLen, |
|---|
| 493 | int instance, UINT32 *pLangCode, int *pServiceType) |
|---|
| 494 | { |
|---|
| 495 | /* cafrii 061213 add |
|---|
| 496 | |
|---|
| 497 | A/53 ±Ô°ÝÀÌ º¯°æµÇ¾î¼ ÂüÁ¶ÇØ¾ß ÇÏ´Â descriptor¿¡ º¯°æÀÌ ÀÖ´Ù. |
|---|
| 498 | |
|---|
| 499 | ´õÀÌ»ó 'instance'´Â Áö¿øÇÏÁö ¾Ê´Â´Ù. |
|---|
| 500 | ¿ì¼± ¼øÀ§ °³³äÀÌ µé¾î°¡±â ¶§¹®¿¡ ¼ø¼°¡ Àǹ̰¡ ¾ø´Ù. |
|---|
| 501 | */ |
|---|
| 502 | UINT32 lang_code = 0; |
|---|
| 503 | DHL_RESULT err; |
|---|
| 504 | ac3AudioStreamDescriptor_t *ac3_desc = NULL; |
|---|
| 505 | UINT32 iso639_code; |
|---|
| 506 | UINT8 *ptr; |
|---|
| 507 | |
|---|
| 508 | /* find AC3 descriptor */ |
|---|
| 509 | err = GetMpegDescriptor(pDescriptors, nDescLen, |
|---|
| 510 | AC3_audio_stream_tag, 0, &ptr); /* get only first instance */ |
|---|
| 511 | if (err == DHL_OK) { |
|---|
| 512 | err = ParseAc3AudioStreamDescriptor(ptr, &ac3_desc); |
|---|
| 513 | if (err) |
|---|
| 514 | ac3_desc = NULL; |
|---|
| 515 | } |
|---|
| 516 | |
|---|
| 517 | /* find ISO 639 descriptor */ |
|---|
| 518 | err = GetMpegDescriptor(pDescriptors, nDescLen, |
|---|
| 519 | ISO_639_language_tag, 0, &ptr); /* first instance */ |
|---|
| 520 | if (err != DHL_OK || |
|---|
| 521 | ptr[0] != ISO_639_language_tag || |
|---|
| 522 | ptr[1] < 4) /* ISO 639 descriptor length is 4. */ |
|---|
| 523 | iso639_code = 0; |
|---|
| 524 | else { |
|---|
| 525 | /* updated by Chan Hun Jeon 2007.05.29 */ |
|---|
| 526 | /* lang_code ´ë¹®ÀÚ¸¦ ¼Ò¹®ÀڷΠġȯ */ |
|---|
| 527 | iso639_code = tolower(ptr[2])<<16UL | tolower(ptr[3])<<8UL | tolower(ptr[4]); |
|---|
| 528 | } |
|---|
| 529 | |
|---|
| 530 | /* decide langugae code */ |
|---|
| 531 | if (ac3_desc && ac3_desc->langflag && ac3_desc->language) |
|---|
| 532 | { |
|---|
| 533 | /* this is new stream. */ |
|---|
| 534 | lang_code = ac3_desc->language; |
|---|
| 535 | } |
|---|
| 536 | else if (ac3_desc && ac3_desc->langflag_2 && ac3_desc->language2) |
|---|
| 537 | { |
|---|
| 538 | /* this is new stream. */ |
|---|
| 539 | lang_code = ac3_desc->language2; |
|---|
| 540 | } |
|---|
| 541 | else if (iso639_code) |
|---|
| 542 | { |
|---|
| 543 | lang_code = iso639_code; |
|---|
| 544 | } |
|---|
| 545 | else if (ac3_desc) |
|---|
| 546 | { |
|---|
| 547 | if (IsValidAc3LangCode(ac3_desc->langcod)) { |
|---|
| 548 | lang_code = ac3lang_to_iso639[ac3_desc->langcod]; |
|---|
| 549 | } |
|---|
| 550 | else if (IsValidAc3LangCode(ac3_desc->langcod2)) { |
|---|
| 551 | lang_code = ac3lang_to_iso639[ac3_desc->langcod2]; |
|---|
| 552 | } |
|---|
| 553 | } |
|---|
| 554 | |
|---|
| 555 | /* Updated by Chan Hun Jeon 2007.05.29 */ |
|---|
| 556 | /* ´ë¹®ÀÚ´Â ¼Ò¹®ÀڷΠġȯ */ |
|---|
| 557 | lang_code = (tolower( (lang_code>>16UL)&0xff ) << 16UL) | ((tolower( (lang_code>>8UL)&0xff) ) << 8UL) | tolower(lang_code&0xff); |
|---|
| 558 | |
|---|
| 559 | if (ac3_desc) { |
|---|
| 560 | FreeMpegDescriptor(ac3_desc); |
|---|
| 561 | ac3_desc = NULL; |
|---|
| 562 | } |
|---|
| 563 | |
|---|
| 564 | if (pLangCode) *pLangCode = lang_code; |
|---|
| 565 | |
|---|
| 566 | if (lang_code == 0) |
|---|
| 567 | return DHL_FAIL_NOT_FOUND; |
|---|
| 568 | |
|---|
| 569 | return DHL_OK; |
|---|
| 570 | |
|---|
| 571 | } |
|---|
| 572 | |
|---|
| 573 | |
|---|
| 574 | |
|---|
| 575 | #if COMMENT |
|---|
| 576 | ____API2____(){} |
|---|
| 577 | #endif |
|---|
| 578 | |
|---|
| 579 | /* |
|---|
| 580 | ±âÁ¸ ÇÔ¼ö À̸§: DMW_Decode_MultipleStringStructure |
|---|
| 581 | */ |
|---|
| 582 | UINT16 DLIB_PSI_DecodeMultipleStringStructure( |
|---|
| 583 | UINT8 text_length, /* MSSÀÇ ±æÀÌ */ |
|---|
| 584 | UINT8 *text_p, /* MSSÀÇ text pointer */ |
|---|
| 585 | char *lang, /* ISO 639.2B language code (3 bytes) */ |
|---|
| 586 | UINT16 max_dec_length, /* decoding textÀÇ ÃÖ´ë ±æÀÌ */ |
|---|
| 587 | UINT16 *decoded_text) /* decoding °á°ú text (unicode·Î ÀúÀåµÊ) */ |
|---|
| 588 | { |
|---|
| 589 | |
|---|
| 590 | UINT16 *cktouk; /* cafrii 060616, use API instead of direct importing. */ |
|---|
| 591 | UINT8 *text; |
|---|
| 592 | UINT8 number_strings; |
|---|
| 593 | UINT8 number_segments; |
|---|
| 594 | UINT8 compression_type; |
|---|
| 595 | UINT8 mode; |
|---|
| 596 | UINT8 number_bytes, number_chars; |
|---|
| 597 | int found_match_lang; |
|---|
| 598 | char iso_lang_code[3]; |
|---|
| 599 | int i, j, k; |
|---|
| 600 | UINT16 tmp_decoded_length; |
|---|
| 601 | UINT16 *tmp_decoded_text; |
|---|
| 602 | UINT16 ucode; |
|---|
| 603 | int left_text_room; |
|---|
| 604 | UINT16 decoded_length = 0; |
|---|
| 605 | BOOL fStringDecodeDone; |
|---|
| 606 | UINT8 *string = DHL_OS_Malloc( sizeof(UINT8) * 4096 ); |
|---|
| 607 | |
|---|
| 608 | if( string == NULL ) |
|---|
| 609 | return 0; |
|---|
| 610 | memset(string, 0, sizeof(UINT8) * 4096); |
|---|
| 611 | |
|---|
| 612 | if ((cktouk = DMW_GetKs2UcTable()) == NULL) /* cafrii 060616 add */ |
|---|
| 613 | return 0; |
|---|
| 614 | |
|---|
| 615 | text = text_p; /* ¾ÕÀ¸·Î ÀÌ pointer¸¦ »ç¿ëÇÒ °ÍÀÓ. */ |
|---|
| 616 | number_strings = (UINT8)*text++; |
|---|
| 617 | |
|---|
| 618 | for(i=0; i<number_strings; i++) |
|---|
| 619 | { |
|---|
| 620 | tmp_decoded_text = decoded_text; |
|---|
| 621 | iso_lang_code[0] = *text++; |
|---|
| 622 | iso_lang_code[1] = *text++; |
|---|
| 623 | iso_lang_code[2] = *text++; |
|---|
| 624 | |
|---|
| 625 | #ifdef _EPG_DEBUG_ |
|---|
| 626 | epgPrintf("iso_lang_code : %c%c%c\n" , iso_lang_code[0] , iso_lang_code[1] , iso_lang_code[2]); |
|---|
| 627 | #endif |
|---|
| 628 | |
|---|
| 629 | /* ¿øÇÏ´Â languageÀÇ character¸¦ decode. */ |
|---|
| 630 | found_match_lang=strncmp(lang, iso_lang_code, 3); |
|---|
| 631 | |
|---|
| 632 | |
|---|
| 633 | number_segments = *text++; |
|---|
| 634 | tmp_decoded_length = 0; /* °¢ segment¸¶´Ù decoded_length¸¦ ±¸ÇÑ´Ù. */ |
|---|
| 635 | fStringDecodeDone = 0; /* ¾ð¾îº° string decodingÀÌ ¿Ï·áµÇ¾ú´Â Áö °Ë»çÇÏ´Â flag. */ |
|---|
| 636 | |
|---|
| 637 | for(j=0;j<number_segments;j++) |
|---|
| 638 | { |
|---|
| 639 | compression_type = *text++; |
|---|
| 640 | mode = *text++; /* mode<0x3f:8-bit unicode, 0x3f:16-bit unicode */ |
|---|
| 641 | number_bytes = *text++; |
|---|
| 642 | if(fStringDecodeDone==1) /* ¾ð¾îº° string decodingÀÌ ¿Ï·áµÇ¾úÀ½. */ |
|---|
| 643 | { |
|---|
| 644 | text += number_bytes; |
|---|
| 645 | } |
|---|
| 646 | else |
|---|
| 647 | { |
|---|
| 648 | #ifdef _EPG_UPDATE_DEBUG_ |
|---|
| 649 | epgPrintf("compression_type = 0x%x\n" , compression_type); |
|---|
| 650 | #endif |
|---|
| 651 | if(compression_type==0x00) |
|---|
| 652 | { |
|---|
| 653 | if(mode==0) /* select ISO/IEC 10646-1 Page 0x00 : ASCII, ISO Latin-1 (Roman) */ |
|---|
| 654 | { |
|---|
| 655 | number_chars = number_bytes; |
|---|
| 656 | tmp_decoded_length += number_chars; |
|---|
| 657 | if(tmp_decoded_length > max_dec_length) /* ¹öÆÛÅ©±âº¸´Ù ¸¹Àº ¾çÀÌ decodingµÇ¾ú³ª? */ |
|---|
| 658 | { |
|---|
| 659 | left_text_room = max_dec_length + number_chars - tmp_decoded_length; |
|---|
| 660 | for(k=0; k<left_text_room; k++) |
|---|
| 661 | *tmp_decoded_text++ = (UINT16)(*(text+k)); |
|---|
| 662 | tmp_decoded_length = max_dec_length; /* ´õÀÌ»ó decodingÇÒ Çʿ䰡 ¾ø´Ù. */ |
|---|
| 663 | //neverdai. 100818 ¹ö±×Àεí. decoded_length°¡ ¾÷µ¥ÀÌÆ®µÇÁö ¾Ê¾Æ 0ÀÌ ¸®ÅÏµÊ |
|---|
| 664 | decoded_length=max_dec_length; |
|---|
| 665 | fStringDecodeDone = 1; |
|---|
| 666 | break; /* segment level decoding stop. */ |
|---|
| 667 | } |
|---|
| 668 | else /* copyÇÒ ÃæºÐÇÑ °ø°£ÀÌ ³²¾ÆÀÖ´Ù. */ |
|---|
| 669 | { |
|---|
| 670 | for(k=0; k<number_chars; k++) |
|---|
| 671 | *tmp_decoded_text++ = (UINT16)(*(text+k)); |
|---|
| 672 | } |
|---|
| 673 | text += number_bytes; /* 8bit pointer Áõ°¡ */ |
|---|
| 674 | } |
|---|
| 675 | else if(mode<0x3f) /* select ISO/IEC 10646-1 Page 0x0 */ |
|---|
| 676 | { |
|---|
| 677 | #ifdef _EPG_DEBUG_ |
|---|
| 678 | epgPrintf("Unsupported language code, skip\n"); |
|---|
| 679 | #endif |
|---|
| 680 | text += number_bytes; /* 8bit pointer Áõ°¡ */ |
|---|
| 681 | } |
|---|
| 682 | else if(mode==0x3f) /* select ISO/IEC 10646-1 mode (all) - KOREAN mode only */ |
|---|
| 683 | { |
|---|
| 684 | number_chars = number_bytes/2; |
|---|
| 685 | |
|---|
| 686 | tmp_decoded_length += number_chars; |
|---|
| 687 | if(tmp_decoded_length > max_dec_length) /* ¹öÆÛÅ©±âº¸´Ù ¸¹Àº ¾çÀÌ decodingµÇ¾ú³ª? */ |
|---|
| 688 | { |
|---|
| 689 | left_text_room = max_dec_length + number_chars - tmp_decoded_length; |
|---|
| 690 | #if 1 /* neverdai 080902 endian ¹®Á¦·Î 2byte ±Û²ÃÀÌ ÂïÈ÷Áö ¾Ê´Â ¹®Á¦ ÀÖÀ½ */ |
|---|
| 691 | for(k=0; k<left_text_room; k++) |
|---|
| 692 | *tmp_decoded_text++ = (text[k*2]<<8) | text[k*2+1]; |
|---|
| 693 | #else |
|---|
| 694 | memcpy((char *)tmp_decoded_text, text, left_text_room*2); |
|---|
| 695 | #endif |
|---|
| 696 | tmp_decoded_length = max_dec_length; /* ´õÀÌ»ó decodingÇÒ Çʿ䰡 ¾ø´Ù. */ |
|---|
| 697 | //neverdai. 100818 ¹ö±×Àεí. decoded_length°¡ ¾÷µ¥ÀÌÆ®µÇÁö ¾Ê¾Æ 0ÀÌ ¸®ÅÏµÊ |
|---|
| 698 | decoded_length=max_dec_length; |
|---|
| 699 | fStringDecodeDone = 1; |
|---|
| 700 | break; /* segment level decoding stop. */ |
|---|
| 701 | } |
|---|
| 702 | else /* copyÇÒ ÃæºÐÇÑ °ø°£ÀÌ ³²¾ÆÀÖ´Ù. */ |
|---|
| 703 | { |
|---|
| 704 | #if 1 /* neverdai 080902 endian ¹®Á¦·Î 2byte ±Û²ÃÀÌ ÂïÈ÷Áö ¾Ê´Â ¹®Á¦ ÀÖÀ½ */ |
|---|
| 705 | for(k=0; k<number_chars; k++) |
|---|
| 706 | *tmp_decoded_text++ = (text[k*2]<<8) | text[k*2+1];; |
|---|
| 707 | #else |
|---|
| 708 | memcpy((char *)tmp_decoded_text, text, number_bytes); |
|---|
| 709 | tmp_decoded_text += number_chars; |
|---|
| 710 | #endif |
|---|
| 711 | |
|---|
| 712 | tmp_decoded_text += number_chars; |
|---|
| 713 | } |
|---|
| 714 | text += number_bytes; /* 8bit pointer Áõ°¡ */ |
|---|
| 715 | } |
|---|
| 716 | else if(mode==0x48) /* ¿Ï¼ºÇü ÇѱÛ. */ |
|---|
| 717 | { |
|---|
| 718 | for(k=0; k<number_bytes; k++) |
|---|
| 719 | { |
|---|
| 720 | ucode = *text++; |
|---|
| 721 | if(ucode >= 0xb0) /* ¿Ï¼ºÇü ÇѱÛÀÓ. */ |
|---|
| 722 | { |
|---|
| 723 | ucode = (ucode << 8) | (*text); |
|---|
| 724 | text++; |
|---|
| 725 | k++; |
|---|
| 726 | } |
|---|
| 727 | /* ¿Ï¼ºÇüÀ» unicode Çѱ۷Π¹Ù²Û´Ù. */ |
|---|
| 728 | if((ucode>=45217)&&(ucode<=51454)) |
|---|
| 729 | { |
|---|
| 730 | ucode -= 45217; |
|---|
| 731 | ucode = (ucode/256)*94 + (ucode%256); |
|---|
| 732 | ucode = cktouk[ucode]; |
|---|
| 733 | } |
|---|
| 734 | tmp_decoded_length++; |
|---|
| 735 | *tmp_decoded_text++ = ucode; |
|---|
| 736 | if(tmp_decoded_length > max_dec_length) /* ¹öÆÛÅ©±âº¸´Ù ¸¹Àº ¾çÀÌ decodingµÇ¾ú³ª? */ |
|---|
| 737 | { |
|---|
| 738 | text += (number_bytes-k); /* ´ÙÀ½ string±îÁö pointer Áõ°¡ */ |
|---|
| 739 | fStringDecodeDone = 1; /* ÇØ´ç¾ð¾î string decode done!! */ |
|---|
| 740 | break; /* segment level decoding stop. */ |
|---|
| 741 | } |
|---|
| 742 | } |
|---|
| 743 | } |
|---|
| 744 | else |
|---|
| 745 | { |
|---|
| 746 | #ifdef _EPG_DEBUG_ |
|---|
| 747 | epgPrintf("Reserved, User private, or Not applicable mode, skip\n"); |
|---|
| 748 | #endif |
|---|
| 749 | text += number_bytes; |
|---|
| 750 | } |
|---|
| 751 | } |
|---|
| 752 | else if(compression_type==0x01) /* ASCII range(1-127)¿¡¸¸ Àû¿ëµÊ. */ |
|---|
| 753 | { |
|---|
| 754 | DecodeHuffmanString (text, number_bytes, cm_Huffman_C4C5, |
|---|
| 755 | (char *)string, max_dec_length); |
|---|
| 756 | for(k=0; string[k]!='\0'; k++) |
|---|
| 757 | { |
|---|
| 758 | *tmp_decoded_text++ = (UINT16)string[k]; /* 8-bit ascii¸¦ unicode·Î ¹Ù²Þ */ |
|---|
| 759 | tmp_decoded_length++; |
|---|
| 760 | if(tmp_decoded_length == max_dec_length) /* ¹öÆÛ¿¡ ³²Àº °ø°£ÀÌ ¾ø´Â°¡? */ |
|---|
| 761 | { |
|---|
| 762 | fStringDecodeDone = 1; |
|---|
| 763 | break; /* segment level decoding stop. */ |
|---|
| 764 | } |
|---|
| 765 | } |
|---|
| 766 | text += number_bytes; /* 8bit pointer Áõ°¡ */ |
|---|
| 767 | } |
|---|
| 768 | else if(compression_type==0x02) /* ASCII range(1-127)¿¡¸¸ Àû¿ëµÊ. */ |
|---|
| 769 | { |
|---|
| 770 | DecodeHuffmanString (text, number_bytes, cm_Huffman_C6C7, |
|---|
| 771 | (char *)string, max_dec_length); |
|---|
| 772 | for(k=0; string[k]!='\0'; k++) |
|---|
| 773 | { |
|---|
| 774 | *tmp_decoded_text++ = (UINT16)string[k]; /* 8-bit ascii¸¦ unicode·Î ¹Ù²Þ */ |
|---|
| 775 | tmp_decoded_length++; |
|---|
| 776 | if(tmp_decoded_length == max_dec_length) /* ¹öÆÛ¿¡ ³²Àº °ø°£ÀÌ ¾ø´Â°¡? */ |
|---|
| 777 | { |
|---|
| 778 | fStringDecodeDone = 1; |
|---|
| 779 | break; /* segment level decoding stop. */ |
|---|
| 780 | } |
|---|
| 781 | } |
|---|
| 782 | text += number_bytes; /* 8bit pointer Áõ°¡ */ |
|---|
| 783 | } |
|---|
| 784 | else |
|---|
| 785 | { |
|---|
| 786 | #ifdef _EPG_DEBUG_ |
|---|
| 787 | epgPrintf("unexpected compression_type error(lang:0x%02x%02x%02x, comp_type:0x%02x)\n", |
|---|
| 788 | iso_lang_code[0], iso_lang_code[1], iso_lang_code[2], compression_type); |
|---|
| 789 | #endif |
|---|
| 790 | text += number_bytes; /* 8bit pointer Áõ°¡ */ |
|---|
| 791 | continue; |
|---|
| 792 | } |
|---|
| 793 | } /* end fStringDecodeDone==0 */ |
|---|
| 794 | /* end for(j=0;j<number_segments;j++) */ |
|---|
| 795 | } |
|---|
| 796 | decoded_length = tmp_decoded_length; |
|---|
| 797 | if(found_match_lang==0) /* ´õÀÌ»ó parsingÇÒ Çʿ䰡 ¾ø´Ù. */ |
|---|
| 798 | break; |
|---|
| 799 | } |
|---|
| 800 | |
|---|
| 801 | if(string) |
|---|
| 802 | DHL_OS_Free((void**)&string); |
|---|
| 803 | |
|---|
| 804 | return decoded_length; /* decoding °á°ú textÀÇ ±æÀÌ */ |
|---|
| 805 | } |
|---|
| 806 | |
|---|
| 807 | |
|---|
| 808 | |
|---|
| 809 | #if COMMENT |
|---|
| 810 | ____Debug____(){} |
|---|
| 811 | #endif |
|---|
| 812 | |
|---|
| 813 | |
|---|
| 814 | void DLIB_PSI_MemDump(void *ptr, UINT32 size, UINT32 width, UINT8 indent) |
|---|
| 815 | { |
|---|
| 816 | UINT32 addr = (UINT32)ptr; |
|---|
| 817 | UINT32 offset, k; |
|---|
| 818 | UINT8 *buf, buf0[16+4]; // include safe-guard. |
|---|
| 819 | UINT32 data; |
|---|
| 820 | char ib[33]; // indent buffer |
|---|
| 821 | |
|---|
| 822 | buf = (UINT8 *)(((UINT32)buf0 + 3) & ~3); // make 4 byte alignment. |
|---|
| 823 | |
|---|
| 824 | if (width != 2 && width != 4) width = 1; |
|---|
| 825 | |
|---|
| 826 | if (addr & (width-1)) { |
|---|
| 827 | DHL_OS_Printf("!! addr %x not aligned to %d\n", addr, width); |
|---|
| 828 | return; |
|---|
| 829 | } |
|---|
| 830 | memset(ib, 0, sizeof(ib)); |
|---|
| 831 | ib[min(indent, 32)] = 0; |
|---|
| 832 | |
|---|
| 833 | for (offset=0; offset<size; offset+=16) |
|---|
| 834 | { |
|---|
| 835 | int len = min(16, size-offset); // dump size of this line. 1~16 |
|---|
| 836 | |
|---|
| 837 | memset(buf, 0, 16); |
|---|
| 838 | |
|---|
| 839 | // hex dump |
|---|
| 840 | //dprint("%08x: ", addr+offset); |
|---|
| 841 | DHL_OS_Printf("%s", ib); |
|---|
| 842 | |
|---|
| 843 | for (k=0; k<len; k+=width) { |
|---|
| 844 | if (width == 1) { |
|---|
| 845 | *(UINT8 *)(&buf[k]) = data = *(UINT8 *)(addr+offset+k); |
|---|
| 846 | DHL_OS_Printf("%02x ", data); |
|---|
| 847 | } |
|---|
| 848 | else if (width == 2) { |
|---|
| 849 | *(UINT16 *)(&buf[k]) = data = *(UINT16 *)(addr+offset+k); |
|---|
| 850 | DHL_OS_Printf("%04x ", data); |
|---|
| 851 | } |
|---|
| 852 | else if (width == 4) { |
|---|
| 853 | *(UINT32 *)(&buf[k]) = data = *(UINT32 *)(addr+offset+k); |
|---|
| 854 | DHL_OS_Printf("%08x ", data); |
|---|
| 855 | } |
|---|
| 856 | } |
|---|
| 857 | |
|---|
| 858 | for (; k<16; k+=width) { |
|---|
| 859 | if (width == 1) |
|---|
| 860 | DHL_OS_Printf("__ "); |
|---|
| 861 | else if (width == 2) |
|---|
| 862 | DHL_OS_Printf("____ "); |
|---|
| 863 | else if (width == 4) |
|---|
| 864 | DHL_OS_Printf("________ "); |
|---|
| 865 | } |
|---|
| 866 | DHL_OS_Printf(" "); |
|---|
| 867 | |
|---|
| 868 | // ascii dump |
|---|
| 869 | for (k=0; k<16; k++) { |
|---|
| 870 | DHL_OS_Printf("%c", buf[k]>=0x20 && buf[k]<0x7f ? buf[k] : '.'); |
|---|
| 871 | } |
|---|
| 872 | DHL_OS_Printf("\n"); |
|---|
| 873 | |
|---|
| 874 | } |
|---|
| 875 | DHL_OS_Printf("\n"); |
|---|
| 876 | |
|---|
| 877 | } |
|---|
| 878 | |
|---|
| 879 | |
|---|
| 880 | |
|---|
| 881 | |
|---|
| 882 | #if COMMENT |
|---|
| 883 | ____Debug____(){} |
|---|
| 884 | #endif |
|---|
| 885 | |
|---|
| 886 | |
|---|
| 887 | |
|---|
| 888 | |
|---|
| 889 | #if COMMENT |
|---|
| 890 | ____Symbol____(){} |
|---|
| 891 | #endif |
|---|
| 892 | |
|---|
| 893 | |
|---|
| 894 | #if 0 //DHL_REGISTER_DEUBG_SYMBOLS |
|---|
| 895 | |
|---|
| 896 | static DHL_SymbolTable _XxxxSymbols[] = |
|---|
| 897 | { |
|---|
| 898 | /* however, if you want typing short-cut, it is good usage. |
|---|
| 899 | DHL_FNC_SYM_ENTRY2("epg_start", App_EpgUpdateStart), |
|---|
| 900 | DHL_FNC_SYM_ENTRY2("epg_stop", App_EpgUpdateCancel), |
|---|
| 901 | DHL_FNC_SYM_ENTRY2("epg_list", Dmc_EpgPrintAllTables), |
|---|
| 902 | DHL_FNC_SYM_ENTRY2("epg_delete", App_EpgDeleteAll), |
|---|
| 903 | |
|---|
| 904 | DHL_VAR_SYM_ENTRY(g_XX_TestMode), |
|---|
| 905 | */ |
|---|
| 906 | 0, |
|---|
| 907 | }; |
|---|
| 908 | |
|---|
| 909 | #endif /* DHL_REGISTER_DEUBG_SYMBOLS */ |
|---|
| 910 | |
|---|
| 911 | |
|---|
| 912 | |
|---|
| 913 | #if COMMENT |
|---|
| 914 | ____Init____(){} |
|---|
| 915 | #endif |
|---|
| 916 | |
|---|
| 917 | |
|---|
| 918 | |
|---|
| 919 | /* end of file */ |
|---|
| 920 | |
|---|