MythTV  master
vbilut.cpp
Go to the documentation of this file.
1 #include "captions/vbilut.h"
2 
3 const std::array<const std::array<const uint8_t,16>,1+8+8> lang_chars
4 {{
5  { 0, 0x23,0x24,0x40,0x5b,0x5c,0x5d,0x5e,0x5f,0x60,0x7b,0x7c,0x7d,0x7e },
6 
7  // for latin-1 font
8  // English (100%)
9  { 0, 0xa3,0x24,0x40,0xab,0xbd,0xbb,0xac,0x23,0xad,0xbc,0xa6,0xbe,0xf7 }, // £$@«½»¬#­¼¦¾÷
10  // German (100%)
11  { 0, 0x23,0x24,0xa7,0xc4,0xd6,0xdc,0x5e,0x5f,0xb0,0xe4,0xf6,0xfc,0xdf }, // #$§ÄÖÜ^_°äöüß
12  // Swedish/Finnish/Hungarian (100%)
13  { 0, 0x23,0xa4,0xc9,0xc4,0xd6,0xc5,0xdc,0x5f,0xe9,0xe4,0xf6,0xe5,0xfc }, // #¤ÉÄÖÅÜ_éäöåü
14  // Italian (100%)
15  { 0, 0xa3,0x24,0xe9,0xb0,0xe7,0xbb,0xac,0x23,0xf9,0xe0,0xf2,0xe8,0xec }, // £$é°ç»¬#ùàòèì
16  // French (100%)
17  { 0, 0xe9,0xef,0xe0,0xeb,0xea,0xf9,0xee,0x23,0xe8,0xe2,0xf4,0xfb,0xe7 }, // éïàëêùî#èâôûç
18  // Portuguese/Spanish (100%)
19  { 0, 0xe7,0x24,0xa1,0xe1,0xe9,0xed,0xf3,0xfa,0xbf,0xfc,0xf1,0xe8,0xe0 }, // ç$¡áéíóú¿üñèà
20  // Czech/Slovak (60%)
21  { 0, 0x23,0x75,0x63,0x74,0x7a,0xfd,0xed,0x72,0xe9,0xe1,0x65,0xfa,0x73 }, // #uctzýíréáeús
22  // reserved (English mapping)
23  { 0, 0xa3,0x24,0x40,0xab,0xbd,0xbb,0xac,0x23,0xad,0xbc,0xa6,0xbe,0xf7 }, // £$@«½»¬#­¼¦¾÷
24 
25  // for latin-2 font
26  // Polish (100%)
27  { 0, 0x23,0xf1,0xb1,0xaf,0xa6,0xa3,0xe6,0xf3,0xea,0xbf,0xb6,0xb3,0xbc }, // #ñ±¯¦£æóê¿¶³¼
28  // German (100%)
29  { 0, 0x23,0x24,0xa7,0xc4,0xd6,0xdc,0x5e,0x5f,0xb0,0xe4,0xf6,0xfc,0xdf }, // #$§ÄÖÜ^_°äöüß
30  // Estonian (100%)
31  { 0, 0x23,0xf5,0xa9,0xc4,0xd6,0xae,0xdc,0xd5,0xb9,0xe4,0xf6,0xbe,0xfc }, // #õ©ÄÖ®ÜÕ¹äö¾ü
32  // Lettish/Lithuanian (90%)
33  { 0, 0x23,0x24,0xa9,0xeb,0xea,0xae,0xe8,0xfc,0xb9,0xb1,0x75,0xbe,0x69 }, // #$©ëê®èü¹±u¾i
34  // French (90%)
35  { 0, 0xe9,0x69,0x61,0xeb,0xec,0x75,0xee,0x23,0x65,0xe2,0xf4,0x75,0xe7 }, // éiaëìuî#eâôuç
36  // Serbian/Croation/Slovenian (100%)
37  { 0, 0x23,0xcb,0xc8,0xc6,0xae,0xd0,0xa9,0xeb,0xe8,0xe6,0xae,0xf0,0xb9 }, // #ËÈÆ®Ð©ëèæ®ð¹
38  // Czech/Slovak (100%)
39  { 0, 0x23,0xf9,0xe8,0xbb,0xbe,0xfd,0xed,0xf8,0xe9,0xe1,0xec,0xfa,0xb9 }, // #ù軾ýíøéáìú¹
40  // Rumanian (95%)
41  { 0, 0x23,0xa2,0xde,0xc2,0xaa,0xc3,0xce,0x69,0xfe,0xe2,0xba,0xe3,0xee }, // #¢ÞªÃÎiþâºãî
42 }};
43 
44 // TODO - Add the rest...page 107
45 const std::array<const uint8_t,13> chartab_original =
46 {
47  0x23,0xa4,0x40,0x5b,0x5c,0x5d,0x5e,0x5f,0x27,0x7b,0x7c,0x7d,0x7e // #¤@[\\]^_\'{|}~
48 };
49 
50 const std::array<const uint16_t,256> hammtab
51 {
52  0x0101, 0x100f, 0x0001, 0x0101, 0x100f, 0x0100, 0x0101, 0x100f,
53  0x100f, 0x0102, 0x0101, 0x100f, 0x010a, 0x100f, 0x100f, 0x0107,
54  0x100f, 0x0100, 0x0101, 0x100f, 0x0100, 0x0000, 0x100f, 0x0100,
55  0x0106, 0x100f, 0x100f, 0x010b, 0x100f, 0x0100, 0x0103, 0x100f,
56  0x100f, 0x010c, 0x0101, 0x100f, 0x0104, 0x100f, 0x100f, 0x0107,
57  0x0106, 0x100f, 0x100f, 0x0107, 0x100f, 0x0107, 0x0107, 0x0007,
58  0x0106, 0x100f, 0x100f, 0x0105, 0x100f, 0x0100, 0x010d, 0x100f,
59  0x0006, 0x0106, 0x0106, 0x100f, 0x0106, 0x100f, 0x100f, 0x0107,
60  0x100f, 0x0102, 0x0101, 0x100f, 0x0104, 0x100f, 0x100f, 0x0109,
61  0x0102, 0x0002, 0x100f, 0x0102, 0x100f, 0x0102, 0x0103, 0x100f,
62  0x0108, 0x100f, 0x100f, 0x0105, 0x100f, 0x0100, 0x0103, 0x100f,
63  0x100f, 0x0102, 0x0103, 0x100f, 0x0103, 0x100f, 0x0003, 0x0103,
64  0x0104, 0x100f, 0x100f, 0x0105, 0x0004, 0x0104, 0x0104, 0x100f,
65  0x100f, 0x0102, 0x010f, 0x100f, 0x0104, 0x100f, 0x100f, 0x0107,
66  0x100f, 0x0105, 0x0105, 0x0005, 0x0104, 0x100f, 0x100f, 0x0105,
67  0x0106, 0x100f, 0x100f, 0x0105, 0x100f, 0x010e, 0x0103, 0x100f,
68  0x100f, 0x010c, 0x0101, 0x100f, 0x010a, 0x100f, 0x100f, 0x0109,
69  0x010a, 0x100f, 0x100f, 0x010b, 0x000a, 0x010a, 0x010a, 0x100f,
70  0x0108, 0x100f, 0x100f, 0x010b, 0x100f, 0x0100, 0x010d, 0x100f,
71  0x100f, 0x010b, 0x010b, 0x000b, 0x010a, 0x100f, 0x100f, 0x010b,
72  0x010c, 0x000c, 0x100f, 0x010c, 0x100f, 0x010c, 0x010d, 0x100f,
73  0x100f, 0x010c, 0x010f, 0x100f, 0x010a, 0x100f, 0x100f, 0x0107,
74  0x100f, 0x010c, 0x010d, 0x100f, 0x010d, 0x100f, 0x000d, 0x010d,
75  0x0106, 0x100f, 0x100f, 0x010b, 0x100f, 0x010e, 0x010d, 0x100f,
76  0x0108, 0x100f, 0x100f, 0x0109, 0x100f, 0x0109, 0x0109, 0x0009,
77  0x100f, 0x0102, 0x010f, 0x100f, 0x010a, 0x100f, 0x100f, 0x0109,
78  0x0008, 0x0108, 0x0108, 0x100f, 0x0108, 0x100f, 0x100f, 0x0109,
79  0x0108, 0x100f, 0x100f, 0x010b, 0x100f, 0x010e, 0x0103, 0x100f,
80  0x100f, 0x010c, 0x010f, 0x100f, 0x0104, 0x100f, 0x100f, 0x0109,
81  0x010f, 0x100f, 0x000f, 0x010f, 0x100f, 0x010e, 0x010f, 0x100f,
82  0x0108, 0x100f, 0x100f, 0x0105, 0x100f, 0x010e, 0x010d, 0x100f,
83  0x100f, 0x010e, 0x010f, 0x100f, 0x010e, 0x000e, 0x100f, 0x010e,
84 };
85 
86 const std::array<const uint8_t,256> hamm84tab
87 {
88  255,255,255,255,255,255,255,255,255, 0, // 0 - 9
89  255, 8,255,255,255,255,255,255,255,255, // 10 - 19
90  255,255,255,255,255,255,255,255, 6,255, // 20 - 29
91  14,255,255,255,255,255, 12,255, 4,255, // 30 - 39
92  255,255,255,255,255,255,255,255,255, 10, // 40 - 49
93  255, 2,255,255,255,255,255,255,255,255, // 50 - 59
94  255,255,255,255, 1,255, 9,255,255,255, // 60 - 69
95  255,255,255,255,255,255,255,255,255,255, // 70 - 79
96  255,255,255,255,255, 7,255, 15,255,255, // 80 - 89
97  255,255,255,255,255,255,255,255,255,255, // 90 - 99
98  255,255,255,255,255,255,255,255,255, 13, // 100 - 109
99  255, 5,255,255,255,255,255,255,255,255, // 110 - 119
100  11,255, 3,255,255,255,255,255,255,255, // 120 - 129
101  255,255,255, 12,255, 4,255,255,255,255, // 130 - 139
102  255,255,255,255, 10,255, 2,255,255,255, // 140 - 149
103  255,255,255,255,255,255,255,255,255,255, // 150 - 159
104  255,255,255,255,255,255,255,255, 0,255, // 160 - 169
105  8,255,255,255,255,255,255,255,255,255, // 170 - 179
106  255,255,255,255,255,255,255,255,255, 6, // 180 - 189
107  255, 14,255,255,255,255,255,255,255,255, // 190 - 199
108  255,255,255,255, 13,255, 5,255,255,255, // 200 - 209
109  255,255,255,255,255,255,255, 11,255, 3, // 210 - 219
110  255,255,255,255,255, 1,255, 9,255,255, // 220 - 229
111  255,255,255,255,255,255,255,255,255,255, // 230 - 239
112  255,255,255,255, 7,255, 15,255,255,255, // 240 - 249
113  255,255,255,255,255,255 }; // 250 - 255
114 
115 
116 const std::array<const uint8_t,256> unham84tab
117 {
118  0x01, 0xff, 0x81, 0x01, 0xff, 0x00, 0x01, 0xff, // 0x
119  0xff, 0x02, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x07,
120  0xff, 0x00, 0x01, 0xff, 0x00, 0x80, 0xff, 0x00, // 1x
121  0x06, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x03, 0xff,
122  0xff, 0x0c, 0x01, 0xff, 0x04, 0xff, 0xff, 0x07, // 2x
123  0x06, 0xff, 0xff, 0x07, 0xff, 0x07, 0x07, 0x87,
124  0x06, 0xff, 0xff, 0x05, 0xff, 0x00, 0x0d, 0xff,
125  0x86, 0x06, 0x06, 0xff, 0x06, 0xff, 0xff, 0x07,
126  0xff, 0x02, 0x01, 0xff, 0x04, 0xff, 0xff, 0x09,
127  0x02, 0x82, 0xff, 0x02, 0xff, 0x02, 0x03, 0xff,
128  0x08, 0xff, 0xff, 0x05, 0xff, 0x00, 0x03, 0xff,
129  0xff, 0x02, 0x03, 0xff, 0x03, 0xff, 0x83, 0x03,
130  0x04, 0xff, 0xff, 0x05, 0x84, 0x04, 0x04, 0xff,
131  0xff, 0x02, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x07,
132  0xff, 0x05, 0x05, 0x85, 0x04, 0xff, 0xff, 0x05,
133  0x06, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x03, 0xff,
134  0xff, 0x0c, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x09,
135  0x0a, 0xff, 0xff, 0x0b, 0x8a, 0x0a, 0x0a, 0xff,
136  0x08, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x0d, 0xff,
137  0xff, 0x0b, 0x0b, 0x8b, 0x0a, 0xff, 0xff, 0x0b,
138  0x0c, 0x8c, 0xff, 0x0c, 0xff, 0x0c, 0x0d, 0xff,
139  0xff, 0x0c, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x07,
140  0xff, 0x0c, 0x0d, 0xff, 0x0d, 0xff, 0x8d, 0x0d,
141  0x06, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x0d, 0xff,
142  0x08, 0xff, 0xff, 0x09, 0xff, 0x09, 0x09, 0x89,
143  0xff, 0x02, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x09,
144  0x88, 0x08, 0x08, 0xff, 0x08, 0xff, 0xff, 0x09,
145  0x08, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x03, 0xff,
146  0xff, 0x0c, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x09,
147  0x0f, 0xff, 0x8f, 0x0f, 0xff, 0x0e, 0x0f, 0xff,
148  0x08, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x0d, 0xff,
149  0xff, 0x0e, 0x0f, 0xff, 0x0e, 0x8e, 0xff, 0x0e,
150 };
151 
152 const std::array<const uint8_t,256> vbi_bit_reverse
153 {
154  0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
155  0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
156  0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
157  0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
158  0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
159  0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
160  0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
161  0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
162  0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
163  0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
164  0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
165  0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
166  0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
167  0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
168  0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
169  0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
170  0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
171  0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
172  0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
173  0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
174  0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
175  0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
176  0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
177  0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
178  0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
179  0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
180  0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
181  0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
182  0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
183  0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
184  0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
185  0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
186 };
187 
188 const std::array<const std::string, 8> formats
189 {
190  "Full format 4:3, 576 lines",
191  "Letterbox 14:9 centre, 504 lines",
192  "Letterbox 14:9 top, 504 lines",
193  "Letterbox 16:9 centre, 430 lines",
194  "Letterbox 16:9 top, 430 lines",
195  "Letterbox > 16:9 centre",
196  "Full format 14:9 centre, 576 lines",
197  "Anamorphic 16:9, 576 lines"
198 };
199 
200 const std::array<const std::string,4> subtitles
201 {
202  "none",
203  "in active image area",
204  "out of active image area",
205  "?"
206 };
207 
212 const std::array<const std::array<const uint8_t,256>,3> hamm24par
213 {{
214  { // parities of first byte
215  0, 33, 34, 3, 35, 2, 1, 32, 36, 5, 6, 39, 7, 38, 37, 4,
216  37, 4, 7, 38, 6, 39, 36, 5, 1, 32, 35, 2, 34, 3, 0, 33,
217  38, 7, 4, 37, 5, 36, 39, 6, 2, 35, 32, 1, 33, 0, 3, 34,
218  3, 34, 33, 0, 32, 1, 2, 35, 39, 6, 5, 36, 4, 37, 38, 7,
219  39, 6, 5, 36, 4, 37, 38, 7, 3, 34, 33, 0, 32, 1, 2, 35,
220  2, 35, 32, 1, 33, 0, 3, 34, 38, 7, 4, 37, 5, 36, 39, 6,
221  1, 32, 35, 2, 34, 3, 0, 33, 37, 4, 7, 38, 6, 39, 36, 5,
222  36, 5, 6, 39, 7, 38, 37, 4, 0, 33, 34, 3, 35, 2, 1, 32,
223  40, 9, 10, 43, 11, 42, 41, 8, 12, 45, 46, 15, 47, 14, 13, 44,
224  13, 44, 47, 14, 46, 15, 12, 45, 41, 8, 11, 42, 10, 43, 40, 9,
225  14, 47, 44, 13, 45, 12, 15, 46, 42, 11, 8, 41, 9, 40, 43, 10,
226  43, 10, 9, 40, 8, 41, 42, 11, 15, 46, 45, 12, 44, 13, 14, 47,
227  15, 46, 45, 12, 44, 13, 14, 47, 43, 10, 9, 40, 8, 41, 42, 11,
228  42, 11, 8, 41, 9, 40, 43, 10, 14, 47, 44, 13, 45, 12, 15, 46,
229  41, 8, 11, 42, 10, 43, 40, 9, 13, 44, 47, 14, 46, 15, 12, 45,
230  12, 45, 46, 15, 47, 14, 13, 44, 40, 9, 10, 43, 11, 42, 41, 8
231  },
232  { // parities of second byte
233  0, 41, 42, 3, 43, 2, 1, 40, 44, 5, 6, 47, 7, 46, 45, 4,
234  45, 4, 7, 46, 6, 47, 44, 5, 1, 40, 43, 2, 42, 3, 0, 41,
235  46, 7, 4, 45, 5, 44, 47, 6, 2, 43, 40, 1, 41, 0, 3, 42,
236  3, 42, 41, 0, 40, 1, 2, 43, 47, 6, 5, 44, 4, 45, 46, 7,
237  47, 6, 5, 44, 4, 45, 46, 7, 3, 42, 41, 0, 40, 1, 2, 43,
238  2, 43, 40, 1, 41, 0, 3, 42, 46, 7, 4, 45, 5, 44, 47, 6,
239  1, 40, 43, 2, 42, 3, 0, 41, 45, 4, 7, 46, 6, 47, 44, 5,
240  44, 5, 6, 47, 7, 46, 45, 4, 0, 41, 42, 3, 43, 2, 1, 40,
241  48, 25, 26, 51, 27, 50, 49, 24, 28, 53, 54, 31, 55, 30, 29, 52,
242  29, 52, 55, 30, 54, 31, 28, 53, 49, 24, 27, 50, 26, 51, 48, 25,
243  30, 55, 52, 29, 53, 28, 31, 54, 50, 27, 24, 49, 25, 48, 51, 26,
244  51, 26, 25, 48, 24, 49, 50, 27, 31, 54, 53, 28, 52, 29, 30, 55,
245  31, 54, 53, 28, 52, 29, 30, 55, 51, 26, 25, 48, 24, 49, 50, 27,
246  50, 27, 24, 49, 25, 48, 51, 26, 30, 55, 52, 29, 53, 28, 31, 54,
247  49, 24, 27, 50, 26, 51, 48, 25, 29, 52, 55, 30, 54, 31, 28, 53,
248  28, 53, 54, 31, 55, 30, 29, 52, 48, 25, 26, 51, 27, 50, 49, 24
249  },
250  { // parities of third byte
251  63, 14, 13, 60, 12, 61, 62, 15, 11, 58, 57, 8, 56, 9, 10, 59,
252  10, 59, 56, 9, 57, 8, 11, 58, 62, 15, 12, 61, 13, 60, 63, 14,
253  9, 56, 59, 10, 58, 11, 8, 57, 61, 12, 15, 62, 14, 63, 60, 13,
254  60, 13, 14, 63, 15, 62, 61, 12, 8, 57, 58, 11, 59, 10, 9, 56,
255  8, 57, 58, 11, 59, 10, 9, 56, 60, 13, 14, 63, 15, 62, 61, 12,
256  61, 12, 15, 62, 14, 63, 60, 13, 9, 56, 59, 10, 58, 11, 8, 57,
257  62, 15, 12, 61, 13, 60, 63, 14, 10, 59, 56, 9, 57, 8, 11, 58,
258  11, 58, 57, 8, 56, 9, 10, 59, 63, 14, 13, 60, 12, 61, 62, 15,
259  31, 46, 45, 28, 44, 29, 30, 47, 43, 26, 25, 40, 24, 41, 42, 27,
260  42, 27, 24, 41, 25, 40, 43, 26, 30, 47, 44, 29, 45, 28, 31, 46,
261  41, 24, 27, 42, 26, 43, 40, 25, 29, 44, 47, 30, 46, 31, 28, 45,
262  28, 45, 46, 31, 47, 30, 29, 44, 40, 25, 26, 43, 27, 42, 41, 24,
263  40, 25, 26, 43, 27, 42, 41, 24, 28, 45, 46, 31, 47, 30, 29, 44,
264  29, 44, 47, 30, 46, 31, 28, 45, 41, 24, 27, 42, 26, 43, 40, 25,
265  30, 47, 44, 29, 45, 28, 31, 46, 42, 27, 24, 41, 25, 40, 43, 26,
266  43, 26, 25, 40, 24, 41, 42, 27, 31, 46, 45, 28, 44, 29, 30, 47
267  }
268 }};
269 
270 
272 const std::array<const uint8_t,256> hamm24val
273 {
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  0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1,
283  2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3,
284  4, 4, 4, 4, 5, 5, 5, 5, 4, 4, 4, 4, 5, 5, 5, 5,
285  6, 6, 6, 6, 7, 7, 7, 7, 6, 6, 6, 6, 7, 7, 7, 7,
286  8, 8, 8, 8, 9, 9, 9, 9, 8, 8, 8, 8, 9, 9, 9, 9,
287  10, 10, 10, 10, 11, 11, 11, 11, 10, 10, 10, 10, 11, 11, 11, 11,
288  12, 12, 12, 12, 13, 13, 13, 13, 12, 12, 12, 12, 13, 13, 13, 13,
289  14, 14, 14, 14, 15, 15, 15, 15, 14, 14, 14, 14, 15, 15, 15, 15
290 };
291 
292 
293 
298 const std::array<const uint16_t, 64> hamm24err
299 {
300  0x0000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
301  0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
302  0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
303  0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
304  0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
305  0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
306  0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
307  0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
308 };
309 
310 
314 const std::array<const int32_t, 64> hamm24cor
315 {
316  0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
317  0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
318  0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
319  0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
320  0x00000, 0x00000, 0x00000, 0x00001, 0x00000, 0x00002, 0x00004, 0x00008,
321  0x00000, 0x00010, 0x00020, 0x00040, 0x00080, 0x00100, 0x00200, 0x00400,
322  0x00000, 0x00800, 0x01000, 0x02000, 0x04000, 0x08000, 0x10000, 0x20000,
323  0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
324 };
325 
326 int hamm8(const uint8_t *p, int *err)
327 {
328  int a = hammtab[p[0]];
329  *err += a;
330  return a & 15;
331 }
332 
333 int hamm84(const uint8_t *p, int *err)
334 {
335  int a = hamm84tab[p[0]];
336 
337  if (a == 255)
338  *err = 1;
339 
340  return a;
341 }
342 
343 int hamm16(const uint8_t *p, int *err)
344 {
345  int a = hammtab[p[0]];
346  int b = hammtab[p[1]];
347  *err += a;
348  *err += b;
349  return (a & 15) | (b & 15) * 16;
350 }
351 
352 int hamm24(const uint8_t *p, int *err)
353 {
354  int e = hamm24par[0][p[0]] ^ hamm24par[1][p[1]] ^ hamm24par[2][p[2]];
355  int x = hamm24val[p[0]] + p[1] % 128 * 16 + p[2] % 128 * 2048;
356 
357  *err += hamm24err[e];
358  return x ^ hamm24cor[e];
359 }
hamm24par
const std::array< const std::array< const uint8_t, 256 >, 3 > hamm24par
This table generates the parity checks for hamm24/18 decoding.
Definition: vbilut.cpp:213
hamm84
int hamm84(const uint8_t *p, int *err)
Definition: vbilut.cpp:333
hamm24err
const std::array< const uint16_t, 64 > hamm24err
Mapping from parity checks made by table hamm24par to error results return by hamm24.
Definition: vbilut.cpp:299
lang_chars
const std::array< const std::array< const uint8_t, 16 >, 1+8+8 > lang_chars
Definition: vbilut.cpp:4
hamm84tab
const std::array< const uint8_t, 256 > hamm84tab
Definition: vbilut.cpp:87
vbi_bit_reverse
const std::array< const uint8_t, 256 > vbi_bit_reverse
Definition: vbilut.cpp:153
vbilut.h
hardwareprofile.config.p
p
Definition: config.py:33
formats
const std::array< const std::string, 8 > formats
Definition: vbilut.cpp:189
hammtab
const std::array< const uint16_t, 256 > hammtab
Definition: vbilut.cpp:51
hamm8
int hamm8(const uint8_t *p, int *err)
Definition: vbilut.cpp:326
hamm24val
const std::array< const uint8_t, 256 > hamm24val
Table to extract the lower 4 bit from hamm24/18 encoded bytes.
Definition: vbilut.cpp:273
hamm24cor
const std::array< const int32_t, 64 > hamm24cor
Mapping from parity checks made by table hamm24par to faulty bit in the decoded 18 bit word.
Definition: vbilut.cpp:315
subtitles
const std::array< const std::string, 4 > subtitles
Definition: vbilut.cpp:201
chartab_original
const std::array< const uint8_t, 13 > chartab_original
Definition: vbilut.cpp:45
unham84tab
const std::array< const uint8_t, 256 > unham84tab
Definition: vbilut.cpp:117
hamm16
int hamm16(const uint8_t *p, int *err)
Definition: vbilut.cpp:343
hamm24
int hamm24(const uint8_t *p, int *err)
Definition: vbilut.cpp:352