--- xv.orig Fri Jun 8 23:03:48 2001 +++ xv.zoom Fri Jun 8 23:15:01 2001 @@ -166,7 +166,7 @@ static int XVideoCheckForXv ( Display * ); static int XVideoGetPort ( Display * ); static void XVideoOutputCoords ( const picture_t *, const boolean_t, - const int, const int, + const int, const int, int *, int *, int *, int *, int *, int * ); /***************************************************************************** @@ -430,6 +430,14 @@ case '9': network_ChannelJoin( 9 ); break; + case 'z': + main_PutIntVariable("vlc_zoom" /*XXX*/, + main_GetIntVariable("vlc_zoom" /*XXX*/,100)-10); + break; + case 'Z': + main_PutIntVariable("vlc_zoom" /*XXX*/, + main_GetIntVariable("vlc_zoom" /*XXX*/,100)+10); + break; default: if( intf_ProcessKey( p_main->p_intf, (char )i_key ) ) @@ -596,19 +604,20 @@ { int i_dest_width, i_dest_height, i_dest_x, i_dest_y; + int i_sx, i_sy; if( !p_vout->p_sys->p_xvimage[p_vout->i_pic_idx] ) return; XVideoOutputCoords( p_rendered_pic, p_vout->b_scale, p_vout->p_sys->i_window_width, p_vout->p_sys->i_window_height, - &i_dest_x, &i_dest_y, + &i_dest_x, &i_dest_y, &i_sx, &i_sy, &i_dest_width, &i_dest_height); XvShmPutImage( p_vout->p_sys->p_display, p_vout->p_sys->xv_port, p_vout->p_sys->yuv_window, p_vout->p_sys->gc, p_vout->p_sys->p_xvimage[p_vout->i_pic_idx], - 0 /*src_x*/, 0 /*src_y*/, + i_sx /*src_x*/, i_sy /*src_y*/, p_rendered_pic->i_width, p_rendered_pic->i_height, 0 /*dest_x*/, 0 /*dest_y*/, i_dest_width, i_dest_height, @@ -617,6 +626,7 @@ XMoveResizeWindow( p_vout->p_sys->p_display, p_vout->p_sys->yuv_window, i_dest_x, i_dest_y, i_dest_width, i_dest_height ); } + } static void vout_SetPalette( p_vout_thread_t p_vout, @@ -1040,67 +1050,63 @@ } } -/* This is based on some code in SetBufferPicture... +/* This was based on some code in SetBufferPicture... * XXX should be using a common function. */ -static void XVideoOutputCoords( const picture_t *p_pic, const boolean_t scale, - const int win_w, const int win_h, - int *dx, int *dy, int *w, int *h) +static void MyScaleFn( const int i_image_size, const int i_win_size, + const float scale, + int *i_src_offset, int *i_dest_offset, int *i_out_size) { - if( !scale ) + const int i_scaled_image_size = scale * i_image_size; + + if( i_scaled_image_size <= i_win_size ) { - *w = p_pic->i_width; *h = p_pic->i_height; + *i_src_offset = 0; + *i_dest_offset = (i_win_size - i_scaled_image_size) / 2; } else { - *w = win_w; - switch( p_pic->i_aspect_ratio ) - { - case AR_3_4_PICTURE: - *h = win_w * 3 / 4; - break; - - case AR_16_9_PICTURE: - *h = win_w * 9 / 16; - break; - - case AR_221_1_PICTURE: - *h = win_w * 100 / 221; - break; - - case AR_SQUARE_PICTURE: - default: - *h = win_w * p_pic->i_height / p_pic->i_width; - break; - } - - if( *h > win_h ) - { - *h = win_h; - switch( p_pic->i_aspect_ratio ) - { - case AR_3_4_PICTURE: - *w = win_h * 4 / 3; - break; + *i_src_offset = (i_image_size - (i_win_size/scale)) / 2; + *i_dest_offset = 0; + } +/* *i_out_size = i_win_size - (2 * *i_dest_offset); */ + *i_out_size = i_scaled_image_size; /*note: may be bigger than window size*/ - case AR_16_9_PICTURE: - *w = win_h * 16 / 9; - break; +} - case AR_221_1_PICTURE: - *w = win_h * 221 / 100; - break; +static void XVideoOutputCoords( const picture_t *p_pic, const boolean_t scale, + const int win_w, const int win_h, + int *dx, int *dy, int *sx, int *sy, + int *w, int *h) +{ + float aspect_ratio; /* Y/X */ + float scale_x, scale_y; + float zoom = main_GetIntVariable( "vlc_zoom" /*VOUT_ZOOM*/, 100 ) / 100.; + + switch( p_pic->i_aspect_ratio ) + { + case AR_3_4_PICTURE: aspect_ratio = 3./4; break; + case AR_16_9_PICTURE: aspect_ratio = 9./16; break; + case AR_221_1_PICTURE: aspect_ratio = 100./221; break; + case AR_SQUARE_PICTURE: + default: + aspect_ratio = (float)p_pic->i_height / p_pic->i_width; + break; + } - case AR_SQUARE_PICTURE: - default: - *w = win_h * p_pic->i_width / p_pic->i_height; - break; - } - } + if( win_h < aspect_ratio * win_w ) + /* if display area is "longer" than required */ + { + scale_y = (float)win_h / p_pic->i_height; + scale_x = (float)(win_h / aspect_ratio) / p_pic->i_width; + } + else + { + scale_x = (float)win_w / p_pic->i_width; + scale_y = (float)(win_w * aspect_ratio) / p_pic->i_height; } - /* Set picture position */ - *dx = (win_w - *w) / 2; - *dy = (win_h - *h) / 2; + MyScaleFn( p_pic->i_width, win_w, scale_x * zoom, sx, dx, w); + MyScaleFn( p_pic->i_height, win_h, scale_y * zoom, sy, dy, h); }