Mercurial > mplayer.hg
annotate libmpdemux/demux_ty_osd.c @ 33556:520fb0f7544c
Rename GUI directory 'mplayer' and some files in it.
The directory 'mplayer' contains the files for the user interface and
has thus been renamed 'ui'.
Inside this directory the following files have been renamed to better
reflect their contents:
mw.c -> main.c
sw.c -> sub.c
pb.c -> playbar.c
gui_common.* -> render.*
play.* -> actions.*
author | ib |
---|---|
date | Sat, 18 Jun 2011 16:03:31 +0000 |
parents | 2546de3e5afe |
children | 27640f4f0479 |
rev | line source |
---|---|
25768 | 1 // Most of this was written by Mike Baker <mbm@linux.com> |
26648
e5f5e8891f86
Mike Baker agreed to relicense his parts of the code as GPL v2+ on IRC.
diego
parents:
25962
diff
changeset
|
2 // and released under the GPL v2+ license. |
10263 | 3 // |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
4 // Modifications and SEVERE cleanup of the code was done by |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
5 // Christopher Wingert |
10263 | 6 // Copyright 2003 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
7 // |
10263 | 8 // Released under GPL2 License. |
9 | |
10 #include <stdio.h> | |
11 #include <stdlib.h> | |
12 #include <unistd.h> | |
13 #include <time.h> | |
14 #include <stdarg.h> | |
10310
68e714ed669f
fix one missing #include, one missing extern and one 10l error.
rathann
parents:
10263
diff
changeset
|
15 #include <string.h> |
10263 | 16 |
17 #include "config.h" | |
18 #include "mp_msg.h" | |
19 #include "help_mp.h" | |
20 | |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
19104
diff
changeset
|
21 //#include "stream/stream.h" |
10263 | 22 //#include "demuxer.h" |
23 //#include "parse_es.h" | |
24 //#include "stheader.h" | |
25 //#include "mp3_hdr.h" | |
32454
69d3be4d52a2
Create a new directory, "sub", for subtitles and OSD related code.
cigaes
parents:
32012
diff
changeset
|
26 //#include "sub/subreader.h" |
32458 | 27 #include "sub/sub_cc.h" |
32467 | 28 #include "sub/sub.h" |
30577
737b7fd47ef4
Add header for ty_ClearOSD(), ty_processuserdata(); avoids forward declarations.
diego
parents:
29263
diff
changeset
|
29 #include "demux_ty_osd.h" |
10263 | 30 |
31 //#include "dvdauth.h" | |
32 | |
33 #define TY_TEXT_MODE ( 1 << 0 ) | |
34 #define TY_OSD_MODE ( 1 << 1 ) | |
35 | |
36 static int TY_OSD_flags = TY_TEXT_MODE | TY_OSD_MODE; | |
37 static int TY_OSD_debug = 0; | |
38 | |
39 // =========================================================================== | |
40 // Closed Caption Decoding and OSD Presentation | |
41 // =========================================================================== | |
42 #define TY_CCNONE ( -3 ) | |
43 #define TY_CCTEXTMODE ( -2 ) | |
44 #define TY_CCPOPUPNB ( -1 ) | |
45 #define TY_CCPOPUP ( 0 ) | |
46 #define TY_CCPAINTON ( 1 ) | |
47 | |
48 #define TY_CC_MAX_X ( 45 ) | |
49 | |
50 static int TY_CC_CUR_X; | |
51 static int TY_CC_CUR_Y; | |
52 static int TY_CC_stat = TY_CCNONE; | |
53 static char TY_CC_buf[ 255 ]; | |
54 static char *TY_CC_ptr = TY_CC_buf; | |
55 static unsigned TY_CC_lastcap = 0; | |
56 static int TY_CC_TextItalic; | |
57 static int TY_CC_Y_Offset; | |
58 | |
59 static subtitle ty_OSD1; | |
60 static subtitle ty_OSD2; | |
61 static subtitle *ty_pOSD1; | |
62 static subtitle *ty_pOSD2; | |
25962 | 63 static int tyOSDInitialized = 0; |
10263 | 64 static int tyOSDUpdate = 0; |
65 | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
17012
diff
changeset
|
66 static void ty_DrawOSD(void) |
10263 | 67 { |
68 // printf( "Calling ty_DrawOSD()\n" ); | |
69 tyOSDUpdate = 1; | |
70 } | |
71 | |
72 void ty_ClearOSD( int start ) | |
73 { | |
74 int index; | |
75 // printf( "Calling ty_ClearOSD()\n" ); | |
76 for ( index = start ; index < SUB_MAX_TEXT ; index++ ) | |
77 { | |
78 memset( ty_OSD1.text[ index ], ' ', TY_CC_MAX_X - 1 ); | |
79 ty_OSD1.text[ index ][ TY_CC_MAX_X - 1 ] = 0; | |
80 memset( ty_OSD2.text[ index ], ' ', TY_CC_MAX_X - 1 ); | |
81 ty_OSD2.text[ index ][ TY_CC_MAX_X - 1 ] = 0; | |
82 } | |
83 } | |
84 | |
85 static void ty_DrawChar( int *x, int *y, char disChar, int fgColor, int bgColor ) | |
86 { | |
87 int cx; | |
88 int cy; | |
89 | |
90 cx = *x; | |
91 cy = *y; | |
92 | |
93 if ( *x >= ( TY_CC_MAX_X - 1 ) ) | |
94 { | |
95 cx = 0; | |
96 } | |
97 if ( ( *y + TY_CC_Y_Offset ) > SUB_MAX_TEXT ) | |
98 { | |
99 cy = SUB_MAX_TEXT - TY_CC_Y_Offset - 1; | |
100 } | |
101 | |
102 // printf( "Calling ty_DrawChar() x:%d y:%d %c fg:%d bg:%d\n", | |
103 // cx, cy, disChar, fgColor, bgColor ); | |
104 | |
105 ty_OSD1.text[ TY_CC_Y_Offset + cy ][ cx ] = disChar; | |
106 memset( &( ty_OSD1.text[ TY_CC_Y_Offset + cy ][ cx + 1 ] ), ' ', | |
107 TY_CC_MAX_X - cx - 2 ); | |
108 ( *x )++; | |
109 } | |
110 | |
111 static void ty_RollupBuf( int dest, int source, int numLines ) | |
112 { | |
113 int index; | |
114 | |
115 // printf( "Calling ty_RollupBuf() dest:%d source %d, numLines %d\n", | |
116 // dest, source, numLines ); | |
117 // | |
118 if ( ( source + TY_CC_Y_Offset + numLines ) > SUB_MAX_TEXT ) | |
119 { | |
120 ty_ClearOSD( 1 ); | |
121 return; | |
122 } | |
123 | |
124 if ( ( source + TY_CC_Y_Offset + numLines ) < 0 ) | |
125 { | |
126 ty_ClearOSD( 1 ); | |
127 return; | |
128 } | |
129 | |
130 if ( numLines > SUB_MAX_TEXT ) | |
131 { | |
132 ty_ClearOSD( 1 ); | |
133 return; | |
134 } | |
135 | |
136 for ( index = 0 ; index < numLines ; index++ ) | |
137 { | |
138 strcpy( ty_OSD1.text[ TY_CC_Y_Offset + dest ], | |
139 ty_OSD1.text[ TY_CC_Y_Offset + source ] ); | |
140 dest++; | |
141 source++; | |
142 } | |
143 memset( ty_OSD1.text[ TY_CC_Y_Offset + source - 1 ], ' ', TY_CC_MAX_X - 1 ); | |
144 ty_OSD1.text[ TY_CC_Y_Offset + source - 1 ][ TY_CC_MAX_X - 1 ] = 0; | |
145 } | |
146 | |
147 static void ty_drawchar( char c ) | |
148 { | |
149 if ( c < 2 ) return; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
150 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
151 if ( TY_OSD_flags & TY_OSD_MODE && TY_CC_stat != TY_CCNONE && |
10263 | 152 TY_CC_CUR_Y != -1 ) |
153 ty_DrawChar( &TY_CC_CUR_X, &TY_CC_CUR_Y, c, 4, 13 ); | |
154 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
155 if ( TY_CC_ptr - TY_CC_buf > sizeof( TY_CC_buf ) - 1 ) |
10263 | 156 { // buffer overflow |
157 TY_CC_ptr = TY_CC_buf; | |
158 memset( TY_CC_buf, 0, sizeof( TY_CC_buf ) ); | |
159 } | |
160 *( TY_CC_ptr++ ) = ( c == 14 ) ? '/' : c; // swap a '/' for musical note | |
161 } | |
162 | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
17012
diff
changeset
|
163 static void ty_draw(void) |
10263 | 164 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
165 if ( TY_CC_ptr != TY_CC_buf && TY_OSD_flags & TY_TEXT_MODE ) |
10263 | 166 { |
167 if ( *( TY_CC_ptr - 1 ) == '\n' ) *( TY_CC_ptr - 1 ) = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
168 |
10263 | 169 mp_msg( MSGT_DEMUX, MSGL_V, "CC: %s\n", TY_CC_buf ); |
170 } | |
171 TY_CC_lastcap = time( NULL ); | |
172 | |
173 TY_CC_ptr = TY_CC_buf; | |
174 memset( TY_CC_buf, 0, sizeof( TY_CC_buf) ); | |
175 | |
176 if ( TY_OSD_flags & TY_OSD_MODE ) ty_DrawOSD(); | |
177 if ( TY_CC_TextItalic ) TY_CC_TextItalic = 0; | |
178 } | |
179 | |
180 | |
181 static int CC_last = 0; | |
182 static char CC_mode = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
183 static int CC_row[] = |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
184 { |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
185 11, -1, 1, 2, 3, 4, 12, 13, 14, 15, 5, 6, 7, 8, 9, 10 |
10263 | 186 }; |
187 | |
188 // char specialchar[] = { '®', '°', '½', '¿', '*', '¢', '£', 14, 'à ', ' ', 'è', 'â', 'ê', 'î', 'ô', 'û' }; | |
189 | |
190 static int ty_CCdecode( char b1, char b2 ) | |
191 { | |
192 int x; | |
193 int data = ( b2 << 8 ) + b1; | |
194 | |
195 if ( b1 & 0x60 ) // text | |
196 { | |
197 if ( !TY_OSD_debug && TY_CC_stat == TY_CCNONE ) return 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
198 if ( TY_OSD_debug > 3 ) |
10263 | 199 { |
200 mp_msg( MSGT_DEMUX, MSGL_DBG3, "%c %c", b1, b2 ); | |
201 } | |
202 ty_drawchar( b1 ); | |
203 ty_drawchar( b2 ); | |
204 | |
205 if ( TY_CC_stat > 0 && TY_OSD_flags & TY_OSD_MODE ) ty_DrawOSD(); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
206 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
207 else if ( ( b1 & 0x10 ) && ( b2 > 0x1F ) && ( data != CC_last ) ) |
10263 | 208 { |
209 #define CURRENT ( ( b1 & 0x08 ) >> 3 ) | |
210 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
211 if ( CC_mode != CURRENT && TY_CC_stat != TY_CCNONE ) |
10263 | 212 { |
213 if ( TY_OSD_debug && TY_CC_ptr != TY_CC_buf ) ty_draw(); | |
214 TY_CC_stat = TY_CCNONE; | |
215 return 0; | |
216 } | |
217 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
218 if ( TY_CC_stat == TY_CCNONE || TY_CC_CUR_Y == -1 ) |
10263 | 219 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
220 if ( TY_CC_ptr != TY_CC_buf ) |
10263 | 221 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
222 if ( TY_OSD_debug ) |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
223 mp_msg( MSGT_DEMUX, MSGL_DBG3, "(TY_OSD_debug) %s\n", |
10263 | 224 TY_CC_buf ); |
225 TY_CC_ptr = TY_CC_buf; | |
226 memset(TY_CC_buf, 0, sizeof(TY_CC_buf)); | |
227 } | |
228 | |
229 if ( CC_mode != CURRENT ) return 0; | |
230 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
231 |
10263 | 232 // preamble address code (row & indent) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
233 if ( b2 & 0x40 ) |
10263 | 234 { |
235 TY_CC_CUR_Y = CC_row[ ( ( b1 << 1 ) & 14 ) | ( ( b2 >> 5 ) & 1 ) ]; | |
236 | |
237 // Offset into MPlayer's Buffer | |
238 if ( ( TY_CC_CUR_Y >= 1 ) && ( TY_CC_CUR_Y <= 4 ) ) | |
239 { | |
240 TY_CC_Y_Offset = SUB_MAX_TEXT - 5 - 1; | |
241 } | |
242 if ( ( TY_CC_CUR_Y >= 5 ) && ( TY_CC_CUR_Y <= 10 ) ) | |
243 { | |
244 TY_CC_Y_Offset = SUB_MAX_TEXT - 5 - 5; | |
245 } | |
246 if ( ( TY_CC_CUR_Y >= 12 ) && ( TY_CC_CUR_Y <= 15 ) ) | |
247 { | |
248 TY_CC_Y_Offset = SUB_MAX_TEXT - 5 - 12; | |
249 } | |
250 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
251 if ( TY_OSD_debug > 3 ) |
10263 | 252 mp_msg( MSGT_DEMUX, MSGL_DBG3, "<< preamble %d >>\n", TY_CC_CUR_Y ); |
253 | |
254 // we still have something in the text buffer | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
255 if (TY_CC_ptr != TY_CC_buf) |
10263 | 256 { |
257 *(TY_CC_ptr++) = '\n'; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
258 if ( TY_CC_TextItalic ) |
10263 | 259 { |
260 TY_CC_TextItalic = 0; | |
261 } | |
262 } | |
263 | |
264 TY_CC_CUR_X = 1; | |
265 // row contains indent flag | |
266 if ( b2 & 0x10 ) | |
267 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
268 for ( x = 0 ; x < ( ( b2 & 0x0F ) << 1 ) ; x++ ) |
10263 | 269 { |
270 TY_CC_CUR_X++; | |
271 *(TY_CC_ptr++) = ' '; | |
272 } | |
273 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
274 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
275 else |
10263 | 276 // !(b2 & 0x40) |
277 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
278 if ( TY_OSD_debug > 3 ) |
10263 | 279 mp_msg( MSGT_DEMUX, MSGL_DBG3, "<< %02x >>\n", b1 & 0x7 ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
280 switch (b1 & 0x07) |
10263 | 281 { |
282 case 0x00: // attribute | |
283 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
284 if ( TY_OSD_debug > 1 ) |
10263 | 285 mp_msg( MSGT_DEMUX, MSGL_DBG3, "<<A: %d>>\n", b2 ); |
286 break; | |
287 } | |
288 case 0x01: // midrow or char | |
289 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
290 switch (b2 & 0x70) |
10263 | 291 { |
292 case 0x20: // midrow attribute change | |
293 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
294 switch (b2 & 0x0e) |
10263 | 295 { |
296 case 0x00: // italics off | |
297 { | |
298 TY_CC_TextItalic = 0; | |
299 *(TY_CC_ptr++) = ' '; | |
300 break; | |
301 } | |
302 case 0x0e: // italics on | |
303 { | |
304 ty_drawchar(' '); | |
305 TY_CC_TextItalic = 1; | |
306 break; | |
307 } | |
308 default: | |
309 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
310 if ( TY_OSD_debug > 1 ) |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
311 mp_msg( MSGT_DEMUX, MSGL_DBG3, "<<D: %d>>\n", |
10263 | 312 b2 & 0x0e ); |
313 } | |
314 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
315 if ( b2 & 0x01 ) |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
316 { |
10263 | 317 // TextUnderline = 1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
318 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
319 else |
10263 | 320 { |
321 // TextUnderline = 0; | |
322 } | |
323 break; | |
324 } | |
325 case 0x30: // special character.. | |
326 { | |
327 // transparent space | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
328 if ( ( b2 & 0x0f ) == 9 ) |
10263 | 329 { |
330 TY_CC_CUR_X++; | |
331 *(TY_CC_ptr++) = ' '; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
332 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
333 else |
10263 | 334 { |
335 // ty_drawchar(specialchar[ b2 & 0x0f ] ); | |
336 ty_drawchar( ' ' ); | |
337 } | |
338 break; | |
339 } | |
340 } | |
341 break; | |
342 } | |
343 | |
344 case 0x04: // misc | |
345 case 0x05: // misc + F | |
346 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
347 if ( TY_OSD_debug > 3 ) |
10263 | 348 mp_msg( MSGT_DEMUX, MSGL_DBG3, "<< misc %02x >>\n", b2 ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
349 switch ( b2 ) |
10263 | 350 { |
351 case 0x20: // resume caption (new caption) | |
352 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
353 if ( TY_OSD_flags & TY_OSD_MODE && |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
354 TY_CC_stat != TY_CCPOPUP ) |
10263 | 355 ty_ClearOSD( 1 ); |
356 TY_CC_stat = TY_CCPOPUP; | |
357 break; | |
358 } | |
359 | |
360 case 0x21: // backspace | |
361 { | |
362 TY_CC_CUR_X--; | |
363 break; | |
364 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
365 |
23913
8b9b08c45999
Do not use gnu case-range extension if it's easy to avoid
reimar
parents:
23635
diff
changeset
|
366 case 0x25: // 2-4 row captions |
8b9b08c45999
Do not use gnu case-range extension if it's easy to avoid
reimar
parents:
23635
diff
changeset
|
367 case 0x26: |
8b9b08c45999
Do not use gnu case-range extension if it's easy to avoid
reimar
parents:
23635
diff
changeset
|
368 case 0x27: |
10263 | 369 { |
370 if ( TY_CC_stat == TY_CCPOPUP ) ty_ClearOSD( 1 ); | |
371 TY_CC_stat = b2 - 0x23; | |
372 if ( TY_CC_CUR_Y < TY_CC_stat ) TY_CC_CUR_Y = TY_CC_stat; | |
373 break; | |
374 } | |
375 | |
376 case 0x29: // resume direct caption | |
377 { | |
378 TY_CC_stat = TY_CCPAINTON; | |
379 break; | |
380 } | |
381 | |
382 case 0x2A: // text restart | |
383 { | |
384 ty_draw(); | |
385 /* FALL */ | |
386 } | |
387 | |
388 case 0x2B: // resume text display | |
389 { | |
390 TY_CC_stat = TY_CCTEXTMODE; | |
391 break; | |
392 } | |
393 | |
394 case 0x2C: // erase displayed memory | |
395 { | |
396 TY_CC_lastcap = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
397 if ( TY_OSD_flags & TY_OSD_MODE ) |
10263 | 398 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
399 if ( TY_CC_stat > TY_CCPOPUP || TY_CC_ptr == TY_CC_buf ) |
10263 | 400 { |
401 ty_ClearOSD( 1 ); | |
402 ty_draw(); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
403 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
404 else |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
405 { |
10263 | 406 ty_ClearOSD( 1 ); |
407 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
408 // CRW - |
10263 | 409 // new buffer |
410 // Used to be a buffer swap here, dunno why | |
411 } | |
412 } | |
413 break; | |
414 } | |
415 | |
416 case 0x2D: // carriage return | |
417 { | |
418 ty_draw(); | |
419 TY_CC_CUR_X = 1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
420 if ( TY_OSD_flags & TY_OSD_MODE ) |
10263 | 421 { |
422 if ( TY_CC_stat > TY_CCPAINTON ) | |
423 ty_RollupBuf | |
424 ( | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
425 TY_CC_CUR_Y - TY_CC_stat + 1 , |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
426 TY_CC_CUR_Y - TY_CC_stat + 2, |
10263 | 427 TY_CC_stat - 1 |
428 ); | |
429 else | |
430 TY_CC_CUR_Y++; | |
431 } | |
432 break; | |
433 } | |
434 | |
435 case 0x2F: // end caption + swap memory | |
436 { | |
437 ty_draw(); | |
438 /* FALL THROUGH TO 0x2E */ | |
439 } | |
440 | |
441 case 0x2E: // erase non-displayed memory | |
442 { | |
443 if ( TY_OSD_debug && TY_CC_ptr != TY_CC_buf ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
444 mp_msg( MSGT_DEMUX, MSGL_DBG3, "(TY_OSD_debug) %s\n", |
10263 | 445 TY_CC_buf ); |
446 if ( TY_OSD_flags & TY_OSD_MODE ) ty_ClearOSD( 1 ); | |
447 | |
448 TY_CC_CUR_X = 1; | |
449 TY_CC_CUR_Y = -1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
450 |
10263 | 451 TY_CC_ptr = TY_CC_buf; |
452 memset( TY_CC_buf, 0, sizeof( TY_CC_buf ) ); | |
453 } | |
454 } | |
455 break; | |
456 } | |
457 case 0x07: // misc (TAB) | |
458 { | |
459 for ( x = 0 ; x < ( b2 - 0x20 ) ; x++ ) | |
460 TY_CC_CUR_X++; | |
461 break; | |
462 } | |
463 } | |
464 } | |
465 } | |
466 CC_last = data; | |
467 return 0; | |
468 } | |
469 | |
470 // =========================================================================== | |
471 // Extended Data Service Decoding and OSD Presentation | |
472 // =========================================================================== | |
473 #define XDS_BUFFER_LENGTH ( 16 ) | |
474 #define XDS_DISPLAY_FRAMES ( 120 ) | |
475 static char *ty_XDS_Display[ XDS_BUFFER_LENGTH ]; | |
476 static int ty_XDSAddLine = -1; | |
477 static int ty_XDSDisplayCount = -1; | |
478 | |
479 | |
19104
2ec2301183cd
marks several read-only string parameters which aren't modified inside the called function as const. Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
18958
diff
changeset
|
480 static void ty_AddXDSToDisplay( const char *format, ... ) |
10263 | 481 { |
482 char line[ 80 ]; | |
483 int index; | |
484 va_list ap; | |
485 | |
486 if ( ty_XDSAddLine == -1 ) | |
487 { | |
488 for( index = 0 ; index < XDS_BUFFER_LENGTH ; index++ ) | |
489 { | |
490 ty_XDS_Display[ index ] = 0; | |
491 } | |
492 ty_XDSAddLine = 0; | |
493 } | |
494 | |
495 va_start( ap, format ); | |
496 vsnprintf( line, 80, format, ap ); | |
497 va_end( ap ); | |
498 mp_msg( MSGT_DEMUX, MSGL_V, "XDS: %s\n", line ); | |
499 | |
500 if ( ty_XDSAddLine == XDS_BUFFER_LENGTH ) | |
501 { | |
502 mp_msg( MSGT_DEMUX, MSGL_ERR, "XDS Buffer would have been blown\n" ); | |
503 } | |
504 | |
505 if ( ty_XDS_Display[ ty_XDSAddLine ] != 0 ) | |
506 { | |
507 free( ty_XDS_Display[ ty_XDSAddLine ] ); | |
508 ty_XDS_Display[ ty_XDSAddLine ] = 0; | |
509 } | |
510 | |
511 ty_XDS_Display[ ty_XDSAddLine ] = malloc( strlen( line ) + 1 ); | |
512 strcpy( ty_XDS_Display[ ty_XDSAddLine ], line ); | |
513 ty_XDSAddLine++; | |
514 } | |
515 | |
516 | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
17012
diff
changeset
|
517 static void ty_DisplayXDSInfo(void) |
10263 | 518 { |
519 int index; | |
520 int size; | |
521 | |
522 if ( ty_XDSDisplayCount == -1 ) | |
523 { | |
524 for( index = 0 ; index < XDS_BUFFER_LENGTH ; index++ ) | |
525 { | |
526 if ( ty_XDS_Display[ index ] != 0 ) | |
527 { | |
528 break; | |
529 } | |
530 } | |
531 if ( index != XDS_BUFFER_LENGTH ) | |
532 { | |
533 size = strlen( ty_XDS_Display[ index ] ); | |
534 | |
535 // Right Justify the XDS Stuff | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
536 memcpy( &( ty_OSD1.text[ 0 ][ TY_CC_MAX_X - size - 1 ] ), |
10263 | 537 ty_XDS_Display[ index ], size ); |
538 free( ty_XDS_Display[ index ] ); | |
539 ty_XDS_Display[ index ] = 0; | |
540 ty_XDSDisplayCount = 0; | |
541 tyOSDUpdate = 1; | |
542 | |
543 } | |
544 else | |
545 { | |
546 // We cleaned out all the XDS stuff to be displayed | |
547 ty_XDSAddLine = 0; | |
548 } | |
549 } | |
550 else | |
551 { | |
552 // We displayed that piece of XDS information long enough | |
11000 | 553 // Let's move on |
10263 | 554 ty_XDSDisplayCount++; |
555 if ( ty_XDSDisplayCount >= XDS_DISPLAY_FRAMES ) | |
556 { | |
557 memset( ty_OSD1.text[ 0 ], ' ', TY_CC_MAX_X - 1 ); | |
558 ty_OSD1.text[ 0 ][ TY_CC_MAX_X - 1 ] = 0; | |
559 ty_XDSDisplayCount = -1; | |
560 tyOSDUpdate = 1; | |
561 } | |
562 } | |
563 } | |
564 | |
565 | |
566 static int TY_XDS_mode = 0; | |
567 static int TY_XDS_type = 0; | |
568 static int TY_XDS_length = 0; | |
569 static char TY_XDS_checksum = 0; | |
570 | |
571 // Array of [ Mode ][ Type ][ Length ] | |
572 static char TY_XDS [ 8 ][ 25 ][ 34 ]; | |
573 static char TY_XDS_new[ 8 ][ 25 ][ 34 ]; | |
574 | |
575 // Array of [ MPAARating|TVRating ][ NumberRatings ] | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
576 static const char * const TY_XDS_CHIP[ 2 ][ 8 ] = |
10263 | 577 { |
578 { "(NOT APPLICABLE)", "G", "PG", "PG-13", "R", "NC-17", "X", "(NOT RATED)" }, | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
579 { "(NOT RATED)", "TV-Y", "TV-Y7", "TV-G", "TV-PG", "TV-14", "TV-MA", |
10263 | 580 "(NOT RATED)" } |
581 }; | |
582 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
583 static const char * const TY_XDS_modes[] = |
10263 | 584 { |
585 "CURRENT", // 01h-02h current program | |
586 "FUTURE ", // 03h-04h future program | |
587 "CHANNEL", // 05h-06h channel | |
588 "MISC. ", // 07h-08h miscellaneous | |
589 "PUBLIC ", // 09h-0Ah public service | |
590 "RESERV.", // 0Bh-0Ch reserved | |
591 "UNDEF. ", | |
592 "INVALID", | |
593 "INVALID", | |
594 "INVALID" | |
595 }; | |
596 | |
597 static int ty_XDSdecode( char b1, char b2 ) | |
598 { | |
599 char line[ 80 ]; | |
600 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
601 if ( b1 < 0x0F ) |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
602 { // start packet |
10263 | 603 TY_XDS_length = 0; |
604 TY_XDS_mode = b1 >> 1; // every other mode is a resume | |
605 TY_XDS_type = b2; | |
606 TY_XDS_checksum = b1 + b2; | |
607 return 0; | |
608 } | |
609 | |
610 TY_XDS_checksum += b1 + b2; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
611 |
10263 | 612 // eof (next byte is checksum) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
613 if ( b1 == 0x0F ) |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
614 { |
10263 | 615 // validity check |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
616 if ( !TY_XDS_length || TY_XDS_checksum & 0x7F ) |
10263 | 617 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
618 if ( TY_OSD_debug > 3 && !TY_XDS_length ) |
10263 | 619 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
620 mp_msg( MSGT_DEMUX, MSGL_DBG3, |
10263 | 621 "%% TY_XDS CHECKSUM ERROR (ignoring)\n" ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
622 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
623 else |
10263 | 624 { |
625 TY_XDS_mode = 0; | |
626 TY_XDS_type = 0; | |
627 return 1; | |
628 } | |
629 } | |
630 | |
631 // check to see if the data has changed. | |
632 if ( strncmp( TY_XDS[ TY_XDS_mode ][ TY_XDS_type ], | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
633 TY_XDS_new[ TY_XDS_mode ][ TY_XDS_type ], TY_XDS_length - 1 ) ) |
10263 | 634 { |
635 char *TY_XDS_ptr = TY_XDS[ TY_XDS_mode ][ TY_XDS_type ]; | |
636 | |
637 TY_XDS_ptr[ TY_XDS_length ] = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
638 memcpy( TY_XDS[ TY_XDS_mode ][ TY_XDS_type ], |
10263 | 639 TY_XDS_new[ TY_XDS_mode ][ TY_XDS_type ], TY_XDS_length ); |
640 | |
641 // nasty hack: only print time codes if seconds are 0 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
642 if ( TY_XDS_mode == 3 && TY_XDS_type == 1 && |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
643 !( TY_XDS_new[ 3 ][ 1 ][ 3 ] & 0x20 ) ) |
10263 | 644 { |
645 return 0; | |
646 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
647 if ( TY_XDS_mode == 0 && TY_XDS_type == 2 && |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
648 ( TY_XDS_new[ 0 ][ 2 ][ 4 ] & 0x3f ) > 1 ) |
10263 | 649 { |
650 return 0; | |
651 } | |
652 | |
653 mp_msg( MSGT_DEMUX, MSGL_DBG3, "%% %s ", TY_XDS_modes[ TY_XDS_mode ] ); | |
654 | |
655 line[ 0 ] = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
656 // printf( "XDS Code %x\n", |
10263 | 657 // ( TY_XDS_mode << 9 ) + TY_XDS_type + 0x100 ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
658 switch ( ( TY_XDS_mode << 9 ) + TY_XDS_type + 0x100 ) |
10263 | 659 { |
660 // cases are specified in 2 bytes hex representing mode, type. | |
661 // TY_XDS_ptr will point to the current class buffer | |
662 case 0x0101: // current | |
663 case 0x0301: // future | |
664 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
665 char *mon[] = |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
666 { |
10263 | 667 "0", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", |
668 "Aug", "Sep", "Oct", "Nov", "Dec", "13", "14", "15" | |
669 }; | |
670 ty_AddXDSToDisplay( "AIR DATE: %s %2d %d:%02d:00", | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
671 mon[ TY_XDS_ptr[ 3 ] & 0x0f ], |
10263 | 672 TY_XDS_ptr[ 2 ] & 0x1f, |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
673 TY_XDS_ptr[ 1 ] & 0x1f, |
10263 | 674 TY_XDS_ptr[ 0 ] & 0x3f |
675 ); | |
676 | |
677 // Program is tape delayed | |
678 if ( TY_XDS_ptr[ 3 ] & 0x10 ) ty_AddXDSToDisplay( " TAPE" ); | |
679 } | |
680 break; | |
681 | |
682 case 0x0102: // current program length | |
683 case 0x0302: // future | |
684 { | |
685 ty_AddXDSToDisplay( | |
686 "DURATION: %d:%02d:%02d of %d:%02d:%02d", | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
687 TY_XDS_ptr[ 3 ] & 0x3f, |
10263 | 688 TY_XDS_ptr[ 2 ] & 0x3f, |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
689 TY_XDS_ptr[ 4 ] & 0x3f, |
10263 | 690 TY_XDS_ptr[ 1 ] & 0x3f, |
691 TY_XDS_ptr[ 0 ] & 0x3f, 0); | |
692 break; | |
693 } | |
694 | |
695 case 0x0103: // current program name | |
696 case 0x0303: // future | |
697 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
698 ty_AddXDSToDisplay( "TITLE: %s", TY_XDS_ptr ); |
10263 | 699 break; |
700 } | |
701 | |
702 case 0x0104: // current program type | |
703 case 0x0304: // future | |
704 { | |
705 // for now just print out the raw data | |
706 // requires a 127 string array to parse | |
707 // properly and isn't worth it. | |
708 sprintf ( line, "%sGENRE:", line ); | |
709 { | |
710 int x; | |
711 for ( x = 0 ; x < TY_XDS_length ; x++ ) | |
712 sprintf( line, "%s %02x", line, TY_XDS_ptr[ x ] ); | |
713 } | |
714 ty_AddXDSToDisplay( line ); | |
715 break; | |
716 } | |
717 | |
718 case 0x0105: // current program rating | |
719 case 0x0305: // future | |
720 { | |
721 sprintf( line, "%sRATING: %s", line, | |
722 TY_XDS_CHIP[ ( TY_XDS_ptr[ 0 ] & 0x08 ) >> 3 ] | |
723 [ TY_XDS_ptr[ 1 ] & 0x07 ] ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
724 if ( TY_XDS_ptr[ 0 ] & 0x20 ) |
10263 | 725 sprintf( line, "%s DIALOGUE", line ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
726 if ( TY_XDS_ptr[ 1 ] & 0x08 ) |
10263 | 727 sprintf( line, "%s LANGUAGE", line ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
728 if ( TY_XDS_ptr[ 1 ] & 0x10 ) |
10263 | 729 sprintf( line, "%s SEXUAL", line ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
730 if ( TY_XDS_ptr[ 1 ] & 0x20 ) |
10263 | 731 sprintf( line, "%s VIOLENCE", line ); |
732 ty_AddXDSToDisplay( line ); | |
733 | |
734 // raw output for verification. | |
735 if ( TY_OSD_debug > 1 ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
736 mp_msg( MSGT_DEMUX, MSGL_DBG3, " (%02x %02x)", |
10263 | 737 TY_XDS_ptr[ 0 ], TY_XDS_ptr[ 1 ] ); |
738 break; | |
739 } | |
740 | |
741 case 0x0106: // current program audio services | |
742 case 0x0306: // future | |
743 { | |
744 // requires table, never actually seen it used either | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
745 ty_AddXDSToDisplay( "AUDIO: %02x %02x", TY_XDS_ptr[ 0 ], |
10263 | 746 TY_XDS_ptr[ 1 ] ); |
747 break; | |
748 } | |
749 | |
750 case 0x0109: // current program aspect ratio | |
751 case 0x0309: // future | |
752 { | |
753 // requires table, rare | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
754 ty_AddXDSToDisplay( "ASPECT: %02x %02x", |
10263 | 755 TY_XDS_ptr[ 0 ], TY_XDS_ptr[ 1 ] ); |
756 break; | |
757 } | |
758 | |
23914 | 759 case 0x0110: // program description |
760 case 0x0111: | |
761 case 0x0112: | |
762 case 0x0113: | |
763 case 0x0114: | |
764 case 0x0115: | |
765 case 0x0116: | |
766 case 0x0117: | |
10263 | 767 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
768 ty_AddXDSToDisplay( "DESCRIP: %s", TY_XDS_ptr ); |
10263 | 769 break; |
770 } | |
771 | |
772 case 0x0501: // channel network name | |
773 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
774 ty_AddXDSToDisplay( "NETWORK: %s", TY_XDS_ptr ); |
10263 | 775 break; |
776 } | |
777 | |
778 case 0x0502: // channel network call letters | |
779 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
780 ty_AddXDSToDisplay( "CALLSIGN: %s", TY_XDS_ptr ); |
10263 | 781 break; |
782 } | |
783 | |
784 case 0x0701: // misc. time of day | |
785 { | |
786 #define TIMEZONE ( TY_XDS[ 3 ][ 4 ][ 0 ] & 0x1f ) | |
787 #define DST ( ( TY_XDS[ 3 ][ 4 ][ 0 ] & 0x20 ) >> 5 ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
788 struct tm tm = |
10263 | 789 { |
10858 | 790 .tm_sec = 0, // sec |
791 .tm_min = ( TY_XDS_ptr[ 0 ] & 0x3F ), // min | |
792 .tm_hour = ( TY_XDS_ptr[ 1 ] & 0x1F ), // hour | |
793 .tm_mday = ( TY_XDS_ptr[ 2 ] & 0x1F ), // day | |
794 .tm_mon = ( TY_XDS_ptr[ 3 ] & 0x1f ) - 1, // month | |
795 .tm_year = ( TY_XDS_ptr[ 5 ] & 0x3f ) + 90, // year | |
796 .tm_wday = 0, // day of week | |
797 .tm_yday = 0, // day of year | |
798 .tm_isdst = 0, // DST | |
10263 | 799 }; |
800 | |
801 time_t time_t = mktime( &tm ); | |
802 char *timestr; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
803 |
10263 | 804 time_t -= ( ( TIMEZONE - DST ) * 60 * 60 ); |
805 timestr = ctime( &time_t ); | |
806 timestr[ strlen( timestr ) - 1 ] = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
807 |
10263 | 808 sprintf( line, "%sCUR.TIME: %s ", line, timestr ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
809 if ( TY_XDS[ 3 ][ 4 ][ 0 ] ) |
10263 | 810 { |
811 sprintf( line, "%sUTC-%d", line, TIMEZONE ); | |
812 if (DST) sprintf( line, "%s DST", line ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
813 } |
10263 | 814 else |
815 sprintf( line, "%sUTC", line ); | |
816 | |
817 ty_AddXDSToDisplay( line ); | |
818 | |
819 break; | |
820 } | |
821 | |
822 case 0x0704: //misc. local time zone | |
823 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
824 sprintf( line, "%sTIMEZONE: UTC-%d", |
10263 | 825 line, TY_XDS_ptr[ 0 ] & 0x1f ); |
826 if ( TY_XDS_ptr[ 0 ] & 0x20 ) sprintf( line, "%s DST", line ); | |
827 ty_AddXDSToDisplay( line ); | |
828 break; | |
829 } | |
830 | |
831 default: | |
832 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
833 mp_msg( MSGT_DEMUX, MSGL_DBG3, "UNKNOWN CLASS %d TYPE %d", |
10263 | 834 ( TY_XDS_mode << 1 ) + 1, TY_XDS_type ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
835 if ( TY_OSD_debug > 1 ) |
10263 | 836 { |
837 int x; | |
838 mp_msg( MSGT_DEMUX, MSGL_DBG3, "\nDUMP:\n" ); | |
839 for ( x = 0 ; x < TY_XDS_length ; x++ ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
840 mp_msg( MSGT_DEMUX, MSGL_DBG3, " %02x %c", |
10263 | 841 TY_XDS_ptr[ x ], TY_XDS_ptr[ x ] ); |
842 mp_msg( MSGT_DEMUX, MSGL_DBG3, "\n" ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
843 } |
10263 | 844 } |
845 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
846 if ( TY_OSD_debug > 1 ) |
10263 | 847 mp_msg( MSGT_DEMUX, MSGL_DBG3, " (%d)", TY_XDS_length ); |
848 } | |
849 TY_XDS_mode = 0; | |
850 TY_XDS_type = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
851 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27692
diff
changeset
|
852 else if ( TY_XDS_length < 34 ) |
10263 | 853 { |
854 TY_XDS_new[ TY_XDS_mode ][ TY_XDS_type ][ TY_XDS_length++ ] = b1; | |
855 TY_XDS_new[ TY_XDS_mode ][ TY_XDS_type ][ TY_XDS_length++ ] = b2; | |
856 } | |
857 return 0; | |
858 } | |
859 | |
860 | |
861 // =========================================================================== | |
862 // Callback from Video Display Processing to put up the OSD | |
863 // =========================================================================== | |
32567
2546de3e5afe
Mark input buffer that is never modified as const.
reimar
parents:
32467
diff
changeset
|
864 void ty_processuserdata( const unsigned char* buf, int len ) |
10263 | 865 { |
866 int index; | |
867 | |
868 sub_justify = 1; | |
869 | |
870 if ( subcc_enabled ) | |
871 { | |
25962 | 872 if ( tyOSDInitialized == 0 ) |
10263 | 873 { |
874 for ( index = 0; index < SUB_MAX_TEXT ; index++ ) | |
875 { | |
876 ty_OSD1.text[ index ] = malloc( TY_CC_MAX_X ); | |
877 ty_OSD2.text[ index ] = malloc( TY_CC_MAX_X ); | |
878 } | |
879 ty_ClearOSD( 0 ); | |
880 ty_OSD1.lines = SUB_MAX_TEXT; | |
881 ty_OSD2.lines = SUB_MAX_TEXT; | |
882 ty_pOSD1 = &ty_OSD1; | |
883 ty_pOSD2 = &ty_OSD2; | |
884 tyOSDUpdate = 0; | |
25962 | 885 tyOSDInitialized = 1; |
10263 | 886 } |
887 | |
888 if ( buf[ 0 ] == 0x01 ) | |
889 { | |
890 ty_CCdecode( buf[ 1 ], buf[ 2 ] ); | |
891 } | |
892 if ( buf[ 0 ] == 0x02 ) | |
893 { | |
894 ty_XDSdecode( buf[ 1 ], buf[ 2 ] ); | |
895 } | |
896 | |
897 ty_DisplayXDSInfo(); | |
898 | |
899 if ( tyOSDUpdate ) | |
900 { | |
901 // for ( index = 0; index < SUB_MAX_TEXT ; index++ ) | |
902 // { | |
903 // printf( "OSD:%d:%s\n", index, ty_OSD1.text[ index ] ); | |
904 // } | |
905 vo_sub = &ty_OSD1; | |
906 vo_osd_changed( OSDTYPE_SUBTITLE ); | |
907 tyOSDUpdate = 0; | |
908 } | |
909 } | |
910 } |