1 diff -urNp ./src/commands.c ../tvtime-1.0.1-savematte/src/commands.c
2 --- ./src/commands.c 2005-09-08 03:31:48.000000000 +0100
3 +++ ../tvtime-1.0.1-savematte/src/commands.c 2007-01-12 18:24:15.000000000 +0000
4 @@ -128,6 +128,7 @@ struct commands_s {
5 int togglepulldowndetection;
12 @@ -2897,7 +2898,7 @@ void commands_handle( commands_t *cmd, i
13 case TVTIME_OVERSCAN_DOWN:
14 cmd->overscan = cmd->overscan + ( (tvtime_cmd == TVTIME_OVERSCAN_UP) ? 0.0025 : -0.0025 );
15 if( cmd->overscan > 0.4 ) cmd->overscan = 0.4; if( cmd->overscan < 0.0 ) cmd->overscan = 0.0;
17 + cmd->changedoverscan = 1;
20 snprintf( message, sizeof( message ), _("Overscan: %.1f%%"),
21 @@ -3489,6 +3490,7 @@ void commands_next_frame( commands_t *cm
22 cmd->togglepulldowndetection = 0;
25 + cmd->changedoverscan = 0;
26 cmd->resizewindow = 0;
27 cmd->setdeinterlacer = 0;
28 cmd->setfreqtable = 0;
29 @@ -3536,6 +3538,11 @@ int commands_toggle_aspect( commands_t *
30 return cmd->toggleaspect;
33 +int commands_get_changed_overscan( commands_t *cmd )
35 + return cmd->changedoverscan;
38 int commands_toggle_alwaysontop( commands_t *cmd )
40 return cmd->togglealwaysontop;
41 diff -urNp ./src/commands.h ../tvtime-1.0.1-savematte/src/commands.h
42 --- ./src/commands.h 2004-10-28 01:50:24.000000000 +0100
43 +++ ../tvtime-1.0.1-savematte/src/commands.h 2007-01-12 18:24:15.000000000 +0000
44 @@ -64,6 +64,7 @@ void commands_set_pulldown_alg( commands
45 int commands_quit( commands_t *cmd );
46 int commands_toggle_fullscreen( commands_t *cmd );
47 int commands_toggle_aspect( commands_t *cmd );
48 +int commands_get_changed_overscan( commands_t *cmd );
49 int commands_toggle_deinterlacer( commands_t *cmd );
50 int commands_toggle_pulldown_detection( commands_t *cmd );
51 int commands_toggle_matte( commands_t *cmd );
52 diff -urNp ./src/tvtime.c ../tvtime-1.0.1-savematte/src/tvtime.c
53 --- ./src/tvtime.c 2005-09-08 03:55:54.000000000 +0100
54 +++ ../tvtime-1.0.1-savematte/src/tvtime.c 2007-01-12 18:29:25.000000000 +0000
55 @@ -1062,84 +1062,55 @@ static void build_matte_menu( menu_t *me
58 menu_set_back_command( menu, TVTIME_SHOW_MENU, "output" );
60 - snprintf( string, sizeof( string ), (mode == 0) ?
61 - TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
62 - _("16:9 + Overscan") );
63 - menu_set_text( menu, 1, string );
64 - menu_set_enter_command( menu, 1, TVTIME_SET_MATTE, "16:9" );
65 - snprintf( string, sizeof( string ), (mode == 1) ?
66 - TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
68 - menu_set_text( menu, 2, string );
69 - menu_set_enter_command( menu, 2, TVTIME_SET_MATTE, "1.85:1" );
70 - snprintf( string, sizeof( string ), (mode == 2) ?
71 - TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
73 - menu_set_text( menu, 3, string );
74 - menu_set_enter_command( menu, 3, TVTIME_SET_MATTE, "2.35:1" );
75 - snprintf( string, sizeof( string ), (mode == 3) ?
76 - TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
78 - menu_set_text( menu, 4, string );
79 - menu_set_enter_command( menu, 4, TVTIME_SET_MATTE, "4:3" );
80 - snprintf( string, sizeof( string ), (mode == 4) ?
81 - TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
83 - menu_set_text( menu, 5, string );
84 - menu_set_enter_command( menu, 5, TVTIME_SET_MATTE, "16:10" );
86 - snprintf( string, sizeof( string ), (mode == 0) ?
87 - TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
88 - _("4:3 + Overscan") );
89 - menu_set_text( menu, 1, string );
90 - menu_set_enter_command( menu, 1, TVTIME_SET_MATTE, "4:3" );
91 - snprintf( string, sizeof( string ), (mode == 1) ?
92 - TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
94 - menu_set_text( menu, 2, string );
95 - menu_set_enter_command( menu, 2, TVTIME_SET_MATTE, "16:9" );
96 - snprintf( string, sizeof( string ), (mode == 2) ?
97 - TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
99 - menu_set_text( menu, 3, string );
100 - menu_set_enter_command( menu, 3, TVTIME_SET_MATTE, "16:10" );
101 - snprintf( string, sizeof( string ), (mode == 3) ?
102 - TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
104 - menu_set_text( menu, 4, string );
105 - menu_set_enter_command( menu, 4, TVTIME_SET_MATTE, "1.85:1" );
106 - snprintf( string, sizeof( string ), (mode == 4) ?
107 - TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
109 - menu_set_text( menu, 5, string );
110 - menu_set_enter_command( menu, 5, TVTIME_SET_MATTE, "2.35:1" );
113 + snprintf( string, sizeof( string ), (mode == 0) ?
114 + TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
116 + menu_set_text( menu, 1, string );
117 + menu_set_enter_command( menu, 1, TVTIME_SET_MATTE, "4:3" );
118 + snprintf( string, sizeof( string ), (mode == 1) ?
119 + TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
121 + menu_set_text( menu, 2, string );
122 + menu_set_enter_command( menu, 2, TVTIME_SET_MATTE, "16:10" );
123 + snprintf( string, sizeof( string ), (mode == 2) ?
124 + TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
126 + menu_set_text( menu, 3, string );
127 + menu_set_enter_command( menu, 3, TVTIME_SET_MATTE, "16:9" );
128 + snprintf( string, sizeof( string ), (mode == 3) ?
129 + TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
131 + menu_set_text( menu, 4, string );
132 + menu_set_enter_command( menu, 4, TVTIME_SET_MATTE, "1.85:1" );
133 + snprintf( string, sizeof( string ), (mode == 4) ?
134 + TVTIME_ICON_RADIOON " %s" : TVTIME_ICON_RADIOOFF " %s",
136 + menu_set_text( menu, 5, string );
137 + menu_set_enter_command( menu, 5, TVTIME_SET_MATTE, "2.35:1" );
140 snprintf( string, sizeof( string ), TVTIME_ICON_PLAINLEFTARROW " %s",
142 menu_set_text( menu, 6, string );
143 menu_set_enter_command( menu, 6, TVTIME_SHOW_MENU, "output" );
147 static void osd_list_matte( tvtime_osd_t *osd, int mode, int sixteennine )
149 tvtime_osd_list_set_lines( osd, 6 );
151 tvtime_osd_list_set_text( osd, 0, _("Matte setting (Anamorphic input)") );
152 - tvtime_osd_list_set_text( osd, 1, _("16:9 + Overscan") );
153 - tvtime_osd_list_set_text( osd, 2, "1.85:1" );
154 - tvtime_osd_list_set_text( osd, 3, "2.35:1" );
155 - tvtime_osd_list_set_text( osd, 4, _("4:3 centre") );
156 - tvtime_osd_list_set_text( osd, 5, "16:10" );
159 tvtime_osd_list_set_text( osd, 0, _("Matte setting (4:3 input)") );
160 - tvtime_osd_list_set_text( osd, 1, _("4:3 + Overscan") );
161 - tvtime_osd_list_set_text( osd, 2, "16:9" );
162 - tvtime_osd_list_set_text( osd, 3, "16:10" );
163 - tvtime_osd_list_set_text( osd, 4, "1.85:1" );
164 - tvtime_osd_list_set_text( osd, 5, "2.35:1" );
166 + tvtime_osd_list_set_text( osd, 1, "4:3" );
167 + tvtime_osd_list_set_text( osd, 2, "16:10" );
168 + tvtime_osd_list_set_text( osd, 3, "16:9" );
169 + tvtime_osd_list_set_text( osd, 4, "1.85:1" );
170 + tvtime_osd_list_set_text( osd, 5, "2.35:1" );
172 tvtime_osd_list_set_hilight( osd, mode + 1 );
173 tvtime_osd_show_list( osd, 1, 0 );
175 @@ -1204,6 +1175,7 @@ int tvtime_main( rtctimer_t *rtctimer, i
179 + int matte_changed = 0;
180 int restarttvtime = 0;
181 int return_value = 0;
182 int last_current_id = -1;
183 @@ -1241,6 +1213,7 @@ int tvtime_main( rtctimer_t *rtctimer, i
184 output = get_xv_output();
186 sixteennine = config_get_aspect( ct );
187 + matte_mode = config_get_matte( ct );
189 if( !output || !output->init( config_get_geometry( ct ),
190 sixteennine, config_get_square_pixels( ct ),
191 @@ -1594,6 +1567,15 @@ int tvtime_main( rtctimer_t *rtctimer, i
192 build_fspos_menu( commands_get_menu( commands, "fspos" ),
193 config_get_fullscreen_position( ct ) );
196 + double matte = 4.0/3.0;
198 + /* initialize with safe values until matte is calculated later in the loop. */
204 /* Initialize our timestamps. */
206 const char *fifo_args = 0;
207 @@ -1607,31 +1589,19 @@ int tvtime_main( rtctimer_t *rtctimer, i
208 int exposed = output->is_exposed();
212 if( vidin && videoinput_has_tuner( vidin ) ) {
213 current_id = station_get_current_id( stationmgr );
219 + /* Since the matte/overscan calculations changed these could probably
220 + be the same variables, but we'll leave it like this for now. */
226 - output_x = (int) ((((double) width) *
227 - commands_get_overscan( commands )) + 0.5);
228 - output_w = (int) ((((double) width) -
229 - (((double) width) *
230 - commands_get_overscan( commands ) * 2.0)) +
232 - output_y = (int) ((((double) height) *
233 - commands_get_overscan( commands )) + 0.5);
234 - output_h = (int) ((((double) height) -
235 - (((double) height) *
236 - commands_get_overscan( commands ) * 2.0)) +
243 @@ -1766,11 +1736,14 @@ int tvtime_main( rtctimer_t *rtctimer, i
245 commands_refresh_menu( commands );
249 if( commands_toggle_aspect( commands ) ) {
251 - output->set_matte( 0, 0 );
252 if( output->toggle_aspect() ) {
254 + /* Matte is now always applied so we change it to 16:9 mode too so that
255 + nothing other than overscan is cropped. */
258 tvtime_osd_show_message( osd,
259 _("16:9 display mode active.") );
260 @@ -1780,6 +1753,7 @@ int tvtime_main( rtctimer_t *rtctimer, i
261 ( ( (double) height ) * (16.0 / 9.0) );
266 tvtime_osd_show_message( osd,
267 _("4:3 display mode active.") );
268 @@ -1800,9 +1774,7 @@ int tvtime_main( rtctimer_t *rtctimer, i
269 output->is_alwaysontop_supported(),
270 output->is_overscan_supported(),
272 - build_matte_menu( commands_get_menu( commands, "matte" ),
273 - matte_mode, sixteennine );
274 - commands_refresh_menu( commands );
277 if( commands_get_fs_pos( commands ) ) {
278 const char *fspos = commands_get_fs_pos( commands );
279 @@ -1839,84 +1811,92 @@ int tvtime_main( rtctimer_t *rtctimer, i
281 commands_refresh_menu( commands );
284 + /* Overscan has been changed so it is calculated and applied with the matte.
285 + So changing it now generated this event so that we can tell it to redo the matte. */
286 + if( commands_get_changed_overscan( commands ) ) {
289 if( commands_toggle_matte( commands ) ||
290 commands_get_matte_mode( commands ) ) {
291 - double matte = 4.0 / 3.0;
292 - int sqwidth = sixteennine ?
293 - ((height * 16) / 9) : ((height * 4) / 3);
294 - int sqheight = sixteennine ?
295 - ((width * 9) / 16) : ((width * 3) / 4);
299 if( commands_toggle_matte( commands ) ) {
300 matte_mode = (matte_mode + 1) % 5;
302 - if( !strcmp( commands_get_matte_mode( commands ), "16:9" ) ) {
303 - matte_mode = sixteennine ? 0 : 1;
304 - } else if( !strcmp( commands_get_matte_mode( commands ),
306 - matte_mode = sixteennine ? 4 : 2;
307 + if( !strcmp( commands_get_matte_mode( commands ), "16:10" ) ) {
309 + } else if( !strcmp( commands_get_matte_mode( commands ),
312 } else if( !strcmp( commands_get_matte_mode( commands ),
314 - matte_mode = sixteennine ? 1 : 3;
316 } else if( !strcmp( commands_get_matte_mode( commands ),
318 - matte_mode = sixteennine ? 2 : 4;
321 - matte_mode = sixteennine ? 3 : 0;
326 - if( sixteennine ) {
327 - if( matte_mode == 0 ) {
328 - matte = 16.0 / 9.0;
329 - } else if( matte_mode == 1 ) {
331 - } else if( matte_mode == 2 ) {
333 - } else if( matte_mode == 3 ) {
335 - matte_w = (int) (((double) sqheight * matte) + 0.5);
336 - matte_x = (width - matte_w) / 2;
337 - /* We're cropping the sides off so we add overscan to avoid mess
338 - * at the top of the screen. */
339 - matte_y = commands_get_overscan( commands ) * height / 2;
340 - matte_h = height - matte_y;
341 - output->set_matte( (matte_h * 4) / 3, matte_h );
342 - } else if( matte_mode == 4 ) {
344 - matte_w = (int) (((double) sqheight * matte) + 0.5);
345 - matte_x = (width - matte_w) / 2;
346 - /* We're cropping the sides off so we add overscan to avoid mess
347 - * at the top of the screen. */
348 - matte_y = commands_get_overscan( commands ) * height / 2;
349 - matte_h = height - matte_y;
350 - output->set_matte( (matte_h * 16) / 10, matte_h );
353 - if( matte_mode == 1 ) {
354 - matte = 16.0 / 9.0;
355 - } else if( matte_mode == 2 ) {
357 - } else if( matte_mode == 3 ) {
359 - } else if( matte_mode == 4 ) {
364 - matte_h = (int) ((((double) sqwidth)/matte) + 0.5);
365 - matte_y = (height - matte_h) / 2;
366 - output->set_matte( sqwidth, matte_h );
368 if( osd && !commands_menu_active( commands ) ) {
369 osd_list_matte( osd, matte_mode, sixteennine );
371 build_matte_menu( commands_get_menu( commands, "matte" ),
372 matte_mode, sixteennine );
373 commands_refresh_menu( commands );
376 + if (matte_changed) {
379 + /* start with overscan then apply matte */
380 + matte_x = (int) ((((double) width) *
381 + commands_get_overscan( commands )) + 0.5);
382 + matte_w = (int) ((((double) width) -
383 + (((double) width) *
384 + commands_get_overscan( commands ) * 2.0)) +
386 + matte_y = (int) ((((double) height) *
387 + commands_get_overscan( commands )) + 0.5);
388 + matte_h = (int) ((((double) height) -
389 + (((double) height) *
390 + commands_get_overscan( commands ) * 2.0)) +
393 + int sqwidth = sixteennine ?
394 + ((matte_h * 16) / 9) : ((matte_h * 4) / 3);
395 + int sqheight = sixteennine ?
396 + ((matte_w * 9) / 16) : ((matte_w * 3) / 4);
398 + if( matte_mode == 0 ) {
400 + config_save( ct, "Matte", "4:3" );
401 + } else if( matte_mode == 1 ) {
403 + config_save( ct, "Matte", "16:10" );
404 + } else if( matte_mode == 2 ) {
406 + config_save( ct, "Matte", "16:9" );
407 + } else if( matte_mode == 3 ) {
409 + config_save( ct, "Matte", "1.85:1" );
410 + } else if( matte_mode == 4 ) {
412 + config_save( ct, "Matte", "2.35:1" );
415 + if( sixteennine && matte < (16.0/9.0) )
417 + matte_w = (int) (((double) sqheight * matte) + 0.5);
418 + matte_x = (width - matte_w) / 2;
419 + output->set_matte( matte_w, sqheight );
421 + matte_h = (int) ((((double) sqwidth)/matte) + 0.5);
422 + matte_y = (height - matte_h) / 2;
423 + output->set_matte( sqwidth, matte_h );
427 if( commands_toggle_pulldown_detection( commands ) ) {
428 if( height == 480 ) {
429 tvtime->pulldown_alg =
430 diff -urNp ./src/tvtimeconf.c ../tvtime-1.0.1-savematte/src/tvtimeconf.c
431 --- ./src/tvtimeconf.c 2005-09-08 05:07:56.000000000 +0100
432 +++ ../tvtime-1.0.1-savematte/src/tvtimeconf.c 2007-01-12 18:26:09.000000000 +0000
433 @@ -56,6 +56,7 @@ struct config_s
441 @@ -290,6 +291,22 @@ static void parse_option( config_t *ct,
442 ct->aspect = atoi( curval );
445 + if( !xmlStrcasecmp( name, BAD_CAST "Matte" ) ) {
446 + if(!strcmp( curval, "4:3")) {
448 + } else if(!strcmp( curval, "16:10")) {
450 + } else if(!strcmp( curval, "16:9")) {
452 + } else if(!strcmp( curval, "1.85:1")) {
454 + } else if(!strcmp( curval, "2.35:1")) {
457 + /* No valid matte if found ct->matte will be -1 and config_get_matte will choose
458 + a default based on the aspect ratio. */
461 if( !xmlStrcasecmp( name, BAD_CAST "DebugMode" ) ) {
462 ct->debug = atoi( curval );
464 @@ -712,6 +729,7 @@ config_t *config_new( void )
465 ct->geometry = strdup( "0x576" );
469 ct->squarepixels = 1;
472 @@ -807,6 +825,10 @@ config_t *config_new( void )
473 ct->keymap[ 'a' ] = TVTIME_TOGGLE_ASPECT;
474 ct->keymap[ 'f' ] = TVTIME_TOGGLE_FULLSCREEN;
475 ct->keymap[ 'i' ] = TVTIME_TOGGLE_INPUT;
476 + ct->keymap[ 'a' ] = TVTIME_TOGGLE_ASPECT;
477 + ct->keymap[ I_INSERT ] = TVTIME_TOGGLE_MATTE;
478 + ct->keymap[ ',' ] = TVTIME_OVERSCAN_DOWN;
479 + ct->keymap[ '.' ] = TVTIME_OVERSCAN_DOWN;
480 ct->keymap[ 's' ] = TVTIME_SCREENSHOT;
481 ct->keymap[ ',' ] = TVTIME_MIXER_TOGGLE_MUTE;
482 ct->keymap[ 'e' ] = TVTIME_TOGGLE_AUDIO_MODE;
483 @@ -1451,6 +1473,13 @@ int config_get_aspect( config_t *ct )
487 +int config_get_matte( config_t *ct )
489 + /* If matte is not set then default to 0 for normal or 2 for widescreen. */
490 + if (ct->matte == -1) return ct->aspect * 2;
494 int config_get_start_channel( config_t *ct )
496 return ct->start_channel;
497 diff -urNp ./src/tvtimeconf.h ../tvtime-1.0.1-savematte/src/tvtimeconf.h
498 --- ./src/tvtimeconf.h 2005-08-14 18:00:11.000000000 +0100
499 +++ ../tvtime-1.0.1-savematte/src/tvtimeconf.h 2007-01-12 18:24:15.000000000 +0000
500 @@ -151,6 +151,7 @@ int config_get_debug( config_t *ct );
501 const char *config_get_geometry( config_t *ct );
502 int config_get_inputwidth( config_t *ct );
503 int config_get_aspect( config_t *ct );
504 +int config_get_matte( config_t *ct );
505 int config_get_inputnum( config_t *ct );
506 const char *config_get_v4l_device( config_t *ct );
507 const char *config_get_v4l_norm( config_t *ct );
508 diff -urNp ./src/videoinput.c ../tvtime-1.0.1-savematte/src/videoinput.c
509 --- ./src/videoinput.c 2005-09-08 04:13:37.000000000 +0100
510 +++ ../tvtime-1.0.1-savematte/src/videoinput.c 2007-01-12 18:24:15.000000000 +0000
511 @@ -376,6 +376,7 @@ uint8_t *videoinput_next_frame( videoinp
513 wait_for_frame_v4l2( vidin );
515 + videoinput_get_aspect( vidin );
516 cur_buf.type = vidin->capbuffers[ 0 ].vidbuf.type;
517 if( ioctl( vidin->grab_fd, VIDIOC_DQBUF, &cur_buf ) < 0 ) {
518 /* some drivers return EIO when there is no signal */
519 @@ -1148,6 +1149,22 @@ void videoinput_set_saturation_relative(
523 +float videoinput_get_aspect( videoinput_t *vidin )
525 + float aspect = 1.0;
527 + if( vidin->isv4l2 ) {
528 + struct v4l2_cropcap cropcap;
529 + /* on success 0 is returned */
530 + if( !ioctl( vidin->grab_fd, VIDIOC_CROPCAP, &cropcap ) ) {
531 + aspect = (float)cropcap.pixelaspect.numerator / (float)cropcap.pixelaspect.denominator;
532 + fprintf( stderr, "videoinput: Aspect ratio: %f\n", aspect);
539 static void videoinput_do_mute( videoinput_t *vidin, int mute )
541 if( vidin->hasaudio && mute != vidin->hw_muted ) {
542 diff -urNp ./src/videoinput.h ../tvtime-1.0.1-savematte/src/videoinput.h
543 --- ./src/videoinput.h 2005-09-08 03:55:10.000000000 +0100
544 +++ ../tvtime-1.0.1-savematte/src/videoinput.h 2007-01-12 18:24:15.000000000 +0000
545 @@ -71,6 +71,8 @@ typedef struct videoinput_s videoinput_t
546 #define VIDEOINPUT_LANG1 4
547 #define VIDEOINPUT_LANG2 8
549 +float videoinput_get_aspect( videoinput_t *vidin );
552 * Possible PAL audio modes, for the cx88 driver that cannot autodetect.
554 diff -urNp ./src/xvoutput.c ../tvtime-1.0.1-savematte/src/xvoutput.c
555 --- ./src/xvoutput.c 2005-08-14 18:35:50.000000000 +0100
556 +++ ../tvtime-1.0.1-savematte/src/xvoutput.c 2007-01-12 18:24:15.000000000 +0000
557 @@ -233,7 +233,7 @@ static int xv_alloc_frame( void )
563 size = input_width * input_height * 2;
565 alloc = create_shm( size );