comparison libvo/vo_vesa.c @ 2331:9e8585a7182e

Final fix of libmpeg2 zooming: flipping page support
author nick
date Sun, 21 Oct 2001 12:42:17 +0000
parents fc52a0a1626f
children d9ba4de305cf
comparison
equal deleted inserted replaced
2330:8f0861360325 2331:9e8585a7182e
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
77 75
78 static uint32_t image_width, image_height; /* source image dimension */ 76 static uint32_t image_width, image_height; /* source image dimension */
79 static int32_t x_offset,y_offset; /* to center image on screen */ 77 static int32_t x_offset,y_offset; /* to center image on screen */
80 static unsigned init_mode; /* mode before run of mplayer */ 78 static unsigned init_mode; /* mode before run of mplayer */
81 static void *init_state = NULL; /* state before run of mplayer */ 79 static void *init_state = NULL; /* state before run of mplayer */
82 static struct win_frame win; /* real-mode window to video memory */ 80 static struct win_frame win; /* real-mode window to video memory */
83 static uint8_t *yuv_buffer = NULL; /* for yuv2rgb and sw_scaling */ 81 static uint8_t *yuv_buffer = NULL; /* for yuv2rgb and sw_scaling */
84 static unsigned video_mode; /* selected video mode for playback */ 82 static unsigned video_mode; /* selected video mode for playback */
85 static struct VesaModeInfoBlock video_mode_info; 83 static struct VesaModeInfoBlock video_mode_info;
84 static int flip_trigger = 0;
86 85
87 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS) 86 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS)
88 #define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_READABLE | MODE_WIN_WRITEABLE) 87 #define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_READABLE | MODE_WIN_WRITEABLE)
89 static char * vbeErrToStr(int err) 88 static char * vbeErrToStr(int err)
90 { 89 {
234 __vbeCopyBlock(offset,&image[image_offset],image_line_size); 233 __vbeCopyBlock(offset,&image[image_offset],image_line_size);
235 } 234 }
236 } 235 }
237 } 236 }
238 237
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
265 /* is called for yuv only */ 238 /* is called for yuv only */
266 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) 239 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
267 { 240 {
268 if(vesa_zoom) 241 if(vesa_zoom)
269 { 242 {
270 SwScale_YV12slice_brg24(image,stride,y,h, 243 SwScale_YV12slice_brg24(image,stride,y,h,
271 yuv_buffer, 244 yuv_buffer,
272 image_width*((video_mode_info.BitsPerPixel+7)/8), 245 image_width*((video_mode_info.BitsPerPixel+7)/8),
273 image_width, video_mode_info.BitsPerPixel, 246 image_width, video_mode_info.BitsPerPixel,
274 scale_xinc, scale_yinc); 247 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 }
282 } 248 }
283 else 249 else
284 { 250 {
285 yuv2rgb(yuv_buffer, image[0], image[1], image[2], w, h, 251 uint8_t *yuv_slice;
252 yuv_slice=yuv_buffer+(image_width*y+x)*((video_mode_info.BitsPerPixel+7)/8);
253 yuv2rgb(yuv_slice, image[0], image[1], image[2], w, h,
286 image_width * ((video_mode_info.BitsPerPixel+7)/8), 254 image_width * ((video_mode_info.BitsPerPixel+7)/8),
287 stride[0], stride[1]); 255 stride[0], stride[1]);
288 } 256 }
289 if(y || x || w != image_width || h != image_height) 257 flip_trigger = 1;
290 __vbeCopySliceData((uint8_t*)yuv_buffer,x,y,w,h);
291 else __vbeCopyData((uint8_t *)yuv_buffer);
292 return 0; 258 return 0;
293 } 259 }
294 260
295 static void draw_osd(void) 261 static void draw_osd(void)
296 { 262 {
297 /* nothing to do for now */ 263 /* nothing to do for now */
298 } 264 }
299 265
300 static void flip_page(void) 266 static void flip_page(void)
301 { 267 {
302 /*Is not required*/ 268 if(flip_trigger) { __vbeCopyData(yuv_buffer); flip_trigger = 0; }
303 } 269 }
304 270
305 /* is called for rgb only */ 271 /* is called for rgb only */
306 static uint32_t draw_frame(uint8_t *src[]) 272 static uint32_t draw_frame(uint8_t *src[])
307 { 273 {
340 306
341 static void vesa_aspect(uint32_t width,uint32_t height, 307 static void vesa_aspect(uint32_t width,uint32_t height,
342 uint32_t xres,uint32_t yres, 308 uint32_t xres,uint32_t yres,
343 uint32_t *image_width,uint32_t *image_height) 309 uint32_t *image_width,uint32_t *image_height)
344 { 310 {
311 float aspect_factor;
345 aspect_factor = (float)width / height; 312 aspect_factor = (float)width / height;
346 *image_width = xres; 313 *image_width = xres;
347 *image_height = xres /aspect_factor; 314 *image_height = xres /aspect_factor;
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); 315 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);
349 if((*image_height) > yres) 316 if((*image_height) > yres)