comparison libvo/vo_vesa.c @ 2328:00f64d5858b8

Bad fix of libmpeg2 zooming
author nick
date Sun, 21 Oct 2001 07:02:40 +0000
parents ce35271bdb10
children fc52a0a1626f
comparison
equal deleted inserted replaced
2327:2332ba356d03 2328:00f64d5858b8
70 }; 70 };
71 71
72 static int vesa_zoom=0; /* software scaling */ 72 static int vesa_zoom=0; /* software scaling */
73 static unsigned int scale_xinc=0; 73 static unsigned int scale_xinc=0;
74 static unsigned int scale_yinc=0; 74 static unsigned int scale_yinc=0;
75 static float aspect_factor;
76
75 77
76 static uint32_t image_width, image_height; /* source image dimension */ 78 static uint32_t image_width, image_height; /* source image dimension */
77 static uint32_t x_offset,y_offset; /* to center image on screen */ 79 static uint32_t x_offset,y_offset; /* to center image on screen */
78 static unsigned init_mode; /* mode before run of mplayer */ 80 static unsigned init_mode; /* mode before run of mplayer */
79 static void *init_state = NULL; /* state before run of mplayer */ 81 static void *init_state = NULL; /* state before run of mplayer */
231 image_offset = j*image_line_size; 233 image_offset = j*image_line_size;
232 __vbeCopyBlock(offset,&image[image_offset],image_line_size); 234 __vbeCopyBlock(offset,&image[image_offset],image_line_size);
233 } 235 }
234 } 236 }
235 } 237 }
238
239 static void __vbeCopySliceData(uint8_t *image,int x, int y, int w, int h)
240 {
241 unsigned long i,j,image_offset,offset;
242 unsigned pixel_size,image_line_size,screen_line_size,x_shift;
243 pixel_size = (video_mode_info.BitsPerPixel+7)/8;
244 screen_line_size = video_mode_info.XResolution*pixel_size;
245 image_line_size = w*pixel_size;
246 #if 0
247 if(image_width == video_mode_info.XResolution && w == image_width)
248 {
249 /* Special case for zooming */
250 __vbeCopyBlock((y_offset+y)*screen_line_size,image,image_line_size*image_height);
251 }
252 else
253 #endif
254 {
255 x_shift = (x_offset+x)*pixel_size;
256 for(j=0,i=y_offset+y;j<h;i++,j++)
257 {
258 offset = i*screen_line_size+x_shift;
259 image_offset = j*image_line_size;
260 __vbeCopyBlock(offset,&image[image_offset],image_line_size);
261 }
262 }
263 }
264
236 /* is called for yuv only */ 265 /* is called for yuv only */
237 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) 266 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
238 { 267 {
239 uint8_t *yuv_slice;
240 if(vesa_zoom) 268 if(vesa_zoom)
241 { 269 {
242 SwScale_YV12slice_brg24(image,stride,y,h, 270 SwScale_YV12slice_brg24(image,stride,y,h,
243 yuv_buffer, 271 yuv_buffer,
244 image_width*((video_mode_info.BitsPerPixel+7)/8), 272 image_width*((video_mode_info.BitsPerPixel+7)/8),
245 image_width, video_mode_info.BitsPerPixel, 273 image_width, video_mode_info.BitsPerPixel,
246 scale_xinc, scale_yinc); 274 scale_xinc, scale_yinc);
275 if(y || x || w != image_width || h != image_height)
276 {
277 w = image_width;
278 h = image_height;
279 y = 0;
280 x = 0;
281 }
247 } 282 }
248 else 283 else
249 { 284 {
250 yuv_slice=yuv_buffer+(image_width*y+x)*(video_mode_info.BitsPerPixel+7)/8; 285 yuv2rgb(yuv_buffer, image[0], image[1], image[2], w, h,
251 yuv2rgb(yuv_slice, image[0], image[1], image[2], w, h,
252 image_width * ((video_mode_info.BitsPerPixel+7)/8), 286 image_width * ((video_mode_info.BitsPerPixel+7)/8),
253 stride[0], stride[1]); 287 stride[0], stride[1]);
254 } 288 }
255 if(y || x || w != image_width || h != image_height) 289 if(y || x || w != image_width || h != image_height)
256 { 290 __vbeCopySliceData((uint8_t*)yuv_buffer,x,y,w,h);
257 unsigned long i,j,image_offset,offset;
258 unsigned pixel_size,image_line_size,screen_line_size,x_shift;
259 pixel_size = (video_mode_info.BitsPerPixel+7)/8;
260 screen_line_size = video_mode_info.XResolution*pixel_size;
261 image_line_size = w*pixel_size;
262 x_shift = (x_offset+x)*pixel_size;
263 for(j=0,i=(y_offset+y);j<h;i++,j++)
264 {
265 offset = i*screen_line_size+x_shift;
266 image_offset = j*image_line_size;
267 __vbeCopyBlock(offset,&yuv_slice[image_offset],image_line_size);
268 }
269 }
270 else __vbeCopyData((uint8_t *)yuv_buffer); 291 else __vbeCopyData((uint8_t *)yuv_buffer);
271 return 0; 292 return 0;
272 } 293 }
273 294
274 static void draw_osd(void) 295 static void draw_osd(void)
319 340
320 static void vesa_aspect(uint32_t width,uint32_t height, 341 static void vesa_aspect(uint32_t width,uint32_t height,
321 uint32_t xres,uint32_t yres, 342 uint32_t xres,uint32_t yres,
322 uint32_t *image_width,uint32_t *image_height) 343 uint32_t *image_width,uint32_t *image_height)
323 { 344 {
324 float factor; 345 aspect_factor = (float)width / height;
325 factor = (float)width / height;
326 *image_width = xres; 346 *image_width = xres;
327 *image_height = xres / factor; 347 *image_height = xres /aspect_factor;
328 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); 348 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);
329 if((*image_height) > yres) 349 if((*image_height) > yres)
330 { 350 {
331 *image_height = yres; 351 *image_height = yres;
332 *image_width = yres * factor; 352 *image_width = yres * aspect_factor;
333 if(verbose) printf("vo_vesa: Y > X tehrefore *image=%ux%u\n",*image_width,*image_height); 353 if(verbose) printf("vo_vesa: Y > X tehrefore *image=%ux%u\n",*image_width,*image_height);
334 } 354 }
335 } 355 }
336 356
337 static char *model2str(unsigned char type) 357 static char *model2str(unsigned char type)