Mercurial > mplayer.hg
changeset 2328:00f64d5858b8
Bad fix of libmpeg2 zooming
author | nick |
---|---|
date | Sun, 21 Oct 2001 07:02:40 +0000 |
parents | 2332ba356d03 |
children | fc52a0a1626f |
files | libvo/vo_vesa.c |
diffstat | 1 files changed, 42 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/vo_vesa.c Sun Oct 21 00:32:47 2001 +0000 +++ b/libvo/vo_vesa.c Sun Oct 21 07:02:40 2001 +0000 @@ -72,6 +72,8 @@ static int vesa_zoom=0; /* software scaling */ static unsigned int scale_xinc=0; static unsigned int scale_yinc=0; +static float aspect_factor; + static uint32_t image_width, image_height; /* source image dimension */ static uint32_t x_offset,y_offset; /* to center image on screen */ @@ -233,10 +235,36 @@ } } } + +static void __vbeCopySliceData(uint8_t *image,int x, int y, int w, int h) +{ + unsigned long i,j,image_offset,offset; + unsigned pixel_size,image_line_size,screen_line_size,x_shift; + pixel_size = (video_mode_info.BitsPerPixel+7)/8; + screen_line_size = video_mode_info.XResolution*pixel_size; + image_line_size = w*pixel_size; +#if 0 + if(image_width == video_mode_info.XResolution && w == image_width) + { + /* Special case for zooming */ + __vbeCopyBlock((y_offset+y)*screen_line_size,image,image_line_size*image_height); + } + else +#endif + { + x_shift = (x_offset+x)*pixel_size; + for(j=0,i=y_offset+y;j<h;i++,j++) + { + offset = i*screen_line_size+x_shift; + image_offset = j*image_line_size; + __vbeCopyBlock(offset,&image[image_offset],image_line_size); + } + } +} + /* is called for yuv only */ static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) { - uint8_t *yuv_slice; if(vesa_zoom) { SwScale_YV12slice_brg24(image,stride,y,h, @@ -244,29 +272,22 @@ image_width*((video_mode_info.BitsPerPixel+7)/8), image_width, video_mode_info.BitsPerPixel, scale_xinc, scale_yinc); + if(y || x || w != image_width || h != image_height) + { + w = image_width; + h = image_height; + y = 0; + x = 0; + } } else { - yuv_slice=yuv_buffer+(image_width*y+x)*(video_mode_info.BitsPerPixel+7)/8; - yuv2rgb(yuv_slice, image[0], image[1], image[2], w, h, + yuv2rgb(yuv_buffer, image[0], image[1], image[2], w, h, image_width * ((video_mode_info.BitsPerPixel+7)/8), stride[0], stride[1]); } if(y || x || w != image_width || h != image_height) - { - unsigned long i,j,image_offset,offset; - unsigned pixel_size,image_line_size,screen_line_size,x_shift; - pixel_size = (video_mode_info.BitsPerPixel+7)/8; - screen_line_size = video_mode_info.XResolution*pixel_size; - image_line_size = w*pixel_size; - x_shift = (x_offset+x)*pixel_size; - for(j=0,i=(y_offset+y);j<h;i++,j++) - { - offset = i*screen_line_size+x_shift; - image_offset = j*image_line_size; - __vbeCopyBlock(offset,&yuv_slice[image_offset],image_line_size); - } - } + __vbeCopySliceData((uint8_t*)yuv_buffer,x,y,w,h); else __vbeCopyData((uint8_t *)yuv_buffer); return 0; } @@ -321,15 +342,14 @@ uint32_t xres,uint32_t yres, uint32_t *image_width,uint32_t *image_height) { - float factor; - factor = (float)width / height; + aspect_factor = (float)width / height; *image_width = xres; - *image_height = xres / factor; - if(verbose) printf("vo_vesa: aspect factor = %f(%ux%u) *image=%ux%u screen=%ux%u\n",factor,width,height,*image_width,*image_height,xres,yres); + *image_height = xres /aspect_factor; + if(verbose) printf("vo_vesa: aspect factor = %f(%ux%u) *image=%ux%u screen=%ux%u\n",aspect_factor,width,height,*image_width,*image_height,xres,yres); if((*image_height) > yres) { *image_height = yres; - *image_width = yres * factor; + *image_width = yres * aspect_factor; if(verbose) printf("vo_vesa: Y > X tehrefore *image=%ux%u\n",*image_width,*image_height); } }