fix national option subset selection,
[vuplus_dvbapp] / lib / dvb / teletext.cpp
index e2daa8e..4fa0a8a 100644 (file)
@@ -43,14 +43,14 @@ unsigned char NationalReplaceMap[128] =
 // see table 36 in ETSI EN 300 706
 
 unsigned int NationalOptionSubsets[13*14] = {
-       0, 0x0023, 0xc5af, 0xc48d, 0xc5a5, 0xc5be, 0xc3bd, 0xc3ad, 0xc599, 0xc3a9, 0xc3a1, 0xc49b, 0xc3ba, 0xc5a1, // Slovak/Czech
+       0, 0x0023, 0xc5af, 0xc48d, 0xc5a3, 0xc5be, 0xc3bd, 0xc3ad, 0xc599, 0xc3a9, 0xc3a1, 0xc49b, 0xc3ba, 0xc5a1, // Slovak/Czech
        0, 0xc2a3, 0x0024, 0x0040, 0xe28690, 0xc2bd, 0xe28692, 0xe28691, 0x0023, 0x002d, 0xc2bc, 0xc781, 0xc2be, 0xc3b7, // English
        0, 0x0023, 0xc3b5, 0xc5A0, 0xc384, 0xc396, 0xc5bd, 0xc39c, 0xc395, 0xc5a1, 0xc3a4, 0xc3b6, 0xc5be, 0xc3bc, // Estonian
        0, 0xc3a9, 0xc3af, 0xc3a0, 0xc3ab, 0xc3aa, 0xc3b9, 0xc3ae, 0x0023, 0xc3a8, 0xc3a2, 0xc3b4, 0xc3bb, 0xc3a7, // French
        0, 0x0023, 0x0024, 0xc2a7, 0xc384, 0xc396, 0xc39c, 0x005e, 0x005f, 0xcb9a, 0xc3a4, 0xc3b6, 0xc3bc, 0xc39f, // German
        0, 0xc2a3, 0x0024, 0xc3a9, 0xcb9a, 0xc3a7, 0xe28692, 0xe28691, 0x0023, 0xc3b9, 0xc3a0, 0xc3b2, 0xc3a8, 0xc3ac, // Italian
        0, 0x0023, 0x0024, 0xc5a0, 0xc497, 0xc8a9, 0xc5bd, 0xc48d, 0xc5ab, 0xc5a1, 0xc485, 0xc5b3, 0xc5be, 0xc4af/*FIXMEE*/, // Lithuanian/Lettish
-       0, 0x0023, 0xc584, 0xc485, 0xc6b5, 0xc59a, 0xc581, 0xc487, 0xc3b3, 0xc8a9, 0xc5bc, 0xc59b, 0xc582, 0xc5ba, // Polish
+       0, 0x0023, 0xc584, 0xc485, 0xc6b5, 0xc59a, 0xc581, 0xc487, 0xc3b3, 0xc499, 0xc5bc, 0xc59b, 0xc582, 0xc5ba, // Polish
        0, 0xc3a7, 0x0024, 0xc2a1, 0xc3a1, 0xc3a9, 0xc3ad, 0xc3b3, 0xc3ba, 0xc2bf, 0xc3bc, 0xc3b1, 0xc3a8, 0xc3a0, // Spanish/Portuguese
        0, 0x0023, 0xc2a4, 0xc5a2, 0xc382, 0xc59e, 0xc78d, 0xc38e, 0xc4b1, 0xc5a3, 0xc3a2, 0xc59f, 0xc78e, 0xc3ae, // Rumanian
        0, 0x0023, 0xc38b, 0xc48c, 0xc486, 0xc5bd, 0xc490, 0xc5a0, 0xc3ab, 0xc48d, 0xc487, 0xc5be, 0xc491, 0xc5a1, // Slovenian/Serbian/Croation
@@ -169,11 +169,11 @@ void eDVBTeletextParser::processPESPacket(__u8 *pkt, int len)
                        break;
                }
                
-               if (data_unit_id != 0x03)
-               {
-                       /* eDebug("non subtitle data unit id %d", data_unit_id); */
-                       break;
-               }
+//             if (data_unit_id != 0x03)
+//             {
+//                     /* eDebug("non subtitle data unit id %d", data_unit_id); */
+//                     break;
+//             }
                
                unsigned char line_offset = *p++; len--;
                unsigned char framing_code = *p++; len--;
@@ -185,7 +185,7 @@ void eDVBTeletextParser::processPESPacket(__u8 *pkt, int len)
                
                if (framing_code != 0xe4) /* no teletxt data */
                        continue;
-               
+
                m_M = magazine_and_packet_address & 7;
                m_Y = magazine_and_packet_address >> 3;
 
@@ -348,7 +348,7 @@ void eDVBTeletextParser::handlePageEnd(int have_pts, const pts_t &pts)
 void eDVBTeletextParser::setPageAndMagazine(int page, int magazine)
 {
        if (page > 0)
-               eDebug("enable teletext subtitle page %d", page);
+               eDebug("enable teletext subtitle page %x%02x", magazine, page);
        else
                eDebug("disable teletext subtitles");
        m_page_M = magazine&7; /* magazine to look for */
@@ -376,17 +376,23 @@ void eDVBTeletextParser::addSubtitleString(int color, std::string string)
                idx = 0,
                outidx = 0,
                Gtriplet = 0,
-               nat_opts = (m_C >> 11) & 0x7,
+               nat_opts = (m_C & (1<<14) ? 1 : 0) | (m_C & (1<<13) ? 2 : 0) | (m_C & (1<<12) ? 4 : 0),
                nat_subset = NationalOptionSubsetsLookup[Gtriplet*8+nat_opts];
+//     eDebug("nat_opts = %d, nat_subset = %d, m_C %08x, C121314 = %d%d%d",
+//             nat_opts, nat_subset, m_C,
+//             (m_C & (1<<12))?1:0,
+//             (m_C & (1<<13))?1:0,
+//             (m_C & (1<<14))?1:0);
        while (idx < len)
        {
                unsigned char c = string[idx];
                if (c >= 0x20)
                {
-                       if (NationalReplaceMap[c])
+                       unsigned char offs = NationalReplaceMap[c];
+                       if (offs)
                        {
                                unsigned int utf8_code =
-                                       NationalOptionSubsets[nat_subset*14+c];
+                                       NationalOptionSubsets[nat_subset*14+offs];
                                if (utf8_code > 0xFFFFFF)
                                        out[outidx++]=(utf8_code&0xFF000000)>>24;
                                if (utf8_code > 0xFFFF)