Ticket #1420: mythtv_codec_chaching2.patch
| File mythtv_codec_chaching2.patch, 2.1 KB (added by , 20 years ago) |
|---|
-
libs/libmythtv/mpeg/dvbdescriptors.cpp
7 7 // Decode a text string according to ETSI EN 300 468 Annex A 8 8 QString dvb_decode_text(const unsigned char *src, uint length) 9 9 { 10 // array for caching all 16 ISO8859 tables 11 static QTextCodec * codecs[16]; 10 12 QString result; 11 13 12 14 if (!length) 13 15 return QString(""); 14 16 … … 30 32 } 31 33 else if ((buf[0] >= 0x01) && (buf[0] <= 0x0B)) 32 34 { 33 QString coding = "ISO8859-" + QString::number(4 + buf[0]); 34 QTextCodec *codec = QTextCodec::codecForName(coding); 35 result = codec->toUnicode((const char*)buf + 1, length - 1); 35 uint code = 4 + buf[0]; 36 if (!codecs[code-1]) 37 { 38 QString coding = "ISO8859-" + QString::number(code); 39 codecs[code-1] = QTextCodec::codecForName(coding); 40 } 41 result = codecs[code-1]->toUnicode((const char*)buf + 1, length - 1); 36 42 } 37 43 else if (buf[0] == 0x10) 38 44 { … … 44 50 45 51 uint code = 1; 46 52 swab(buf + 1, &code, 2); 47 QString coding = "ISO8859-" + QString::number(code); 48 QTextCodec *codec = QTextCodec::codecForName(coding); 49 result = codec->toUnicode((const char*)buf + 3, length - 3); 53 // check for valid ISO8859 code table 54 if (code>0 && code<17) 55 { 56 if (!codecs[code-1]) { 57 QString coding = "ISO8859-" + QString::number(code); 58 codecs[code-1] = QTextCodec::codecForName(coding); 59 } 60 result = codecs[code-1]->toUnicode((const char*)buf + 3, length - 3); 61 } 62 else 63 { 64 VERBOSE(VB_SIPARSER, "dvbdescriptors.cpp: " 65 "Invalid encoding - ignoring (maybe transmission error)"); 66 result = "N/A"; 67 } 50 68 } 51 69 else 52 70 {
