Mercurial > mplayer.hg
annotate stream/tvi_vbi.c @ 24278:2f47e955fa13
(cosmetics) replace tabs with spaces
author | voroshil |
---|---|
date | Wed, 29 Aug 2007 17:46:33 +0000 |
parents | 298578b37f21 |
children | 7265900f19d9 |
rev | line source |
---|---|
23899 | 1 /* |
2 * Teletext support | |
3 * Copyright (C) 2007 Vladimir Voroshilov <voroshil@gmail.com> | |
4 * | |
5 * This file is part of MPlayer. | |
6 * | |
7 * MPlayer 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 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * MPlayer 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 MPlayer; if not, write to the Free Software | |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
20 * | |
21 * | |
22 * Based on Attila Otvos' teletext patch, Michael Niedermayer's | |
23 * proof-of-concept teletext capture utility and some parts | |
24 * (decode_raw_line_runin,pll_add,pll_reset) of MythTV project. | |
24099 | 25 * Code for calculating [soc:eoc] is based on aletv of Edgar Toernig. |
23899 | 26 * |
24186 | 27 * Teletext system is described in |
28 * ETS 300 706 "Enhanced Teletext specification" : May 1997 | |
29 * http://www.themm.net/~mihu/linux/saa7146/specs/ets_300706e01p.pdf | |
23899 | 30 * |
31 * Some implementation details: | |
32 * How to port teletext to another tvi_* driver (see tvi_v4l2.c for example): | |
33 * | |
34 * 1. Implement TVI_CONTROL_VBI_INIT (initialize driver-related vbi subsystem, | |
35 * start grabbing thread) | |
36 * input data: vbi device name. | |
37 * (driver should also call TV_VBI_CONTROL_START for common vbi subsystem initialization | |
38 * with pointer to initialized tt_stream_properties structure. | |
39 * After ioctl call variable will contain pointer to initialized priv_vbi_t structure. | |
40 * | |
41 * 2. After receiving next chunk of raw vbi data call TV_VBI_CONTROL_DECODE_PAGE | |
42 * ioctl with pointer to data buffer | |
43 * 3. pass all other VBI related ioctl cmds to teletext_control routine | |
44 * | |
45 * Page displaying process consist of following stages: | |
46 * | |
47 * ---grabbing stage--- | |
48 * 0. stream/tvi_*.c: vbi_grabber(...) | |
49 * getting vbi data from video device | |
50 * ---decoding stage--- | |
51 * 1. stream/tvi_vbi.c: decode_raw_line_runin(...) or decode_raw_line_sine(...) | |
52 * decode raw vbi data into sliced 45(?) bytes long packets | |
53 * 2. stream/tvi_vbi.c: decode_pkt0(...), decode_pkt_page(...) | |
54 * packets processing (header analyzing, storing complete page in cache, | |
55 * only raw member of tt_char is filled at this stage) | |
56 * 3. stream/tvi_vbi.c: decode_page(...) | |
57 * page decoding. filling unicode,gfx,ctl,etc members of tt_char structure | |
58 * with appropriate values according to teletext control chars, converting | |
59 * text to utf8. | |
60 * ---rendering stage--- | |
61 * 4. stream/tvi_vbi.c: prepare_visible_page(...) | |
62 * processing page. adding number of just received by background process | |
63 * teletext page, adding current time,etc. | |
64 * 5. libvo/sub.c: vo_update_text_teletext(...) | |
65 * rendering displayable osd with text and graphics | |
66 * | |
67 * TODO: | |
68 * v4lv1,bktr support | |
69 * spu rendering | |
70 * is better quality on poor signal possible ? | |
71 * link support | |
72 * font autoscale | |
73 * greyscale osd | |
74 * slave command for dumping pages | |
75 * fix bcd<->dec as suggested my Michael | |
76 * | |
77 * BUGS: | |
78 * wrong colors in debug dump | |
79 * blinking when visible page was just updated | |
80 */ | |
81 | |
82 #include "config.h" | |
83 | |
84 #include <stdlib.h> | |
85 #include <string.h> | |
86 #include <unistd.h> | |
87 #include <errno.h> | |
88 #include <math.h> | |
89 #include <stdio.h> | |
90 | |
91 #include <pthread.h> | |
92 | |
93 #include "tv.h" | |
94 #include "mp_msg.h" | |
95 #include "help_mp.h" | |
96 #include "libmpcodecs/img_format.h" | |
97 #include "libavutil/common.h" | |
98 #include "input/input.h" | |
99 | |
100 //#define DEBUG_DUMP 1 | |
101 | |
102 /// page magazine entry structure | |
103 typedef struct mag_s{ | |
104 tt_page* pt; | |
105 int order; | |
106 int lang; | |
107 } mag_t; | |
108 | |
109 typedef struct { | |
110 int on; ///< teletext on/off | |
111 int pagenum; ///< seek page number | |
112 int subpagenum; ///< seek subpage | |
113 int curr_pagenum; ///< current page number | |
114 int pagenumdec; ///< set page num with dec | |
115 | |
116 teletext_format tformat; ///< see teletext_format enum | |
117 teletext_zoom zoom; ///< see teletext_zoom enum | |
118 mag_t* mag; ///< pages magazine (has 8 entities) | |
119 /// Currently displayed page (with additional info, e.g current time) | |
120 tt_char display_page[VBI_ROWS*VBI_COLUMNS]; | |
121 /// number of raw bytes between two subsequent encoded bits | |
122 int bpb; | |
123 /// clock run-in sequence will be searched in buffer in [soc:eoc] bytes range | |
124 int soc; | |
125 int eoc; | |
126 /// minimum number of raw vbi bytes wich can be decoded into 8 data bits | |
127 int bp8bl; | |
128 /// maximum number of raw vbi bytes wich can be decoded into 8 data bits | |
129 int bp8bh; | |
130 | |
131 int pll_adj; | |
132 int pll_dir; | |
133 int pll_cnt; | |
134 int pll_err; | |
135 int pll_lerr; | |
136 int pll_fixed; | |
137 /// vbi stream properties (buffer size,bytes per line, etc) | |
138 tt_stream_props* ptsp; | |
139 pthread_mutex_t buffer_mutex; | |
140 | |
141 tt_page** ptt_cache; | |
142 unsigned char* ptt_cache_first_subpage; | |
24232
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
143 /// network info |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
144 unsigned char initialpage; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
145 unsigned int initialsubpage; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
146 unsigned int networkid; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
147 int timeoffset; // timeoffset=realoffset*2 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
148 unsigned int juliandate; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
149 unsigned int universaltime; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
150 unsigned char networkname[21]; |
23899 | 151 } priv_vbi_t; |
152 | |
153 static unsigned char fixParity[256]; | |
154 | |
155 static tt_char tt_space={0x20,7,0,0,0,0,0x20}; | |
156 static tt_char tt_error={'?',1,0,0,0,0,'?'}; // Red '?' on black background | |
157 static double si[12]; | |
158 static double co[12]; | |
159 | |
160 #define VBI_FORMAT(priv) (*(priv->ptsp)) | |
161 | |
162 #define FIXP_SH 16 | |
163 #define ONE_FIXP (1<<FIXP_SH) | |
164 #define FIXP2INT(a) ((a)>>FIXP_SH) | |
165 #define ANY2FIXP(a) ((int)((a)*ONE_FIXP)) | |
166 | |
167 static const unsigned char corrHamm48[256]={ | |
168 0x01, 0xff, 0x01, 0x01, 0xff, 0x00, 0x01, 0xff, | |
169 0xff, 0x02, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x07, | |
170 0xff, 0x00, 0x01, 0xff, 0x00, 0x00, 0xff, 0x00, | |
171 0x06, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x03, 0xff, | |
172 0xff, 0x0c, 0x01, 0xff, 0x04, 0xff, 0xff, 0x07, | |
173 0x06, 0xff, 0xff, 0x07, 0xff, 0x07, 0x07, 0x07, | |
174 0x06, 0xff, 0xff, 0x05, 0xff, 0x00, 0x0d, 0xff, | |
175 0x06, 0x06, 0x06, 0xff, 0x06, 0xff, 0xff, 0x07, | |
176 0xff, 0x02, 0x01, 0xff, 0x04, 0xff, 0xff, 0x09, | |
177 0x02, 0x02, 0xff, 0x02, 0xff, 0x02, 0x03, 0xff, | |
178 0x08, 0xff, 0xff, 0x05, 0xff, 0x00, 0x03, 0xff, | |
179 0xff, 0x02, 0x03, 0xff, 0x03, 0xff, 0x03, 0x03, | |
180 0x04, 0xff, 0xff, 0x05, 0x04, 0x04, 0x04, 0xff, | |
181 0xff, 0x02, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x07, | |
182 0xff, 0x05, 0x05, 0x05, 0x04, 0xff, 0xff, 0x05, | |
183 0x06, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x03, 0xff, | |
184 0xff, 0x0c, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x09, | |
185 0x0a, 0xff, 0xff, 0x0b, 0x0a, 0x0a, 0x0a, 0xff, | |
186 0x08, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x0d, 0xff, | |
187 0xff, 0x0b, 0x0b, 0x0b, 0x0a, 0xff, 0xff, 0x0b, | |
188 0x0c, 0x0c, 0xff, 0x0c, 0xff, 0x0c, 0x0d, 0xff, | |
189 0xff, 0x0c, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x07, | |
190 0xff, 0x0c, 0x0d, 0xff, 0x0d, 0xff, 0x0d, 0x0d, | |
191 0x06, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x0d, 0xff, | |
192 0x08, 0xff, 0xff, 0x09, 0xff, 0x09, 0x09, 0x09, | |
193 0xff, 0x02, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x09, | |
194 0x08, 0x08, 0x08, 0xff, 0x08, 0xff, 0xff, 0x09, | |
195 0x08, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x03, 0xff, | |
196 0xff, 0x0c, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x09, | |
197 0x0f, 0xff, 0x0f, 0x0f, 0xff, 0x0e, 0x0f, 0xff, | |
198 0x08, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x0d, 0xff, | |
199 0xff, 0x0e, 0x0f, 0xff, 0x0e, 0x0e, 0xff, 0x0e }; | |
200 | |
201 | |
202 enum { | |
24271 | 203 LATIN=0, |
24256 | 204 CYRILLIC1, |
24271 | 205 CYRILLIC2, |
24255
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
206 CYRILLIC3, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
207 GREEK, |
23899 | 208 LANGS |
209 }; | |
210 | |
211 // conversion table for chars 0x20-0x7F (UTF8) | |
212 // TODO: add another languages | |
213 static unsigned int lang_chars[LANGS][0x60]={ | |
214 { | |
215 //Latin | |
216 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, | |
217 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, | |
218 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, | |
219 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, | |
220 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47, | |
221 0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, | |
222 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57, | |
223 0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, | |
224 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67, | |
225 0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f, | |
226 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77, | |
227 0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f | |
228 }, | |
229 { | |
24255
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
230 //Cyrillic-1 (Serbian/Croatian) |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
231 0x20,0x21,0x22,0x23,0x24,0x25,0x044b,0x27, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
232 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
233 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
234 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
235 0x0427,0x0410,0x0411,0x0426,0x0414,0x0415,0x0424,0x0413, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
236 0x0425,0x0418,0x0408,0x041a,0x041b,0x041c,0x041d,0x041e, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
237 0x041f,0x040c,0x0420,0x0421,0x0422,0x0423,0x0412,0x0403, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
238 0x0409,0x040a,0x0417,0x040b,0x0416,0x0402,0x0428,0x040f, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
239 0x0447,0x0430,0x0431,0x0446,0x0434,0x0435,0x0444,0x0433, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
240 0x0445,0x0438,0x0428,0x043a,0x043b,0x043c,0x043d,0x043e, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
241 0x043f,0x042c,0x0440,0x0441,0x0442,0x0443,0x0432,0x0423, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
242 0x0429,0x042a,0x0437,0x042b,0x0436,0x0422,0x0448,0x042f |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
243 }, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
244 { |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
245 //Cyrillic-2 (Russian/Bulgarian) |
23899 | 246 0x20,0x21,0x22,0x23,0x24,0x25,0x044b,0x27, |
247 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, | |
248 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, | |
249 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, | |
250 0x042e,0x0410,0x0411,0x0426,0x0414,0x0415,0x0424,0x0413, | |
251 0x0425,0x0418,0x0419,0x041a,0x041b,0x041c,0x041d,0x041e, | |
252 0x041f,0x042f,0x0420,0x0421,0x0422,0x0423,0x0416,0x0412, | |
253 0x042c,0x042a,0x0417,0x0428,0x042d,0x0429,0x0427,0x042b, | |
254 0x044e,0x0430,0x0431,0x0446,0x0434,0x0435,0x0444,0x0433, | |
255 0x0445,0x0438,0x0439,0x043a,0x043b,0x043c,0x043d,0x043e, | |
256 0x043f,0x044f,0x0440,0x0441,0x0442,0x0443,0x0436,0x0432, | |
257 0x044c,0x044a,0x0437,0x0448,0x044d,0x0449,0x0447,0x044b | |
24255
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
258 }, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
259 { |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
260 //Cyrillic-3 (Ukrainian) |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
261 0x20,0x21,0x22,0x23,0x24,0x25,0xef,0x27, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
262 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
263 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
264 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
265 0x042e,0x0410,0x0411,0x0426,0x0414,0x0415,0x0424,0x0413, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
266 0x0425,0x0418,0x0419,0x041a,0x041b,0x041c,0x041d,0x041e, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
267 0x041f,0x042f,0x0420,0x0421,0x0422,0x0423,0x0416,0x0412, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
268 0x042c,0x49,0x0417,0x0428,0x042d,0x0429,0x0427,0xcf, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
269 0x044e,0x0430,0x0431,0x0446,0x0434,0x0435,0x0444,0x0433, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
270 0x0445,0x0438,0x0439,0x043a,0x043b,0x043c,0x043d,0x043e, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
271 0x043f,0x044f,0x0440,0x0441,0x0442,0x0443,0x0436,0x0432, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
272 0x044c,0x69,0x0437,0x0448,0x044d,0x0449,0x0447,0xFF |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
273 }, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
274 { |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
275 //Greek |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
276 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
277 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
278 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
279 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
280 0x0390,0x0391,0x0392,0x0393,0x0394,0x0395,0x0396,0x0397, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
281 0x0398,0x0399,0x039a,0x039b,0x039c,0x039d,0x039e,0x039f, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
282 0x03a0,0x03a1,0x03a2,0x03a3,0x03a4,0x03a5,0x03a6,0x03a7, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
283 0x03a8,0x03a9,0x03aa,0x03ab,0x03ac,0x03ad,0x03ae,0x03af, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
284 0x03b0,0x03b1,0x03b2,0x03b3,0x03b4,0x03b5,0x03b6,0x03b7, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
285 0x03b8,0x03b9,0x03ba,0x03bb,0x03bc,0x03bd,0x03be,0x03bf, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
286 0x03c0,0x03c1,0x03c2,0x03c3,0x03c4,0x03c5,0x03c6,0x03c7, |
d6b310ab40c8
Conversion tables for Serbian/Croatian, Ukrainian and Greek charsets.
voroshil
parents:
24244
diff
changeset
|
287 0x03c8,0x03c9,0x03ca,0x03cb,0x03cc,0x03cd,0x03ce,0x03cf |
23899 | 288 } |
289 }; | |
290 | |
24184 | 291 /** |
292 * Latin National Option Sub-Sets | |
293 * see Table 36 of ETS specification for details. | |
294 * | |
295 * 00: £ $ @ « ½ » ¬ #  ¼ ¦ ¾ ÷ English | |
296 * 01: é ï à ë ê ù î # è â ô û ç French | |
297 * 02: # ¤ É Ä Ö Å Ü _ é ä ö å ü Swedish/Finnish/Hungarian | |
298 * 03: # u c t z ý à r é á e ú s Czech/Slovak | |
299 * 04: # $ § Ä Ö Ü ^ _ ° ä ö ü ß German | |
300 * 05: ç $ ¡ á é à ó ú ¿ ü ñ è à Portuguese/Spanish | |
301 * 06: £ $ é ° ç » ¬ # ù à ò è ì Italian | |
302 * | |
303 */ | |
304 static unsigned int latin_subchars[8][13]={ | |
305 // English | |
306 {0xa3,0x24,0x40,0xab,0xbd,0xbb,0xac,0x23,0xad,0xbc,0xa6,0xbe,0xf7}, | |
307 // French | |
308 {0xe9,0xef,0xe0,0xeb,0xea,0xf9,0xee,0x23,0xe8,0xe2,0xf4,0xfb,0xe7}, | |
309 // Swedish/Finnish/Hungarian | |
310 {0x23,0xa4,0xc9,0xc4,0xd6,0xc5,0xdc,0x5f,0xe9,0xe4,0xf6,0xe5,0xfc}, | |
311 // Czech/Slovak | |
312 {0x23,0x75,0x63,0x74,0x7a,0xfd,0xed,0x72,0xe9,0xe1,0x65,0xfa,0x73}, | |
313 // German | |
314 {0x23,0x24,0xa7,0xc4,0xd6,0xdc,0x5e,0x5f,0xb0,0xe4,0xf6,0xfc,0xdf}, | |
315 // Portuguese/Spanish | |
316 {0xe7,0x24,0xa1,0xe1,0xe9,0xed,0xf3,0xfa,0xbf,0xfc,0xf1,0xe8,0xe0}, | |
317 // Italian | |
318 {0xa3,0x24,0xe9,0xb0,0xe7,0xbb,0xac,0x23,0xf9,0xe0,0xf2,0xe8,0xec}, | |
319 // Reserved | |
320 {0x23,0x24,0x40,0x5b,0x5c,0x5d,0x5e,0x5f,0x60,0x7b,0x7c,0x7d,0x7e} | |
321 }; | |
322 | |
23899 | 323 static int lang2id (int lang){ |
24271 | 324 return LATIN; |
23899 | 325 } |
326 | |
327 /** | |
328 * \brief convert chars from curent teletext codepage into MPlayer charset | |
329 * \param p raw teletext char to decode | |
330 * \param lang teletext internal language code (see lang2id) | |
331 * \return UTF8 char | |
332 * | |
333 * \remarks | |
334 * routine will analyze raw member of given tt_char structure and | |
335 * fill unicode member of the same struct with appropriate utf8 code. | |
336 */ | |
337 static unsigned int conv2uni(unsigned int p,int lang) | |
338 { | |
24184 | 339 int charset=lang2id(lang); |
23899 | 340 if(p<0x80 && p>=0x20){ |
24271 | 341 if(charset==LATIN){ |
24184 | 342 if (p>=0x23 && p<=0x24){ |
343 return latin_subchars[lang][p-0x23]; | |
344 }else if (p==0x40){ | |
345 return latin_subchars[lang][2]; | |
346 }else if (p>=0x5b && p<=0x60){ | |
24190 | 347 return latin_subchars[lang][p-0x5b+3]; |
24184 | 348 }else if (p>=0x7b && p<=0x7e){ |
349 return latin_subchars[lang][p-0x7b+9]; | |
24278 | 350 } |
351 } | |
24184 | 352 return lang_chars[charset][p-0x20]; |
23899 | 353 }else |
354 return 0x20; | |
355 } | |
356 | |
357 static void init_vbi_consts(priv_vbi_t* priv){ | |
358 int i,j; | |
359 double ang; | |
360 for(i=0; i<256; i++){ | |
361 j=i&0x7F; | |
362 j^= j+j; | |
363 j^= j<<2; | |
364 j^= j<<4; | |
365 fixParity[i]= i ^ (j&0x80) ^ 0x80; | |
366 } | |
367 | |
368 for(i=0,ang=0; i<12; i++,ang+=M_PI/priv->bpb){ | |
369 si[i]= sin(ang); | |
370 co[i]= cos(ang); | |
371 } | |
372 | |
373 priv->bpb=(priv->ptsp->sampling_rate/6937500.0)*ONE_FIXP+0.5; | |
24099 | 374 priv->soc=FFMAX(9.2e-6*priv->ptsp->sampling_rate-priv->ptsp->offset, 0); |
375 priv->eoc=FFMIN(12.9e-6*priv->ptsp->sampling_rate-priv->ptsp->offset, | |
376 priv->ptsp->samples_per_line-43*8*priv->bpb/ONE_FIXP); | |
377 if (priv->eoc - priv->soc<16*priv->bpb/ONE_FIXP){ // invalid [soc:eoc] | |
378 priv->soc=0; | |
379 priv->eoc=92; | |
24197 | 380 } |
23899 | 381 priv->bp8bl=0.97*8*priv->bpb/ONE_FIXP; // -3% tolerance |
382 priv->bp8bh=1.03*8*priv->bpb/ONE_FIXP; // +3% tolerance | |
383 } | |
384 /** | |
385 * \brief calculate increased/decreased by given value page number | |
386 * \param curr current page number in hexadecimal for | |
387 * \param direction decimal value (can be negative) to add to value | |
388 * of curr parameter | |
389 * \return new page number in hexadecimal form | |
390 * | |
391 * VBI page numbers are represented in special hexadecimal form, e.g. | |
392 * page with number 123 (as seen by user) internally has number 0x123. | |
393 * and equation 0x123+8 should be equal to 0x131 instead of regular 0x12b. | |
394 * | |
395 * | |
396 * Page numbers 0xYYY (where Y is not belongs to (0..9). | |
397 * Page number belongs to [0x000,0x799] or [0x100:0x899] (first 0 can be | |
398 * treated as '8') | |
399 */ | |
400 static int steppage(int p, int direction, int skip_hidden) | |
401 { | |
402 if(skip_hidden) | |
403 p=(p&15)+((p>>4)&15)*10+(p>>8)*100; | |
404 p+=direction; | |
405 if(skip_hidden){ | |
406 p=(p+800)%800; | |
407 p=(p%10)+((p/10)%10)*16+(p/100)*256; | |
408 } | |
409 | |
410 return p&0x7ff; | |
411 } | |
412 | |
413 /* | |
414 ------------------------------------------------------------------ | |
415 Cache stuff | |
416 ------------------------------------------------------------------ | |
417 */ | |
418 | |
419 /** | |
420 * \brief add/update entry in cache | |
421 * \param priv private data structure | |
422 * \param pg page to store in cache | |
423 * \param line line to update (value below 0 means update entire page) | |
424 */ | |
425 static void put_to_cache(priv_vbi_t* priv,tt_page* pg,int line){ | |
426 tt_page* pgc; //page in cache | |
24244 | 427 int i,j,count; |
23899 | 428 |
429 if(line<0){ | |
430 i=0; | |
24278 | 431 count=VBI_ROWS*VBI_COLUMNS; |
23899 | 432 }else if(line<VBI_ROWS){ |
433 i=line*VBI_COLUMNS; | |
434 count=(line+1)*VBI_COLUMNS; | |
435 }else | |
436 return; | |
437 | |
438 pthread_mutex_lock(&(priv->buffer_mutex)); | |
439 | |
440 if(!priv->ptt_cache[pg->pagenum]){ | |
441 priv->ptt_cache[pg->pagenum]=calloc(1,sizeof(tt_page)); | |
442 pgc=priv->ptt_cache[pg->pagenum]; | |
443 }else{ | |
444 pgc=priv->ptt_cache[pg->pagenum]; | |
445 while(pgc->next_subpage && pgc->subpagenum!=pg->subpagenum) | |
446 pgc=pgc->next_subpage; | |
447 | |
448 if(pgc->subpagenum!=pg->subpagenum){ | |
449 pgc->next_subpage=calloc(1,sizeof(tt_page)); | |
450 pgc=pgc->next_subpage; | |
451 } | |
452 } | |
453 pgc->pagenum=pg->pagenum; | |
454 pgc->subpagenum=pg->subpagenum; | |
455 pgc->lang=pg->lang; | |
456 pgc->flags=pg->flags; | |
24244 | 457 for(j=0;j<6;++j) |
458 pgc->links[j]=pg->links[j]; | |
23899 | 459 //instead of copying entire page into cache, copy only undamaged |
460 //symbols into cache | |
461 for(;i<count;i++){ | |
462 if(!(pg->raw[i]&0x80)) | |
463 pgc->raw[i]=pg->raw[i]; | |
464 else | |
465 mp_msg(MSGT_TV,MSGL_DBG3,"char error. pg:%x, c[%d]=0x%x\n", | |
466 pg->pagenum,i,pg->raw[i]); | |
467 } | |
468 pgc->active=1; | |
469 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
470 } | |
471 | |
472 /** | |
473 * \brief get any subpage number of given page | |
474 * \param priv private data structure | |
475 * \param pagenum page number to search subpages in | |
476 * | |
477 * \return subpage number of first found subpage which belongs to | |
478 * given page number | |
479 * | |
480 * \note page itself is subpage too (and usually has subpage number 0) | |
481 */ | |
482 static inline int get_subpagenum_from_cache(priv_vbi_t* priv, int pagenum){ | |
483 if (!priv->ptt_cache[pagenum]) | |
484 return -1; | |
485 else | |
486 return priv->ptt_cache[pagenum]->subpagenum; | |
487 } | |
488 | |
489 /** | |
490 * \brief get page from cache by it page and subpage number | |
491 * \param priv private data structure | |
492 * \param pagenum page number | |
493 * \param subpagenum subpage number | |
494 * | |
495 * \return pointer to tt_page structure if requested page is found | |
496 * and NULL otherwise | |
497 */ | |
498 static inline tt_page* get_from_cache(priv_vbi_t* priv, int pagenum,int subpagenum){ | |
499 tt_page* tp=priv->ptt_cache[pagenum]; | |
500 | |
501 while(tp && tp->subpagenum!=subpagenum) | |
502 tp=tp->next_subpage; | |
503 return tp; | |
504 } | |
505 | |
506 /** | |
507 * \brief clears cache | |
508 * \param priv private data structure | |
509 * | |
510 * Deletes all tt_page structures from cache and frees allocated memory. | |
511 * Only zero-filled array of pointers remains in memory | |
512 */ | |
513 static void clear_cache(priv_vbi_t* priv){ | |
514 int i; | |
515 tt_page* tp; | |
516 for(i=0;i<VBI_MAX_PAGES;i++){ | |
517 while(priv->ptt_cache[i]){ | |
518 tp=priv->ptt_cache[i]; | |
519 priv->ptt_cache[i]=tp->next_subpage; | |
520 free(tp); | |
521 } | |
522 } | |
24232
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
523 priv->initialsubpage=priv->networkid=0; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
524 priv->timeoffset=0; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
525 priv->juliandate=priv->universaltime=0; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
526 memset(priv->networkname,0,21); |
23899 | 527 } |
528 | |
529 /** | |
530 * \brief cache initialization | |
531 * \param priv private data structure | |
532 * | |
533 * \note Has to be called before any cache operations! | |
534 */ | |
535 static void init_cache(priv_vbi_t* priv){ | |
536 priv->ptt_cache=calloc(VBI_MAX_PAGES,sizeof(tt_page*)); | |
537 } | |
538 | |
539 /** | |
540 * \brief destroys cache | |
541 * \param priv private data structure | |
542 * | |
543 * Frees all memory allocated for cache (including array of pointers). | |
544 * It is safe to call this routine multiple times | |
545 */ | |
546 static void destroy_cache(priv_vbi_t* priv){ | |
547 if(priv->ptt_cache){ | |
548 clear_cache(priv); | |
549 free(priv->ptt_cache); | |
550 priv->ptt_cache=NULL; | |
551 } | |
552 } | |
553 | |
554 /* | |
555 ------------------------------------------------------------------ | |
556 Decoder stuff | |
557 ------------------------------------------------------------------ | |
558 */ | |
559 /** | |
560 * \brief converts raw teletext page into useful format (1st rendering stage) | |
561 * \param pg page to decode | |
562 * | |
563 * Routine fills tt_char structure of each teletext_page character with proper | |
564 * info about foreground and background colors, character | |
565 * type (graphics/control/text). | |
566 */ | |
567 static void decode_page(tt_char* p,int lang,unsigned char* raw) | |
568 { | |
569 int c,gfx=0,lat=0; | |
570 int i=0; | |
571 int fg_color=0; | |
572 int bg_color=0; | |
573 int row,col; | |
574 int separated=0; | |
24275
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
575 int conceal; |
24276
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
576 int hold; |
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
577 tt_char tt_held; |
23899 | 578 |
579 for(row=0;row<VBI_ROWS;row++) { | |
580 lat=(lang==0); | |
581 gfx=0; | |
582 fg_color=7; | |
583 bg_color=0; | |
584 separated=0; | |
24275
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
585 conceal=0; |
24276
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
586 hold=0; |
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
587 tt_held=tt_space; |
23899 | 588 for(col=0;col<VBI_COLUMNS;col++){ |
589 i=row*VBI_COLUMNS+col; | |
590 c=raw[i]; | |
591 p[i].raw=c; | |
592 if(c&0x80){ //damaged char | |
593 p[i]=tt_error; | |
594 continue; | |
595 } | |
596 p[i].gfx=gfx?(separated?2:1):0; | |
597 p[i].lng=lat?0:lang; | |
598 p[i].ctl=(c&0x60)==0?1:0; | |
599 p[i].fg=fg_color; | |
600 p[i].bg=bg_color; | |
24275
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
601 |
23899 | 602 if ((c&0x60)==0){ //control chars |
24275
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
603 if(c>=0x08 && c<=0x09){//Flash/Steady |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
604 int tmp; |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
605 tmp=bg_color; |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
606 bg_color=fg_color; |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
607 fg_color=tmp; |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
608 if(c==0x09){ |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
609 p[i].fg=fg_color; |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
610 p[i].bg=bg_color; |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
611 } |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
612 }else if(c>=0x0a && c<=0x0f){ |
23899 | 613 }else if (c<=0x17){ //colors |
614 fg_color=c&0x0f; | |
615 gfx=c>>4; | |
24275
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
616 conceal=0; |
24276
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
617 if(!gfx) hold=0; |
23899 | 618 }else if (c<=0x18){ |
24275
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
619 conceal=1; |
23899 | 620 }else if (c<=0x1a){ //Contiguous/Separated gfx |
621 separated=!(c&1); | |
622 }else if (c<=0x1b){ | |
623 lat=!lat; | |
624 }else if (c<=0x1d){ | |
625 bg_color=(c&1)?fg_color:0; | |
626 p[i].bg=bg_color; | |
24276
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
627 }else{ //Hold/Release Graphics |
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
628 hold=!(c&1); |
23899 | 629 } |
630 p[i].ctl=1; | |
24276
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
631 if(hold || c==0x1f){ |
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
632 p[i]=tt_held; |
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
633 p[i].fg=fg_color; |
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
634 p[i].bg=bg_color; |
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
635 }else |
24277 | 636 p[i].unicode=p[i].gfx?0:' '; |
23899 | 637 continue; |
638 } | |
639 | |
24275
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
640 if(conceal){ |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
641 p[i].gfx=0; |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
642 p[i].unicode=' '; |
a12f357e8bd0
Implement Flash/Steady (swapping foreground/background colors)
voroshil
parents:
24271
diff
changeset
|
643 }else if(gfx){ |
23899 | 644 p[i].unicode=c-0x20; |
645 if (p[i].unicode>0x3f) p[i].unicode-=0x20; | |
24276
e8b635a55781
Implement Hold/Release graphics (showing control chars as
voroshil
parents:
24275
diff
changeset
|
646 tt_held=p[i]; |
23899 | 647 }else |
24184 | 648 p[i].unicode=conv2uni(c,p[i].lng); |
23899 | 649 |
650 p[i].fg=fg_color; | |
651 p[i].bg=bg_color; | |
652 } | |
653 } | |
654 } | |
655 | |
656 /** | |
657 * \brief prepares current page for displaying | |
658 * \param priv_vbi private data structure | |
659 * | |
660 * Routine adds some useful info (time and page number of page, grabbed by | |
661 * background thread to top line of current page). Displays "No teletext" | |
662 * string if no vbi data available. | |
663 */ | |
23908 | 664 #define PRINT_HEX(dp,i,h) dp[i].unicode=((h)&0xf)>9?'A'+((h)&0xf)-10:'0'+((h)&0xf) |
23899 | 665 static void prepare_visible_page(priv_vbi_t* priv){ |
666 tt_page *pg,*curr_pg; | |
667 unsigned char *p; | |
668 int i; | |
669 | |
670 pthread_mutex_lock(&(priv->buffer_mutex)); | |
671 mp_msg(MSGT_TV,MSGL_DBG3,"tvi_vbi: prepare_visible_page pg:0x%x, sub:0x%x\n", | |
672 priv->pagenum,priv->subpagenum); | |
673 if(priv->subpagenum==-1) //no page yet | |
674 priv->subpagenum=get_subpagenum_from_cache(priv,priv->pagenum); | |
675 | |
676 pg=get_from_cache(priv,priv->pagenum,priv->subpagenum); | |
677 mp_dbg(MSGT_TV,MSGL_DBG3,"tvi_vbi: prepare_vibible_page2 pg:0x%x, sub:0x%x\n", | |
678 priv->pagenum,priv->subpagenum); | |
679 | |
680 curr_pg=get_from_cache(priv,priv->curr_pagenum, | |
681 get_subpagenum_from_cache(priv,priv->curr_pagenum)); | |
682 if (!pg && !curr_pg){ | |
683 p=MSGTR_TV_NoTeletext; | |
684 for(i=0;i<VBI_COLUMNS && *p;i++){ | |
685 GET_UTF8(priv->display_page[i].unicode,*p++,break;); | |
686 } | |
687 for(;i<VBI_ROWS*VBI_COLUMNS;i++) | |
688 priv->display_page[i]=tt_space; | |
689 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
690 return; | |
691 } | |
692 | |
693 if (!pg || !pg->active){ | |
694 for(i=0;i<VBI_ROWS*VBI_COLUMNS;i++){ | |
695 priv->display_page[i]=tt_space; | |
696 } | |
697 }else{ | |
698 decode_page(priv->display_page,pg->lang,pg->raw); | |
699 mp_msg(MSGT_TV,MSGL_DBG3,"page #%x was decoded!\n",pg->pagenum); | |
700 } | |
701 | |
702 PRINT_HEX(priv->display_page,0,(priv->curr_pagenum&0x700)?priv->curr_pagenum>>8:8); | |
703 PRINT_HEX(priv->display_page,1,priv->curr_pagenum>>4); | |
704 PRINT_HEX(priv->display_page,2,priv->curr_pagenum); | |
705 priv->display_page[3].unicode=' '; | |
706 priv->display_page[4].unicode=' '; | |
707 switch(priv->pagenumdec>>12){ | |
708 case 1: | |
709 priv->display_page[5].unicode='_'; | |
710 priv->display_page[6].unicode='_'; | |
711 PRINT_HEX(priv->display_page,7,priv->pagenumdec); | |
712 break; | |
713 case 2: | |
714 priv->display_page[5].unicode='_'; | |
715 PRINT_HEX(priv->display_page,6,priv->pagenumdec>>4); | |
716 PRINT_HEX(priv->display_page,7,priv->pagenumdec); | |
717 break; | |
718 default: | |
719 PRINT_HEX(priv->display_page,5,(priv->pagenum&0x700)?priv->pagenum>>8:8); | |
720 PRINT_HEX(priv->display_page,6,priv->pagenum>>4); | |
721 PRINT_HEX(priv->display_page,7,priv->pagenum); | |
722 } | |
723 if(priv->subpagenum!=-1){ | |
724 priv->display_page[8].unicode='.'; | |
725 PRINT_HEX(priv->display_page,9,priv->subpagenum>>4); | |
726 PRINT_HEX(priv->display_page,10,priv->subpagenum); | |
727 }else{ | |
728 priv->display_page[8].unicode=' '; | |
729 priv->display_page[9].unicode=' '; | |
730 priv->display_page[10].unicode=' '; | |
731 } | |
732 priv->display_page[11].unicode=' '; | |
733 for(i=VBI_TIME_LINEPOS;i<VBI_COLUMNS;i++){ | |
734 priv->display_page[i].unicode=curr_pg->raw[i]; | |
735 } | |
736 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
737 } | |
738 /* | |
739 ------------------------------------------------------------------ | |
740 Renderer stuff | |
741 ------------------------------------------------------------------ | |
742 */ | |
743 #ifdef DEBUG_DUMP | |
744 /** | |
745 * \brief renders teletext page into given file | |
746 * \param pt page to render | |
747 * \param f opened file descriptor | |
748 * \param pagenum which page to render | |
749 * \param colored use colors not implementede yet) | |
750 * | |
751 * Text will be UTF8 encoded | |
752 */ | |
753 static void render2text(tt_page* pt,FILE* f,int colored){ | |
754 int i,j; | |
755 unsigned int u; | |
756 unsigned char buf[8]; | |
757 unsigned char tmp; | |
758 int pos; | |
759 tt_char dp[VBI_ROWS*VBI_COLUMNS]; | |
760 int color=0; | |
761 int bkg=0; | |
762 int c1,b1; | |
763 if(!pt) | |
764 return; | |
765 fprintf(f,"+========================================+\n"); | |
766 fprintf(f,"| lang:%d pagenum:0x%x subpagenum:%d flags:0x%x|\n", | |
767 pt->lang, | |
768 pt->pagenum, | |
769 pt->subpagenum, | |
770 0); | |
771 fprintf(f,"+----------------------------------------+\n"); | |
772 | |
773 decode_page(dp,pt->lang,pt->raw); | |
774 for(i=0;i<VBI_ROWS;i++){ | |
775 fprintf(f,"|"); | |
776 if(colored) fprintf(f,"\033[40m"); | |
777 for(j=0;j<VBI_COLUMNS;j++) | |
778 { | |
779 u=dp[i*VBI_COLUMNS+j].unicode; | |
23928 | 780 if(dp[i*VBI_COLUMNS+j].fg <= 7) |
23899 | 781 c1=30+dp[i*VBI_COLUMNS+j].fg; |
23928 | 782 else |
23899 | 783 c1=38; |
23928 | 784 if(dp[i*VBI_COLUMNS+j].bg <= 7) |
23899 | 785 b1=40+dp[i*VBI_COLUMNS+j].bg; |
23928 | 786 else |
23899 | 787 b1=40; |
788 if (b1!=bkg && colored){ | |
789 fprintf(f,"\033[%dm",b1); | |
790 bkg=b1; | |
791 } | |
792 if(c1!=color && colored){ | |
793 fprintf(f,"\033[%dm",c1); | |
794 color=c1; | |
795 } | |
796 if(dp[i*VBI_COLUMNS+j].gfx){ | |
797 fprintf(f,"*"); | |
798 }else{ | |
799 pos=0; | |
800 PUT_UTF8(u,tmp,if(pos<7) buf[pos++]=tmp;); | |
801 buf[pos]='\0'; | |
802 fprintf(f,"%s",buf); | |
803 } | |
804 } | |
805 | |
806 if (colored) fprintf(f,"\033[0m"); | |
807 color=-1;bkg=-1; | |
808 fprintf(f,"|\n"); | |
809 } | |
810 #if 1 | |
811 //for debug | |
812 fprintf(f,"+====================raw=================+\n"); | |
813 for(i=0;i<VBI_ROWS;i++){ | |
814 for(j=0;j<VBI_COLUMNS;j++) | |
815 fprintf(f,"%02x ",dp[i*VBI_COLUMNS+j].raw); | |
816 fprintf(f,"\n"); | |
817 } | |
818 fprintf(f,"+====================lng=================+\n"); | |
819 for(i=0;i<VBI_ROWS;i++){ | |
820 for(j=0;j<VBI_COLUMNS;j++) | |
821 fprintf(f,"%02x ",dp[i*VBI_COLUMNS+j].lng); | |
822 fprintf(f,"\n"); | |
823 } | |
824 #endif | |
825 fprintf(f,"+========================================+\n"); | |
826 } | |
827 | |
828 /** | |
829 * \brief dump page into pgXXX.txt file in vurrent directory | |
830 * \param pt page to dump | |
831 * | |
832 * \note XXX in filename is page number | |
833 * \note use only for debug purposes | |
834 */ | |
835 static void dump_page(tt_page* pt) | |
836 { | |
837 FILE*f; | |
838 char name[100]; | |
839 snprintf(name,99,"pg%x.txt",pt->pagenum); | |
840 f=fopen(name,"wb"); | |
841 render2text(pt,f,1); | |
842 fclose(f); | |
843 } | |
844 #endif //DEBUG_DUMP | |
845 | |
846 | |
847 /** | |
848 * \brief checks whether page is ready and copies it into cache array if so | |
849 * \param priv private data structure | |
850 * \param magAddr page's magazine address (0-7) | |
851 * | |
852 * Routine also calls decode_page to perform 1st stage of rendering | |
853 */ | |
854 static void store_in_cache(priv_vbi_t* priv, int magAddr, int line){ | |
855 mp_msg(MSGT_TV,MSGL_DBG2,"store_in_cache(%d): pagenum:%x\n", | |
856 priv->mag[magAddr].order, | |
857 priv->mag[magAddr].pt->pagenum); | |
858 | |
859 put_to_cache(priv,priv->mag[magAddr].pt,line); | |
860 priv->curr_pagenum=priv->mag[magAddr].pt->pagenum; | |
861 | |
862 #ifdef DEBUG_DUMP | |
863 dump_page(get_from_cache(priv, | |
864 priv->mag[magAddr].pt->pagenum, | |
865 priv->mag[magAddr].pt->subpagenum)); | |
866 #endif | |
867 } | |
868 | |
869 | |
870 /* | |
871 ------------------------------------------------------------------ | |
872 Grabber stuff | |
873 ------------------------------------------------------------------ | |
874 */ | |
875 #define PLL_SAMPLES 4 | |
876 #define PLL_ERROR 4 | |
877 #define PLL_ADJUST 4 | |
878 | |
879 /** | |
880 * \brief adjust current phase for better signal decoding | |
881 * \param n count of bytes processed (?) | |
882 * \param err count of error bytes (?) | |
883 * | |
884 * \remarks code was got from MythTV project | |
885 */ | |
886 static void pll_add(priv_vbi_t* priv,int n,int err){ | |
887 if(priv->pll_fixed) | |
888 return; | |
889 if(err>PLL_ERROR*2/3) | |
890 err=PLL_ERROR*2/3; | |
891 priv->pll_err+=err; | |
892 priv->pll_cnt+=n; | |
893 if(priv->pll_cnt<PLL_SAMPLES) | |
894 return; | |
895 if(priv->pll_err>PLL_ERROR) | |
896 { | |
897 if(priv->pll_err>priv->pll_lerr) | |
898 priv->pll_dir= -priv->pll_dir; | |
899 priv->pll_lerr=priv->pll_err; | |
900 priv->pll_adj+=priv->pll_dir; | |
901 if (priv->pll_adj<-PLL_ADJUST || priv->pll_adj>PLL_ADJUST) | |
902 { | |
903 priv->pll_adj=0; | |
904 priv->pll_dir=-1; | |
905 priv->pll_lerr=0; | |
906 } | |
907 mp_msg(MSGT_TV,MSGL_DBG3,"vbi: pll_adj=%2d\n",priv->pll_adj); | |
908 } | |
909 priv->pll_cnt=0; | |
910 priv->pll_err=0; | |
911 } | |
912 | |
913 /** | |
914 * \brief reset error correction | |
915 * \param priv private data structure | |
916 * \param fine_tune shift value for adjusting | |
917 * | |
918 * \remarks code was got from MythTV project | |
919 */ | |
920 static void pll_reset(priv_vbi_t* priv,int fine_tune){ | |
921 priv->pll_fixed=fine_tune >= -PLL_ADJUST && fine_tune <= PLL_ADJUST; | |
922 | |
923 priv->pll_err=0; | |
924 priv->pll_lerr=0; | |
925 priv->pll_cnt=0; | |
926 priv->pll_dir=-1; | |
927 priv->pll_adj=0; | |
928 if(priv->pll_fixed) | |
929 priv->pll_adj=fine_tune; | |
930 if(priv->pll_fixed) | |
931 mp_msg(MSGT_TV,MSGL_DBG3,"pll_reset (fixed@%2d)\n",priv->pll_adj); | |
932 else | |
933 mp_msg(MSGT_TV,MSGL_DBG3,"pll_reset (auto)\n"); | |
934 | |
935 } | |
936 /** | |
937 * \brief decode packet 0 (teletext page header) | |
938 * \param priv private data structure | |
939 * \param data raw teletext data (with not applied hamm correction yet) | |
940 * \param magAddr teletext page's magazine address | |
941 * | |
942 * \remarks | |
943 * data buffer was shifted by 6 and now contains: | |
944 * 0..1 page number | |
945 * 2..5 sub-code | |
946 * 6..7 control codes | |
947 * 8..39 display data | |
948 * | |
949 * only first 8 bytes protected by Hamm 8/4 code | |
950 */ | |
951 static int decode_pkt0(priv_vbi_t* priv,unsigned char* data,int magAddr) | |
952 { | |
953 int d[8]; | |
954 int i,err; | |
955 | |
956 if (magAddr<0 || magAddr>7) | |
957 return 0; | |
958 for(i=0;i<8;i++){ | |
959 d[i]= corrHamm48[ data[i] ]; | |
960 if(d[i]&0x80){ | |
961 pll_add(priv,2,4); | |
962 | |
963 if(priv->mag[magAddr].pt) | |
964 free(priv->mag[magAddr].pt); | |
965 priv->mag[magAddr].pt=NULL; | |
966 priv->mag[magAddr].order=0; | |
967 return 0; | |
968 } | |
969 } | |
970 if (!priv->mag[magAddr].pt) | |
971 priv->mag[magAddr].pt= malloc(sizeof(tt_page)); | |
972 | |
24169 | 973 priv->mag[magAddr].lang=(d[7]>>1)&0x7; |
23899 | 974 priv->mag[magAddr].pt->lang=priv->mag[magAddr].lang; |
975 priv->mag[magAddr].pt->subpagenum=(d[2]|(d[3]<<4)|(d[4]<<8)|(d[5]<<12))&0x3f7f; | |
976 priv->mag[magAddr].pt->pagenum=(magAddr<<8) | d[0] | (d[1]<<4); | |
977 priv->mag[magAddr].pt->flags=( d[6] | (d[7]<<4)); | |
978 | |
979 memset(priv->mag[magAddr].pt->raw, 0x00, VBI_COLUMNS*VBI_ROWS); | |
980 priv->mag[magAddr].order=0; | |
981 | |
982 for(i=0;i<8;i++){ | |
983 priv->mag[magAddr].pt->raw[i]=0x20; | |
984 } | |
985 err=0; | |
986 for(i=8; i<VBI_COLUMNS; i++){ | |
987 data[i]= fixParity[data[i]]; | |
988 priv->mag[magAddr].pt->raw[i]=data[i]; | |
989 if(data[i]&0x80) //Error | |
990 err++; | |
991 pll_add(priv,1,err); | |
992 } | |
993 | |
994 store_in_cache(priv,magAddr,0); | |
995 | |
996 return 1; | |
997 } | |
998 | |
999 /** | |
24232
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1000 * \brief decode teletext 8/30 Format 1 packet |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1001 * \param priv private data structure |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1002 * \param data raw teletext data (with not applied hamm correction yet) |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1003 * \param magAddr teletext page's magazine address |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1004 * |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1005 * \remarks |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1006 * packet contains: |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1007 * 0 designation code |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1008 * 1..2 initial page |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1009 * 3..6 initial subpage & magazine address |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1010 * 7..8 network id |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1011 * 9 time offset |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1012 * 10..12 julian date |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1013 * 13..15 universal time |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1014 * 20..40 network name |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1015 * |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1016 * First 7 bytes are protected by Hamm 8/4 code. |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1017 * Bytes 20-40 has odd parity check. |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1018 * |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1019 * See subcaluse 9.8.1 of specification for details |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1020 */ |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1021 static int decode_pkt30(priv_vbi_t* priv,unsigned char* data,int magAddr) |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1022 { |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1023 int d[8]; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1024 int i,err; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1025 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1026 for(i=0;i<7;i++){ |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1027 d[i]= corrHamm48[ data[i] ]; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1028 if(d[i]&0x80){ |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1029 pll_add(priv,2,4); |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1030 return 0; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1031 } |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1032 d[i]&=0xf; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1033 } |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1034 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1035 err=0; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1036 for(i=20; i<40; i++){ |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1037 data[i]= fixParity[data[i]]; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1038 if(data[i]&0x80)//Unrecoverable error |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1039 err++; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1040 pll_add(priv,1,err); |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1041 } |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1042 if (err) return 0; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1043 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1044 if (d[0]&0xe) //This is not 8/30 Format 1 packet |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1045 return 1; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1046 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1047 priv->initialpage=d[1] | d[2]<<4 | (d[6]&0xc)<<7 | (d[4]&1)<<8; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1048 priv->initialsubpage=d[3] | d[4]<<4 | d[5]<<8 | d[6]<<12; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1049 priv->networkid=data[7]<<8 | data[8]; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1050 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1051 priv->timeoffset=(data[9]>>1)&0xf; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1052 if(data[9]&0x40) |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1053 priv->timeoffset=-priv->timeoffset; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1054 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1055 priv->juliandate=(data[10]&0xf)<<16 | data[11]<<8 | data[12]; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1056 priv->juliandate-=0x11111; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1057 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1058 priv->universaltime=data[13]<<16 | data[14]<<8 | data[15]; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1059 priv->universaltime-=0x111111; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1060 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1061 snprintf(priv->networkname,21,"%s",data+20); |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1062 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1063 return 1; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1064 } |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1065 |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1066 /** |
23899 | 1067 * \brief decode packets 1..24 (teletext page header) |
1068 * \param priv private data structure | |
1069 * \param data raw teletext data | |
1070 * \param magAddr teletext page's magazine address | |
1071 * \param rowAddr teletext page's row number | |
1072 * | |
1073 * \remarks | |
1074 * data buffer was shifted by 6 and now contains 40 bytes of display data: | |
1075 * this type of packet is not proptected by Hamm 8/4 code | |
1076 */ | |
1077 static void decode_pkt_page(priv_vbi_t* priv,unsigned char*data,int magAddr,int rowAddr){ | |
1078 int i,err; | |
1079 if (!priv->mag[magAddr].pt) | |
1080 return; | |
1081 | |
1082 priv->mag[magAddr].order=rowAddr; | |
1083 | |
1084 err=0; | |
1085 for(i=0; i<VBI_COLUMNS; i++){ | |
1086 data[i]= fixParity[ data[i] ]; | |
1087 priv->mag[magAddr].pt->raw[i+rowAddr*VBI_COLUMNS]=data[i]; | |
1088 if( data[i]&0x80) //HammError | |
1089 err++; | |
1090 } | |
1091 pll_add(priv,1,err); | |
1092 | |
1093 store_in_cache(priv,magAddr,rowAddr); | |
1094 } | |
1095 | |
1096 /** | |
24244 | 1097 * \brief decode packets 27 (teletext links) |
1098 * \param priv private data structure | |
1099 * \param data raw teletext data | |
1100 * \param magAddr teletext page's magazine address | |
1101 */ | |
1102 static int decode_pkt27(priv_vbi_t* priv,unsigned char* data,int magAddr){ | |
1103 int i,hpg; | |
1104 | |
1105 if (!priv->mag[magAddr].pt) | |
1106 return 0; | |
1107 for(i=0;i<38;++i) | |
1108 if ((data[i] = corrHamm48[ data[i] ]) & 0x80){ | |
1109 pll_add(priv,2,4); | |
1110 return 0; | |
1111 } | |
1112 | |
1113 /* | |
1114 Not a X/27/0 Format 1 packet or | |
1115 flag "show links on row 24" is not set. | |
1116 */ | |
1117 if (data[0] || !(data[37] & 8)) | |
1118 return 1; | |
1119 for(i=0;i<6;++i) { | |
1120 hpg = (magAddr<<8) ^ ((data[4+i*6]&0x8)<<5 | (data[6+i*6]&0xc)<<7); | |
1121 if (!hpg) hpg=0x800; | |
1122 priv->mag[magAddr].pt->links[i].pagenum = (data[1+i*6] & 0xf) | | |
1123 ((data[2+i*6] & 0xf) << 4) | hpg; | |
1124 priv->mag[magAddr].pt->links[i].subpagenum = ((data[3+i*6] & 0xf) | | |
1125 (data[4+i*6] & 0xf) << 4 | (data[5+i*6] & 0xf) << 8 | | |
1126 (data[6+i*6] & 0xf) << 12) & 0x3f7f; | |
1127 } | |
1128 put_to_cache(priv,priv->mag[magAddr].pt,-1); | |
1129 return 1; | |
1130 } | |
1131 | |
1132 /** | |
23899 | 1133 * \brief decodes raw vbi data (signal amplitudes) into sequence of bytes |
1134 * \param priv private data structure | |
1135 * \param buf raw vbi data (one line of frame) | |
1136 * \param data output buffer for decoded bytes (at least 45 bytes long) | |
1137 * | |
1138 * Used XawTV's algorithm. Signal phase is calculated with help of starting clock | |
1139 * run-in sequence (min/max values and bit distance values are calculated) | |
1140 */ | |
1141 static int decode_raw_line_runin(priv_vbi_t* priv,unsigned char* buf,unsigned char* data){ | |
1142 const int magic= 0x27; // reversed 1110010 | |
1143 int dt[256],hi[6],lo[6]; | |
1144 int i,x,r; | |
1145 int decoded; | |
1146 int sync; | |
1147 unsigned char min,max; | |
1148 int thr=0; //threshold | |
1149 | |
1150 //stubs | |
24099 | 1151 int soc=priv->soc; |
1152 int eoc=priv->eoc; | |
23899 | 1153 |
1154 for(i=soc;i<eoc;i++) | |
1155 dt[i]=buf[i+priv->bpb/ONE_FIXP]-buf[i]; // amplifies the edges best. | |
1156 /* set barrier */ | |
1157 for (i=eoc; i<eoc+16; i+=2) | |
1158 dt[i]=100, dt[i+1]=-100; | |
1159 | |
1160 /* find 6 rising and falling edges */ | |
1161 for (i=soc, x=0; x<6; ++x) | |
1162 { | |
1163 while (dt[i]<32) | |
1164 i++; | |
1165 hi[x]=i; | |
1166 while (dt[i]>-32) | |
1167 i++; | |
1168 lo[x]=i; | |
1169 } | |
1170 if (i>=eoc) | |
1171 { | |
1172 return 0; // not enough periods found | |
1173 } | |
1174 i=hi[5]-hi[1]; // length of 4 periods (8 bits) | |
1175 if (i<priv->bp8bl || i>priv->bp8bh) | |
1176 { | |
1177 mp_msg(MSGT_TV,MSGL_DBG3,"vbi: wrong freq %d (%d,%d)\n", | |
1178 i,priv->bp8bl,priv->bp8bh); | |
1179 return 0; // bad frequency | |
1180 } | |
1181 /* AGC and sync-reference */ | |
1182 min=255, max=0, sync=0; | |
1183 for (i=hi[4]; i<hi[5]; ++i) | |
1184 if (buf[i]>max) | |
1185 max=buf[i], sync=i; | |
1186 for (i=lo[4]; i<lo[5]; ++i) | |
1187 if (buf[i]<min) | |
1188 min=buf[i]; | |
1189 thr=(min+max)/2; | |
1190 | |
1191 buf+=sync; | |
1192 // searching for '11' | |
1193 for(i=priv->pll_adj*priv->bpb/10;i<16*priv->bpb;i+=priv->bpb) | |
1194 if(buf[FIXP2INT(i)]>thr && buf[FIXP2INT(i+priv->bpb)]>thr) | |
1195 break; | |
1196 r=0; | |
1197 for(decoded=1; decoded<= (VBI_COLUMNS+3)<<3;decoded++){ | |
1198 r>>=1; | |
1199 if(buf[FIXP2INT(i)]>thr) r|=0x80; | |
1200 if(!(decoded & 0x07)){ | |
1201 data[(decoded>>3) - 1]=r; | |
1202 r=0; | |
1203 } | |
1204 i+=priv->bpb; | |
1205 } | |
1206 if(data[0]!=magic) | |
1207 return 0; //magic not found | |
1208 | |
1209 //stub | |
1210 for(i=0;i<43;i++){ | |
1211 data[i]=data[i+1]; | |
1212 } | |
1213 mp_msg(MSGT_TV,MSGL_DBG3,"thr:%d sync:%d ",thr,sync); | |
1214 | |
1215 return 1; | |
1216 } | |
1217 | |
1218 /** | |
1219 * \brief decodes raw vbi data (signal amplitudes) into sequence of bytes | |
1220 * \param priv private data structure | |
1221 * \param buf raw vbi data (one line of frame) | |
1222 * \param data output buffer for decoded bytes (at least 45 bytes long) | |
1223 * | |
1224 * Used Michael Niedermayer's algorithm. | |
1225 * Signal phase is calculated using correlation between given samples data and | |
1226 * pure sine | |
1227 */ | |
1228 static int decode_raw_line_sine(priv_vbi_t* priv,unsigned char* buf,unsigned char* data){ | |
1229 int i,x,r,amp,xFixp; | |
1230 int avg=0; | |
1231 double sin_sum=0, cos_sum=0; | |
1232 | |
1233 for(x=0; x< FIXP2INT(10*priv->bpb); x++) | |
1234 avg+=buf[x]; | |
1235 | |
1236 avg/=FIXP2INT(10*priv->bpb); | |
1237 | |
1238 for(x=0; x<12; x++){ | |
1239 amp= buf[x<<1]; | |
1240 sin_sum+= si[x]*(amp-avg); | |
1241 cos_sum+= co[x]*(amp-avg); | |
1242 } | |
1243 //this is always zero. Why ? | |
1244 xFixp= atan(sin_sum/cos_sum)*priv->bpb/M_PI; | |
1245 | |
1246 //Without this line the result is full of errors | |
1247 //and routine is unable to find magic sequence | |
1248 buf+=FIXP2INT(10*priv->bpb); | |
1249 | |
1250 r=0; | |
1251 for(x=FIXP2INT(xFixp);x<70;x=FIXP2INT(xFixp)){ | |
1252 r=(r<<1) & 0xFFFF; | |
1253 if(buf[x]>avg) r|=1; | |
1254 xFixp+=priv->bpb; | |
1255 if(r==0xAAE4) break; | |
1256 } | |
1257 | |
1258 //this is not teletext | |
1259 if (r!=0xaae4) return 0; | |
1260 | |
1261 //Decode remaining 45-2(clock run-in)-1(framing code)=42 bytes | |
1262 for(i=1; i<=(42<<3); i++){ | |
1263 r>>=1; | |
1264 x=FIXP2INT(xFixp); | |
1265 if(buf[x]> avg) | |
1266 r|=0x80; | |
1267 | |
1268 if(!(i & 0x07)){ | |
1269 data[(i>>3)-1]=r; | |
1270 r=0; | |
1271 } | |
1272 xFixp+=priv->bpb; | |
1273 } | |
1274 | |
1275 return 1; | |
1276 } | |
1277 | |
1278 /** | |
1279 * \brief decodes all vbi lines from one video frame | |
1280 * \param priv private data structure | |
1281 * \param buf buffer with raw vbi data in it | |
1282 * | |
1283 * \note buffer size have to be at least priv->ptsp->bufsize bytes | |
1284 */ | |
1285 static void vbi_decode(priv_vbi_t* priv,unsigned char*buf){ | |
1286 int magAddr; | |
1287 int pkt; | |
1288 unsigned char data[64]; | |
1289 unsigned char* linep; | |
1290 int d0,d1; | |
1291 int i=0; | |
1292 mp_msg(MSGT_TV,MSGL_DBG3,"vbi: vbi_decode\n"); | |
1293 for(linep=buf; linep<buf+priv->ptsp->bufsize; linep+=priv->ptsp->samples_per_line,i++){ | |
1294 #if 0 | |
1295 /* | |
1296 This routine is alternative implementation of raw VBI data decoding. | |
24278 | 1297 Unfortunately, it detects only about 20% of incoming data, |
23899 | 1298 but Michael says that this algorithm is better, and he wants to fix it. |
1299 */ | |
1300 if(decode_raw_line_sine(priv,linep,data)<=0){ | |
1301 #endif | |
1302 if(decode_raw_line_runin(priv,linep,data)<=0){ | |
1303 continue; //this is not valid teletext line | |
1304 } | |
1305 d0= corrHamm48[ data[0] ]; | |
1306 d1= corrHamm48[ data[1] ]; | |
1307 | |
1308 if(d0&0x80 || d1&0x80){ | |
1309 pll_add(priv,2,4); | |
1310 mp_msg(MSGT_TV,MSGL_V,"vbi_decode(%d):HammErr after decode_raw_line\n",i); | |
1311 | |
1312 continue; //hamError | |
1313 } | |
1314 magAddr=d0 & 0x7; | |
1315 pkt=(d0>>3)|(d1<<1); | |
1316 mp_msg(MSGT_TV,MSGL_DBG3,"vbi_decode(%d):%x %x (mag:%x, pkt:%d)\n", | |
1317 i,d0,d1,magAddr,pkt); | |
1318 if(!pkt){ | |
1319 decode_pkt0(priv,data+2,magAddr); //skip MRGA | |
1320 }else if(pkt>0 && pkt<VBI_ROWS){ | |
1321 if(!priv->mag[magAddr].pt) continue; | |
1322 decode_pkt_page(priv,data+2,magAddr,pkt);//skip MRGA | |
24244 | 1323 }else if(pkt==27) { |
1324 decode_pkt27(priv,data+2,magAddr); | |
24232
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1325 }else if(pkt==30){ |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1326 decode_pkt30(priv,data+2,magAddr); |
23899 | 1327 } else { |
1328 mp_msg(MSGT_TV,MSGL_DBG3,"unsupported packet:%d\n",pkt); | |
1329 } | |
1330 } | |
1331 | |
1332 } | |
1333 | |
1334 /* | |
1335 --------------------------------------------------------------------------------- | |
1336 Public routines | |
1337 --------------------------------------------------------------------------------- | |
1338 */ | |
1339 | |
1340 /** | |
1341 * \brief toggles teletext page displaying format | |
1342 * \param priv_vbi private data structure | |
1343 * \param flag new format | |
1344 * \return | |
1345 * TVI_CONTROL_TRUE is success, | |
1346 * TVI_CONTROL_FALSE otherwise | |
1347 * | |
1348 * flag: | |
1349 * 0 - opaque | |
1350 * 1 - transparent | |
1351 * 2 - opaque with black foreground color (only in bw mode) | |
1352 * 3 - transparent with black foreground color (only in bw mode) | |
1353 */ | |
1354 static int teletext_set_format(priv_vbi_t * priv, teletext_format flag) | |
1355 { | |
1356 flag&=3; | |
1357 | |
1358 mp_msg(MSGT_TV,MSGL_DBG3,"teletext_set_format_is called. mode:%d\n",flag); | |
1359 pthread_mutex_lock(&(priv->buffer_mutex)); | |
1360 | |
1361 priv->tformat=flag; | |
1362 | |
1363 priv->pagenumdec=0; | |
1364 | |
1365 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1366 return TVI_CONTROL_TRUE; | |
1367 } | |
1368 | |
1369 /** | |
1370 * \brief append just entered digit to editing page number | |
1371 * \param priv_vbi private data structure | |
1372 * \param dec decimal digit to append | |
1373 * | |
1374 * dec: | |
1375 * '0'..'9' append digit | |
1376 * '-' remove last digit (backspace emulation) | |
1377 * | |
1378 * This routine allows user to jump to arbitrary page. | |
1379 * It implements simple page number editing algorithm. | |
1380 * | |
1381 * Subsystem can be on one of two modes: normal and page number edit mode. | |
1382 * Zero value of priv->pagenumdec means normal mode | |
1383 * Non-zero value means page number edit mode and equals to packed | |
1384 * decimal number of already entered part of page number. | |
1385 * | |
1386 * How this works. | |
1387 * Let's assume that current mode is normal (pagenumdec is zero), teletext page | |
1388 * 100 are displayed as usual. topmost left corner of page contains page number. | |
1389 * Then vbi_add_dec is sequentially called (through slave | |
1390 * command of course) with 1,4,-,2,3 * values of dec parameter. | |
1391 * | |
1392 * +-----+------------+------------------+ | |
1393 * | dec | pagenumdec | displayed number | | |
1394 * +-----+------------+------------------+ | |
1395 * | | 0x000 | 100 | | |
1396 * +-----+------------+------------------+ | |
1397 * | 1 | 0x001 | __1 | | |
1398 * +-----+------------+------------------+ | |
1399 * | 4 | 0x014 | _14 | | |
1400 * +-----+------------+------------------+ | |
1401 * | - | 0x001 | __1 | | |
1402 * +-----+------------+------------------+ | |
1403 * | 2 | 0x012 | _12 | | |
1404 * +-----+------------+------------------+ | |
1405 * | 3 | 0x123 | 123 | | |
1406 * +-----+------------+------------------+ | |
1407 * | | 0x000 | 123 | | |
1408 * +-----+------------+------------------+ | |
1409 * | |
1410 * pagenumdec will automatically receive zero value after third digit of page | |
1411 * number is entered and current page will be switched to another one with | |
1412 * entered page number. | |
1413 */ | |
1414 static void vbi_add_dec(priv_vbi_t * priv, char *dec) | |
1415 { | |
1416 int count, shift; | |
1417 if (!dec) | |
1418 return; | |
1419 if (!priv->on) | |
1420 return; | |
1421 if ((*dec<'0' || *dec>'9') && *dec!='-') | |
1422 return; | |
1423 if (!priv->pagenumdec) //first digit cannot be '0','9' or '-' | |
1424 if(*dec=='-' || *dec=='0' || *dec=='9') | |
1425 return; | |
1426 pthread_mutex_lock(&(priv->buffer_mutex)); | |
1427 count=(priv->pagenumdec>>12)&0xf; | |
1428 if (*dec=='-') { | |
1429 count--; | |
1430 if (count) | |
1431 priv->pagenumdec=((priv->pagenumdec>>4)&0xfff)|(count<<12); | |
1432 else | |
1433 priv->pagenumdec=0; | |
1434 } else { | |
1435 shift = count * 4; | |
1436 count++; | |
1437 priv->pagenumdec= | |
1438 (((priv->pagenumdec)<<4|(*dec-'0'))&0xfff)|(count<<12); | |
1439 if (count==3) { | |
1440 priv->pagenum=priv->pagenumdec&0x7ff; | |
1441 priv->subpagenum=get_subpagenum_from_cache(priv,priv->pagenum); | |
1442 priv->pagenumdec=0; | |
1443 } | |
1444 } | |
1445 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1446 } | |
1447 | |
1448 | |
1449 /** | |
1450 * \brief Teletext control routine | |
1451 * \param priv_vbi private data structure | |
1452 * \param cmd command | |
1453 * \param arg command parameter (has to be not null) | |
1454 */ | |
1455 int teletext_control(void* p, int cmd, void *arg) | |
1456 { | |
1457 int fine_tune=99; | |
1458 priv_vbi_t* priv=(priv_vbi_t*)p; | |
24244 | 1459 tt_page* pgc; |
23899 | 1460 |
1461 if (!priv && cmd!=TV_VBI_CONTROL_START) | |
1462 return TVI_CONTROL_FALSE; | |
1463 if (!arg && cmd!=TV_VBI_CONTROL_STOP) | |
1464 return TVI_CONTROL_FALSE; | |
1465 | |
1466 switch (cmd) { | |
1467 case TV_VBI_CONTROL_RESET: | |
1468 { | |
1469 tv_param_t* tv_param=arg; | |
1470 pthread_mutex_lock(&(priv->buffer_mutex)); | |
1471 priv->pagenumdec=0; | |
1472 clear_cache(priv); | |
1473 priv->pagenum=steppage(0,tv_param->tpage&0x7ff,1); | |
1474 priv->tformat=tv_param->tformat; | |
1475 priv->subpagenum=0; | |
1476 pll_reset(priv,fine_tune); | |
1477 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1478 return TVI_CONTROL_TRUE; | |
1479 } | |
1480 case TV_VBI_CONTROL_START: | |
1481 { | |
1482 int i; | |
1483 tt_stream_props* ptsp=*(tt_stream_props**)arg; | |
1484 | |
1485 if(!ptsp) | |
1486 return TVI_CONTROL_FALSE; | |
1487 | |
1488 priv=calloc(1,sizeof(priv_vbi_t)); | |
1489 | |
1490 priv->ptsp=malloc(sizeof(tt_stream_props)); | |
1491 memcpy(priv->ptsp,ptsp,sizeof(tt_stream_props)); | |
1492 *(priv_vbi_t**)arg=priv; | |
1493 | |
1494 priv->subpagenum=0; | |
1495 pthread_mutex_init(&priv->buffer_mutex, NULL); | |
1496 priv->pagenumdec=0; | |
1497 for(i=0;i<VBI_ROWS*VBI_COLUMNS;i++) | |
1498 priv->display_page[i]=tt_space; | |
1499 | |
1500 priv->mag=calloc(8,sizeof(mag_t)); | |
1501 init_cache(priv); | |
1502 init_vbi_consts(priv); | |
1503 pll_reset(priv,fine_tune); | |
1504 return TVI_CONTROL_TRUE; | |
1505 } | |
1506 case TV_VBI_CONTROL_STOP: | |
1507 { | |
1508 if(priv->mag) | |
1509 free(priv->mag); | |
1510 if(priv->ptsp) | |
1511 free(priv->ptsp); | |
1512 destroy_cache(priv); | |
1513 free(priv); | |
1514 return TVI_CONTROL_TRUE; | |
1515 } | |
1516 case TV_VBI_CONTROL_SET_MODE: | |
1517 priv->on=(*(int*)arg%2); | |
1518 return TVI_CONTROL_TRUE; | |
1519 case TV_VBI_CONTROL_GET_MODE: | |
1520 *(int*)arg=priv->on; | |
1521 return TVI_CONTROL_TRUE; | |
1522 case TV_VBI_CONTROL_SET_FORMAT: | |
1523 return teletext_set_format(priv, *(int *) arg); | |
1524 case TV_VBI_CONTROL_GET_FORMAT: | |
1525 pthread_mutex_lock(&(priv->buffer_mutex)); | |
1526 *(int*)arg=priv->tformat; | |
1527 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1528 return TVI_CONTROL_TRUE; | |
1529 case TV_VBI_CONTROL_GET_HALF_PAGE: | |
1530 if(!priv->on) | |
1531 return TVI_CONTROL_FALSE; | |
1532 *(int *)arg=priv->zoom; | |
1533 return TVI_CONTROL_TRUE; | |
1534 case TV_VBI_CONTROL_SET_HALF_PAGE: | |
1535 { | |
1536 int val=*(int*)arg; | |
1537 val%=3; | |
1538 if(val<0) | |
1539 val+=3; | |
1540 pthread_mutex_lock(&(priv->buffer_mutex)); | |
1541 priv->zoom=val; | |
1542 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1543 return TVI_CONTROL_TRUE; | |
1544 } | |
24244 | 1545 case TV_VBI_CONTROL_GO_LINK: |
1546 { | |
1547 int val=*(int *) arg; | |
1548 if(val<1 || val>6) | |
1549 return TVI_CONTROL_FALSE; | |
1550 pthread_mutex_lock(&(priv->buffer_mutex)); | |
1551 if (!(pgc = priv->ptt_cache[priv->pagenum])) { | |
1552 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1553 return TVI_CONTROL_FALSE; | |
1554 } | |
1555 if (!pgc->links[val-1].pagenum || pgc->links[val-1].pagenum>0x7ff) { | |
1556 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1557 return TVI_CONTROL_FALSE; | |
1558 } | |
1559 priv->pagenum=pgc->links[val-1].pagenum; | |
1560 if(pgc->links[val-1].subpagenum!=0x3f7f) | |
1561 priv->subpagenum=pgc->links[val-1].subpagenum; | |
1562 else | |
1563 priv->subpagenum=get_subpagenum_from_cache(priv,priv->pagenum); | |
1564 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1565 return TVI_CONTROL_TRUE; | |
1566 } | |
23899 | 1567 case TV_VBI_CONTROL_SET_PAGE: |
1568 { | |
1569 int val=*(int *) arg; | |
1570 if(val<100 || val>0x899) | |
1571 return TVI_CONTROL_FALSE; | |
1572 pthread_mutex_lock(&(priv->buffer_mutex)); | |
1573 priv->pagenum=val&0x7ff; | |
1574 priv->subpagenum=get_subpagenum_from_cache(priv,priv->pagenum); | |
1575 priv->pagenumdec=0; | |
1576 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1577 return TVI_CONTROL_TRUE; | |
1578 } | |
1579 case TV_VBI_CONTROL_STEP_PAGE: | |
1580 { | |
1581 int direction=*(int *) arg; | |
1582 pthread_mutex_lock(&(priv->buffer_mutex)); | |
1583 priv->pagenum=steppage(priv->pagenum, direction,1); | |
1584 priv->subpagenum=get_subpagenum_from_cache(priv,priv->pagenum); | |
1585 priv->pagenumdec=0; | |
1586 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1587 return TVI_CONTROL_TRUE; | |
1588 } | |
1589 case TV_VBI_CONTROL_GET_PAGE: | |
1590 *(int*)arg=((priv->pagenum+0x700)&0x7ff)+0x100; | |
1591 return TVI_CONTROL_TRUE; | |
1592 case TV_VBI_CONTROL_SET_SUBPAGE: | |
1593 pthread_mutex_lock(&(priv->buffer_mutex)); | |
1594 priv->pagenumdec=0; | |
1595 priv->subpagenum=*(int*)arg; | |
1596 if(priv->subpagenum<0) | |
1597 priv->subpagenum=0; | |
1598 if(priv->subpagenum>=VBI_MAX_SUBPAGES) | |
1599 priv->subpagenum=VBI_MAX_SUBPAGES-1; | |
1600 pthread_mutex_unlock(&(priv->buffer_mutex)); | |
1601 return TVI_CONTROL_TRUE; | |
1602 case TV_VBI_CONTROL_GET_SUBPAGE: | |
1603 *(int*)arg=priv->subpagenum; | |
1604 return TVI_CONTROL_TRUE; | |
1605 case TV_VBI_CONTROL_ADD_DEC: | |
1606 vbi_add_dec(priv, *(char **) arg); | |
1607 return TVI_CONTROL_TRUE; | |
1608 case TV_VBI_CONTROL_DECODE_PAGE: | |
1609 vbi_decode(priv,*(unsigned char**)arg); | |
1610 return TVI_CONTROL_TRUE; | |
1611 case TV_VBI_CONTROL_GET_VBIPAGE: | |
1612 if(!priv->on) | |
1613 return TVI_CONTROL_FALSE; | |
1614 prepare_visible_page(priv); | |
1615 *(void **)arg=priv->display_page; | |
1616 return TVI_CONTROL_TRUE; | |
24232
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1617 case TV_VBI_CONTROL_GET_NETWORKNAME: |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1618 *(void **)arg=priv->networkname; |
d0290b80e612
Implement 8/30 format 1 teletext packet decoding
voroshil
parents:
24197
diff
changeset
|
1619 return TVI_CONTROL_TRUE; |
23899 | 1620 } |
1621 return TVI_CONTROL_UNKNOWN; | |
1622 } |