Merge pull request #4217 from Montellese/jsonrpc_music_type_unknown
[vuplus_xbmc] / xbmc / video / TeletextDefines.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include "utils/StdString.h"
24
25 #define FLOFSIZE 4
26 #define SUBTITLE_CACHESIZE 50
27
28 #define number2char(c) ((c) + (((c) <= 9) ? '0' : ('A' - 10)))
29
30 enum /* indices in atrtable */
31 {
32   ATR_WB, /* white on black */
33   ATR_PassiveDefault, /* Default for passive objects: white on black, ignore at Black Background Color Substitution */
34   ATR_L250, /* line25 */
35   ATR_L251, /* line25 */
36   ATR_L252, /* line25 */
37   ATR_L253, /* line25 */
38   ATR_TOPMENU0, /* topmenu */
39   ATR_TOPMENU1, /* topmenu */
40   ATR_TOPMENU2, /* topmenu */
41   ATR_TOPMENU3, /* topmenu */
42   ATR_MSG0, /* message */
43   ATR_MSG1, /* message */
44   ATR_MSG2, /* message */
45   ATR_MSG3, /* message */
46   ATR_MSGDRM0, /* message */
47   ATR_MSGDRM1, /* message */
48   ATR_MSGDRM2, /* message */
49   ATR_MSGDRM3, /* message */
50   ATR_MENUHIL0, /* hilit menu line */
51   ATR_MENUHIL1, /* hilit menu line */
52   ATR_MENUHIL2, /* hilit menu line */
53   ATR_MENU0, /* menu line */
54   ATR_MENU1, /* menu line */
55   ATR_MENU2, /* menu line */
56   ATR_MENU3, /* menu line */
57   ATR_MENU4, /* menu line */
58   ATR_MENU5, /* menu line */
59   ATR_MENU6, /* menu line */
60   ATR_CATCHMENU0, /* catch menu line */
61   ATR_CATCHMENU1 /* catch menu line */
62 };
63
64 /* colortable */
65 enum enumTeletextColor
66 {
67   TXT_ColorBlack = 0,
68   TXT_ColorRed, /* 1 */
69   TXT_ColorGreen, /* 2 */
70   TXT_ColorYellow, /* 3 */
71   TXT_ColorBlue,  /* 4 */
72   TXT_ColorMagenta,  /* 5 */
73   TXT_ColorCyan,  /* 6 */
74   TXT_ColorWhite, /* 7 */
75   TXT_ColorMenu1 = (4*8),
76   TXT_ColorMenu2,
77   TXT_ColorMenu3,
78   TXT_ColorTransp,
79   TXT_ColorTransp2,
80   TXT_Color_SIZECOLTABLE
81 };
82
83 enum /* options for charset */
84 {
85   C_G0P = 0, /* primary G0 */
86   C_G0S, /* secondary G0 */
87   C_G1C, /* G1 contiguous */
88   C_G1S, /* G1 separate */
89   C_G2,
90   C_G3,
91   C_OFFSET_DRCS = 32
92   /* 32..47: 32+subpage# GDRCS (offset/20 in PageChar) */
93   /* 48..63: 48+subpage#  DRCS (offset/20 in PageChar) */
94 };
95
96 enum /* page function */
97 {
98   FUNC_LOP = 0, /* Basic Level 1 Teletext page (LOP) */
99   FUNC_DATA, /* Data broadcasting page coded according to EN 300 708 [2] clause 4 */
100   FUNC_GPOP, /* Global Object definition page (GPOP) - (see clause 10.5.1) */
101   FUNC_POP, /* Normal Object definition page (POP) - (see clause 10.5.1) */
102   FUNC_GDRCS, /* Global DRCS downloading page (GDRCS) - (see clause 10.5.2) */
103   FUNC_DRCS, /* Normal DRCS downloading page (DRCS) - (see clause 10.5.2) */
104   FUNC_MOT, /* Magazine Organization table (MOT) - (see clause 10.6) */
105   FUNC_MIP, /* Magazine Inventory page (MIP) - (see clause 11.3) */
106   FUNC_BTT, /* Basic TOP table (BTT) } */
107   FUNC_AIT, /* Additional Information Table (AIT) } (see clause 11.2) */
108   FUNC_MPT, /* Multi-page table (MPT) } */
109   FUNC_MPTEX, /* Multi-page extension table (MPT-EX) } */
110   FUNC_TRIGGER /* Page contain trigger messages defined according to [8] */
111 };
112
113 enum
114 {
115   NAT_DEFAULT = 0,
116   NAT_CZ = 1,
117   NAT_UK = 2,
118   NAT_ET = 3,
119   NAT_FR = 4,
120   NAT_DE = 5,
121   NAT_IT = 6,
122   NAT_LV = 7,
123   NAT_PL = 8,
124   NAT_SP = 9,
125   NAT_RO = 10,
126   NAT_SR = 11,
127   NAT_SW = 12,
128   NAT_TR = 13,
129   NAT_MAX_FROM_HEADER = 13,
130   NAT_SC = 14,
131   NAT_RB = 15,
132   NAT_UA = 16,
133   NAT_GR = 17,
134   NAT_HB = 18,
135   NAT_AR = 19
136 };
137
138 const unsigned char CountryConversionTable[] = { NAT_UK, NAT_DE, NAT_SW, NAT_IT, NAT_FR, NAT_SP, NAT_CZ, NAT_RO};
139 const unsigned char MapTblFG[] = {  0,  0,  8,  8, 16, 16, 16 };
140 const unsigned char MapTblBG[] = {  8, 16,  8, 16,  8, 16, 24 };
141 const unsigned short DefaultColors[] =  /* 0x0bgr */
142 {
143   0x000, 0x00f, 0x0f0, 0x0ff, 0xf00, 0xf0f, 0xff0, 0xfff,
144   0x000, 0x007, 0x070, 0x077, 0x700, 0x707, 0x770, 0x777,
145   0x50f, 0x07f, 0x7f0, 0xbff, 0xac0, 0x005, 0x256, 0x77c,
146   0x333, 0x77f, 0x7f7, 0x7ff, 0xf77, 0xf7f, 0xff7, 0xddd,
147   0x420, 0x210, 0x420, 0x000, 0x000
148 };
149
150 /* hamming table */
151 const unsigned char dehamming[] =
152 {
153   0x01, 0xFF, 0x01, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0xFF, 0x02, 0x01, 0xFF, 0x0A, 0xFF, 0xFF, 0x07,
154   0xFF, 0x00, 0x01, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x06, 0xFF, 0xFF, 0x0B, 0xFF, 0x00, 0x03, 0xFF,
155   0xFF, 0x0C, 0x01, 0xFF, 0x04, 0xFF, 0xFF, 0x07, 0x06, 0xFF, 0xFF, 0x07, 0xFF, 0x07, 0x07, 0x07,
156   0x06, 0xFF, 0xFF, 0x05, 0xFF, 0x00, 0x0D, 0xFF, 0x06, 0x06, 0x06, 0xFF, 0x06, 0xFF, 0xFF, 0x07,
157   0xFF, 0x02, 0x01, 0xFF, 0x04, 0xFF, 0xFF, 0x09, 0x02, 0x02, 0xFF, 0x02, 0xFF, 0x02, 0x03, 0xFF,
158   0x08, 0xFF, 0xFF, 0x05, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x02, 0x03, 0xFF, 0x03, 0xFF, 0x03, 0x03,
159   0x04, 0xFF, 0xFF, 0x05, 0x04, 0x04, 0x04, 0xFF, 0xFF, 0x02, 0x0F, 0xFF, 0x04, 0xFF, 0xFF, 0x07,
160   0xFF, 0x05, 0x05, 0x05, 0x04, 0xFF, 0xFF, 0x05, 0x06, 0xFF, 0xFF, 0x05, 0xFF, 0x0E, 0x03, 0xFF,
161   0xFF, 0x0C, 0x01, 0xFF, 0x0A, 0xFF, 0xFF, 0x09, 0x0A, 0xFF, 0xFF, 0x0B, 0x0A, 0x0A, 0x0A, 0xFF,
162   0x08, 0xFF, 0xFF, 0x0B, 0xFF, 0x00, 0x0D, 0xFF, 0xFF, 0x0B, 0x0B, 0x0B, 0x0A, 0xFF, 0xFF, 0x0B,
163   0x0C, 0x0C, 0xFF, 0x0C, 0xFF, 0x0C, 0x0D, 0xFF, 0xFF, 0x0C, 0x0F, 0xFF, 0x0A, 0xFF, 0xFF, 0x07,
164   0xFF, 0x0C, 0x0D, 0xFF, 0x0D, 0xFF, 0x0D, 0x0D, 0x06, 0xFF, 0xFF, 0x0B, 0xFF, 0x0E, 0x0D, 0xFF,
165   0x08, 0xFF, 0xFF, 0x09, 0xFF, 0x09, 0x09, 0x09, 0xFF, 0x02, 0x0F, 0xFF, 0x0A, 0xFF, 0xFF, 0x09,
166   0x08, 0x08, 0x08, 0xFF, 0x08, 0xFF, 0xFF, 0x09, 0x08, 0xFF, 0xFF, 0x0B, 0xFF, 0x0E, 0x03, 0xFF,
167   0xFF, 0x0C, 0x0F, 0xFF, 0x04, 0xFF, 0xFF, 0x09, 0x0F, 0xFF, 0x0F, 0x0F, 0xFF, 0x0E, 0x0F, 0xFF,
168   0x08, 0xFF, 0xFF, 0x05, 0xFF, 0x0E, 0x0D, 0xFF, 0xFF, 0x0E, 0x0F, 0xFF, 0x0E, 0x0E, 0xFF, 0x0E
169 };
170
171 /* odd parity table, error=0x20 (space) */
172 const unsigned char deparity[] =
173 {
174   ' ' , 0x01, 0x02, ' ' , 0x04, ' ' , ' ' , 0x07, 0x08, ' ' , ' ' , 0x0b, ' ' , 0x0d, 0x0e, ' ' ,
175   0x10, ' ' , ' ' , 0x13, ' ' , 0x15, 0x16, ' ' , ' ' , 0x19, 0x1a, ' ' , 0x1c, ' ' , ' ' , 0x1f,
176   0x20, ' ' , ' ' , 0x23, ' ' , 0x25, 0x26, ' ' , ' ' , 0x29, 0x2a, ' ' , 0x2c, ' ' , ' ' , 0x2f,
177   ' ' , 0x31, 0x32, ' ' , 0x34, ' ' , ' ' , 0x37, 0x38, ' ' , ' ' , 0x3b, ' ' , 0x3d, 0x3e, ' ' ,
178   0x40, ' ' , ' ' , 0x43, ' ' , 0x45, 0x46, ' ' , ' ' , 0x49, 0x4a, ' ' , 0x4c, ' ' , ' ' , 0x4f,
179   ' ' , 0x51, 0x52, ' ' , 0x54, ' ' , ' ' , 0x57, 0x58, ' ' , ' ' , 0x5b, ' ' , 0x5d, 0x5e, ' ' ,
180   ' ' , 0x61, 0x62, ' ' , 0x64, ' ' , ' ' , 0x67, 0x68, ' ' , ' ' , 0x6b, ' ' , 0x6d, 0x6e, ' ' ,
181   0x70, ' ' , ' ' , 0x73, ' ' , 0x75, 0x76, ' ' , ' ' , 0x79, 0x7a, ' ' , 0x7c, ' ' , ' ' , 0x7f,
182   0x00, ' ' , ' ' , 0x03, ' ' , 0x05, 0x06, ' ' , ' ' , 0x09, 0x0a, ' ' , 0x0c, ' ' , ' ' , 0x0f,
183   ' ' , 0x11, 0x12, ' ' , 0x14, ' ' , ' ' , 0x17, 0x18, ' ' , ' ' , 0x1b, ' ' , 0x1d, 0x1e, ' ' ,
184   ' ' , 0x21, 0x22, ' ' , 0x24, ' ' , ' ' , 0x27, 0x28, ' ' , ' ' , 0x2b, ' ' , 0x2d, 0x2e, ' ' ,
185   0x30, ' ' , ' ' , 0x33, ' ' , 0x35, 0x36, ' ' , ' ' , 0x39, 0x3a, ' ' , 0x3c, ' ' , ' ' , 0x3f,
186   ' ' , 0x41, 0x42, ' ' , 0x44, ' ' , ' ' , 0x47, 0x48, ' ' , ' ' , 0x4b, ' ' , 0x4d, 0x4e, ' ' ,
187   0x50, ' ' , ' ' , 0x53, ' ' , 0x55, 0x56, ' ' , ' ' , 0x59, 0x5a, ' ' , 0x5c, ' ' , ' ' , 0x5f,
188   0x60, ' ' , ' ' , 0x63, ' ' , 0x65, 0x66, ' ' , ' ' , 0x69, 0x6a, ' ' , 0x6c, ' ' , ' ' , 0x6f,
189   ' ' , 0x71, 0x72, ' ' , 0x74, ' ' , ' ' , 0x77, 0x78, ' ' , ' ' , 0x7b, ' ' , 0x7d, 0x7e, ' ' ,
190 };
191
192 /*
193  *  [AleVT]
194  *
195  *  This table generates the parity checks for hamm24/18 decoding.
196  *  Bit 0 is for test A, 1 for B, ...
197  *
198  *  Thanks to R. Gancarz for this fine table *g*
199  */
200 const unsigned char hamm24par[3][256] =
201 {
202     {
203         /* Parities of first byte */
204    0, 33, 34,  3, 35,  2,  1, 32, 36,  5,  6, 39,  7, 38, 37,  4,
205   37,  4,  7, 38,  6, 39, 36,  5,  1, 32, 35,  2, 34,  3,  0, 33,
206   38,  7,  4, 37,  5, 36, 39,  6,  2, 35, 32,  1, 33,  0,  3, 34,
207    3, 34, 33,  0, 32,  1,  2, 35, 39,  6,  5, 36,  4, 37, 38,  7,
208   39,  6,  5, 36,  4, 37, 38,  7,  3, 34, 33,  0, 32,  1,  2, 35,
209    2, 35, 32,  1, 33,  0,  3, 34, 38,  7,  4, 37,  5, 36, 39,  6,
210    1, 32, 35,  2, 34,  3,  0, 33, 37,  4,  7, 38,  6, 39, 36,  5,
211   36,  5,  6, 39,  7, 38, 37,  4,  0, 33, 34,  3, 35,  2,  1, 32,
212   40,  9, 10, 43, 11, 42, 41,  8, 12, 45, 46, 15, 47, 14, 13, 44,
213   13, 44, 47, 14, 46, 15, 12, 45, 41,  8, 11, 42, 10, 43, 40,  9,
214   14, 47, 44, 13, 45, 12, 15, 46, 42, 11,  8, 41,  9, 40, 43, 10,
215   43, 10,  9, 40,  8, 41, 42, 11, 15, 46, 45, 12, 44, 13, 14, 47,
216   15, 46, 45, 12, 44, 13, 14, 47, 43, 10,  9, 40,  8, 41, 42, 11,
217   42, 11,  8, 41,  9, 40, 43, 10, 14, 47, 44, 13, 45, 12, 15, 46,
218   41,  8, 11, 42, 10, 43, 40,  9, 13, 44, 47, 14, 46, 15, 12, 45,
219   12, 45, 46, 15, 47, 14, 13, 44, 40,  9, 10, 43, 11, 42, 41,  8
220     }, {
221         /* Parities of second byte */
222    0, 41, 42,  3, 43,  2,  1, 40, 44,  5,  6, 47,  7, 46, 45,  4,
223   45,  4,  7, 46,  6, 47, 44,  5,  1, 40, 43,  2, 42,  3,  0, 41,
224   46,  7,  4, 45,  5, 44, 47,  6,  2, 43, 40,  1, 41,  0,  3, 42,
225    3, 42, 41,  0, 40,  1,  2, 43, 47,  6,  5, 44,  4, 45, 46,  7,
226   47,  6,  5, 44,  4, 45, 46,  7,  3, 42, 41,  0, 40,  1,  2, 43,
227    2, 43, 40,  1, 41,  0,  3, 42, 46,  7,  4, 45,  5, 44, 47,  6,
228    1, 40, 43,  2, 42,  3,  0, 41, 45,  4,  7, 46,  6, 47, 44,  5,
229   44,  5,  6, 47,  7, 46, 45,  4,  0, 41, 42,  3, 43,  2,  1, 40,
230   48, 25, 26, 51, 27, 50, 49, 24, 28, 53, 54, 31, 55, 30, 29, 52,
231   29, 52, 55, 30, 54, 31, 28, 53, 49, 24, 27, 50, 26, 51, 48, 25,
232   30, 55, 52, 29, 53, 28, 31, 54, 50, 27, 24, 49, 25, 48, 51, 26,
233   51, 26, 25, 48, 24, 49, 50, 27, 31, 54, 53, 28, 52, 29, 30, 55,
234   31, 54, 53, 28, 52, 29, 30, 55, 51, 26, 25, 48, 24, 49, 50, 27,
235   50, 27, 24, 49, 25, 48, 51, 26, 30, 55, 52, 29, 53, 28, 31, 54,
236   49, 24, 27, 50, 26, 51, 48, 25, 29, 52, 55, 30, 54, 31, 28, 53,
237   28, 53, 54, 31, 55, 30, 29, 52, 48, 25, 26, 51, 27, 50, 49, 24
238     }, {
239         /* Parities of third byte */
240   63, 14, 13, 60, 12, 61, 62, 15, 11, 58, 57,  8, 56,  9, 10, 59,
241   10, 59, 56,  9, 57,  8, 11, 58, 62, 15, 12, 61, 13, 60, 63, 14,
242    9, 56, 59, 10, 58, 11,  8, 57, 61, 12, 15, 62, 14, 63, 60, 13,
243   60, 13, 14, 63, 15, 62, 61, 12,  8, 57, 58, 11, 59, 10,  9, 56,
244    8, 57, 58, 11, 59, 10,  9, 56, 60, 13, 14, 63, 15, 62, 61, 12,
245   61, 12, 15, 62, 14, 63, 60, 13,  9, 56, 59, 10, 58, 11,  8, 57,
246   62, 15, 12, 61, 13, 60, 63, 14, 10, 59, 56,  9, 57,  8, 11, 58,
247   11, 58, 57,  8, 56,  9, 10, 59, 63, 14, 13, 60, 12, 61, 62, 15,
248   31, 46, 45, 28, 44, 29, 30, 47, 43, 26, 25, 40, 24, 41, 42, 27,
249   42, 27, 24, 41, 25, 40, 43, 26, 30, 47, 44, 29, 45, 28, 31, 46,
250   41, 24, 27, 42, 26, 43, 40, 25, 29, 44, 47, 30, 46, 31, 28, 45,
251   28, 45, 46, 31, 47, 30, 29, 44, 40, 25, 26, 43, 27, 42, 41, 24,
252   40, 25, 26, 43, 27, 42, 41, 24, 28, 45, 46, 31, 47, 30, 29, 44,
253   29, 44, 47, 30, 46, 31, 28, 45, 41, 24, 27, 42, 26, 43, 40, 25,
254   30, 47, 44, 29, 45, 28, 31, 46, 42, 27, 24, 41, 25, 40, 43, 26,
255   43, 26, 25, 40, 24, 41, 42, 27, 31, 46, 45, 28, 44, 29, 30, 47
256     }
257 };
258
259 /*
260  *  [AleVT]
261  *
262  *  Table to extract the lower 4 bit from hamm24/18 encoded bytes
263  */
264 const unsigned char hamm24val[256] =
265 {
266       0,  0,  0,  0,  1,  1,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1,
267       2,  2,  2,  2,  3,  3,  3,  3,  2,  2,  2,  2,  3,  3,  3,  3,
268       4,  4,  4,  4,  5,  5,  5,  5,  4,  4,  4,  4,  5,  5,  5,  5,
269       6,  6,  6,  6,  7,  7,  7,  7,  6,  6,  6,  6,  7,  7,  7,  7,
270       8,  8,  8,  8,  9,  9,  9,  9,  8,  8,  8,  8,  9,  9,  9,  9,
271      10, 10, 10, 10, 11, 11, 11, 11, 10, 10, 10, 10, 11, 11, 11, 11,
272      12, 12, 12, 12, 13, 13, 13, 13, 12, 12, 12, 12, 13, 13, 13, 13,
273      14, 14, 14, 14, 15, 15, 15, 15, 14, 14, 14, 14, 15, 15, 15, 15,
274       0,  0,  0,  0,  1,  1,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1,
275       2,  2,  2,  2,  3,  3,  3,  3,  2,  2,  2,  2,  3,  3,  3,  3,
276       4,  4,  4,  4,  5,  5,  5,  5,  4,  4,  4,  4,  5,  5,  5,  5,
277       6,  6,  6,  6,  7,  7,  7,  7,  6,  6,  6,  6,  7,  7,  7,  7,
278       8,  8,  8,  8,  9,  9,  9,  9,  8,  8,  8,  8,  9,  9,  9,  9,
279      10, 10, 10, 10, 11, 11, 11, 11, 10, 10, 10, 10, 11, 11, 11, 11,
280      12, 12, 12, 12, 13, 13, 13, 13, 12, 12, 12, 12, 13, 13, 13, 13,
281      14, 14, 14, 14, 15, 15, 15, 15, 14, 14, 14, 14, 15, 15, 15, 15
282 };
283
284 const signed char hamm24err[64] =
285 {
286      0, -1, -1, -1,  -1, -1, -1, -1,  -1, -1, -1, -1,  -1, -1, -1, -1,
287     -1, -1, -1, -1,  -1, -1, -1, -1,  -1, -1, -1, -1,  -1, -1, -1, -1,
288      0,  0,  0,  0,   0,  0,  0,  0,   0,  0,  0,  0,   0,  0,  0,  0,
289      0,  0,  0,  0,   0,  0,  0,  0,  -1, -1, -1, -1,  -1, -1, -1, -1,
290 };
291
292 /*
293  *  [AleVT]
294  *
295  *  Mapping from parity checks made by table hamm24par to faulty bit
296  *  in the decoded 18 bit word.
297  */
298 const unsigned int hamm24cor[64] =
299 {
300     0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
301     0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
302     0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
303     0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
304     0x00000, 0x00000, 0x00000, 0x00001, 0x00000, 0x00002, 0x00004, 0x00008,
305     0x00000, 0x00010, 0x00020, 0x00040, 0x00080, 0x00100, 0x00200, 0x00400,
306     0x00000, 0x00800, 0x01000, 0x02000, 0x04000, 0x08000, 0x10000, 0x20000,
307     0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
308 };
309
310 inline int IsDec(int i)
311 {
312   return ((i & 0x00F) <= 9) && ((i & 0x0F0) <= 0x90);
313 }
314
315 /* struct for page attributes */
316 typedef struct
317 {
318   unsigned char fg      :6;           /* foreground color */
319   unsigned char bg      :6;           /* background color */
320   unsigned char charset :6;           /* see enum above */
321   unsigned char doubleh :1;           /* double height */
322   unsigned char doublew :1;           /* double width */
323   /* ignore at Black Background Color Substitution */
324   /* black background set by New Background ($1d) instead of start-of-row default or Black Backgr. ($1c) */
325   /* or black background set by level 2.5 extensions */
326   unsigned char IgnoreAtBlackBgSubst:1;
327   unsigned char concealed:1;            /* concealed information */
328   unsigned char inverted :1;            /* colors inverted */
329   unsigned char flashing :5;            /* flash mode */
330   unsigned char diacrit  :4;            /* diacritical mark */
331   unsigned char underline:1;            /* Text underlined */
332   unsigned char boxwin   :1;            /* Text boxed/windowed */
333   unsigned char setX26   :1;            /* Char is set by packet X/26 (no national subset used) */
334   unsigned char setG0G2  :7;            /* G0+G2 set designation  */
335 } TextPageAttr_t;
336
337 /* struct for (G)POP/(G)DRCS links for level 2.5, allocated at reception of p27/4 or /5, initialized with 0 after allocation */
338 typedef struct
339 {
340   unsigned short page;                  /* linked page number */
341   unsigned short subpage;               /* 1 bit for each needed (1) subpage */
342   unsigned char l25:1;                  /* 1: page required at level 2.5 */
343   unsigned char l35:1;                  /* 1: page required at level 3.5 */
344   unsigned char drcs:1;                 /* 1: link to (G)DRCS, 0: (G)POP */
345   unsigned char local:1;                /* 1: global (G*), 0: local */
346 } Textp27_t;
347
348 /* struct for extension data for level 2.5, allocated at reception, initialized with 0 after allocation */
349 typedef struct
350 {
351   unsigned char *p26[16];               /* array of pointers to max. 16 designation codes of packet 26 */
352   Textp27_t *p27;                       /* array of 4 structs for (G)POP/(G)DRCS links for level 2.5 */
353   unsigned short bgr[16];               /* CLUT 2+3, 2*8 colors, 0x0bgr */
354   unsigned char DefaultCharset:7;       /* default G0/G2 charset + national option */
355   unsigned char LSP:1;                  /* 1: left side panel to be displayed */
356   unsigned char SecondCharset:7;        /* second G0 charset */
357   unsigned char RSP:1;                  /* 1: right side panel to be displayed */
358   unsigned char DefScreenColor:5;       /* default screen color (above and below lines 0..24) */
359   unsigned char ColorTableRemapping:3;  /* 1: index in table of CLUTs to use */
360   unsigned char DefRowColor:5;          /* default row color (left and right to lines 0..24) */
361   unsigned char BlackBgSubst:1;         /* 1: substitute black background (as result of start-of-line or 1c, not 00/10+1d) */
362   unsigned char SPL25:1;                /* 1: side panel required at level 2.5 */
363   unsigned char p28Received:1;          /* 1: extension data valid (p28/0 received) */
364   unsigned char LSPColumns:4;           /* number of columns in left side panel, 0->16, rsp=16-lsp */
365 } TextExtData_t;
366
367 /* struct for pageinfo, max. 16 Bytes, at beginning of each cached page buffer, initialized with 0 after allocation */
368 typedef struct
369 {
370   unsigned char *p24;                   /* pointer to lines 25+26 (packets 24+25) (2*40 bytes) for FLOF or level 2.5 data */
371   TextExtData_t *ext;                   /* pointer to array[16] of data for level 2.5 */
372   unsigned char boxed         :1;       /* p0: boxed (newsflash or subtitle) */
373   unsigned char nationalvalid :1;       /* p0: national option character subset is valid (no biterror detected) */
374   unsigned char national      :3;       /* p0: national option character subset */
375   unsigned char function      :3;       /* p28/0: page function */
376 } TextPageinfo_t;
377
378 /* one cached page: struct for pageinfo, 24 lines page data */
379 typedef struct
380 {
381   TextPageinfo_t pageinfo;
382   unsigned char p0[24];                 /* packet 0: center of headline */
383   unsigned char data[23*40];            /* packet 1-23 */
384 } TextCachedPage_t;
385
386 typedef struct
387 {
388   short page;
389   short language;
390 } TextSubtitle_t;
391
392 typedef struct
393 {
394   bool Valid;
395   long Timestamp;
396   unsigned char  PageChar[40 * 25];
397   TextPageAttr_t PageAtrb[40 * 25];
398 } TextSubtitleCache_t;
399
400 /* main data structure */
401 typedef struct TextCacheStruct_t
402 {
403   int               CurrentPage[9];
404   int               CurrentSubPage[9];
405   TextExtData_t    *astP29[9];
406   TextCachedPage_t *astCachetable[0x900][0x80];
407   unsigned char     SubPageTable[0x900];
408   unsigned char     BasicTop[0x900];
409   short             FlofPages[0x900][FLOFSIZE];
410   char              ADIPTable[0x900][13];
411   int               ADIP_PgMax;
412   int               ADIP_Pg[10];
413   bool              BTTok;
414   int               CachedPages;
415   int               PageReceiving;
416   int               Page;
417   int               SubPage;
418   bool              PageUpdate;
419   int               NationalSubset;
420   int               NationalSubsetSecondary;
421   bool              ZapSubpageManual;
422   TextSubtitle_t    SubtitlePages[8];
423   unsigned char     TimeString[8];
424   int               vtxtpid;
425
426   /* cachetable for packets 29 (one for each magazine) */
427   /* cachetable */
428   unsigned char   FullRowColor[25];
429   unsigned char   FullScrColor;
430   unsigned char   tAPx, tAPy;              /* temporary offset to Active Position for objects */
431   short           pop, gpop, drcs, gdrcs;
432   unsigned short *ColorTable;
433
434   CStdString      line30;
435 } TextCacheStruct_t;
436
437 /* struct for all Information needed for Page Rendering */
438 typedef struct
439 {
440   bool PageCatching;
441   bool TranspMode;
442   bool HintMode;
443   bool ShowFlof;
444   bool Show39;
445   bool Showl25;
446   bool ShowHex;
447   int ZoomMode;
448
449   int InputCounter;
450   int ClearBBColor;
451   int Prev_100, Prev_10, Next_10, Next_100;
452   int Height;
453   int Width;
454   int FontHeight;
455   int FontWidth;
456   int FontWidth_Normal;
457   unsigned short rd0[TXT_Color_SIZECOLTABLE];
458   unsigned short gn0[TXT_Color_SIZECOLTABLE];
459   unsigned short bl0[TXT_Color_SIZECOLTABLE];
460   unsigned short tr0[TXT_Color_SIZECOLTABLE];
461   TextSubtitleCache_t *SubtitleCache[SUBTITLE_CACHESIZE];
462   unsigned char PageChar[25*40];
463   TextPageAttr_t PageAtrb[25*40];
464   TextPageinfo_t *PageInfo;
465   int PosX;
466   int PosY;
467   int nofirst;
468   unsigned char axdrcs[12+1+10+1];
469   int TTFShiftX, TTFShiftY; /* parameters for adapting to various TTF fonts */
470   bool Boxed;
471   int ScreenMode, PrevScreenMode;
472   bool DelayStarted;
473   unsigned int SubtitleDelay;
474 } TextRenderInfo_t;
475
476 class CDVDTeletextTools
477 {
478 public:
479   static void NextDec(int *i);
480   static void PrevDec(int *i);
481   static void Hex2Str(char *s, unsigned int n);
482   static signed int deh24(unsigned char *p);
483 };