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