Mercurial > mplayer.hg
comparison libvo/vo_vesa.c @ 4537:bc5b78f1df77
Support of scaling with every fourcc
(include patch of Michael Niedermayer <michaelni@gmx.at>)
Now (*swScale)() is used as BES by functionality.
author | nick |
---|---|
date | Tue, 05 Feb 2002 16:43:18 +0000 |
parents | be41ab8c8918 |
children | 59a90d0d662d |
comparison
equal
deleted
inserted
replaced
4536:fd65c9bdcc76 | 4537:bc5b78f1df77 |
---|---|
38 #ifdef CONFIG_VIDIX | 38 #ifdef CONFIG_VIDIX |
39 #include "vosub_vidix.h" | 39 #include "vosub_vidix.h" |
40 #endif | 40 #endif |
41 | 41 |
42 #include "../postproc/swscale.h" | 42 #include "../postproc/swscale.h" |
43 #include "../postproc/rgb2rgb.h" | 43 //#include "../postproc/rgb2rgb.h" |
44 | 44 |
45 LIBVO_EXTERN(vesa) | 45 LIBVO_EXTERN(vesa) |
46 extern int verbose; | 46 extern int verbose; |
47 | 47 |
48 #define MAX_BUFFERS 3 | 48 #define MAX_BUFFERS 3 |
76 idx=-2 indicates invalid frame, exists only in init() */ | 76 idx=-2 indicates invalid frame, exists only in init() */ |
77 }; | 77 }; |
78 | 78 |
79 static void (*cpy_blk_fnc)(unsigned long,uint8_t *,unsigned long) = NULL; | 79 static void (*cpy_blk_fnc)(unsigned long,uint8_t *,unsigned long) = NULL; |
80 | 80 |
81 static int vesa_zoom=0; /* software scaling */ | 81 static uint32_t srcW=0,srcH=0,srcBpp,srcFourcc; /* source image description */ |
82 static unsigned int scale_srcW=0; | 82 static uint32_t dstBpp,dstW, dstH,dstFourcc; /* destinition image description */ |
83 static unsigned int scale_srcH=0; | 83 |
84 | 84 static SwsContext * sws = NULL; |
85 static uint32_t image_bpp,image_width, image_height; /* source image dimension */ | 85 |
86 static int32_t x_offset,y_offset; /* to center image on screen */ | 86 static int32_t x_offset,y_offset; /* to center image on screen */ |
87 static unsigned init_mode; /* mode before run of mplayer */ | 87 static unsigned init_mode; /* mode before run of mplayer */ |
88 static void *init_state = NULL; /* state before run of mplayer */ | 88 static void *init_state = NULL; /* state before run of mplayer */ |
89 static struct win_frame win; /* real-mode window to video memory */ | 89 static struct win_frame win; /* real-mode window to video memory */ |
90 static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */ | 90 static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */ |
144 if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err); | 144 if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err); |
145 if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err); | 145 if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err); |
146 if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high); | 146 if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high); |
147 if(dga_buffer && !HAS_DGA()) free(dga_buffer); | 147 if(dga_buffer && !HAS_DGA()) free(dga_buffer); |
148 vbeDestroy(); | 148 vbeDestroy(); |
149 if(sws) freeSwsContext(sws); | |
149 } | 150 } |
150 | 151 |
151 #define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high) | 152 #define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high) |
152 #define VIDEO_PTR(offset) (win.ptr + offset - win.low) | 153 #define VIDEO_PTR(offset) (win.ptr + offset - win.low) |
153 | 154 |
176 int x_res = video_mode_info.XResolution; | 177 int x_res = video_mode_info.XResolution; |
177 int y_res = video_mode_info.YResolution; | 178 int y_res = video_mode_info.YResolution; |
178 int shift_r = video_mode_info.RedFieldPosition; | 179 int shift_r = video_mode_info.RedFieldPosition; |
179 int shift_g = video_mode_info.GreenFieldPosition; | 180 int shift_g = video_mode_info.GreenFieldPosition; |
180 int shift_b = video_mode_info.BlueFieldPosition; | 181 int shift_b = video_mode_info.BlueFieldPosition; |
181 int pixel_size = (video_mode_info.BitsPerPixel+7)/8; | 182 int pixel_size = (dstBpp+7)/8; |
182 int bpl = video_mode_info.BytesPerScanLine; | 183 int bpl = video_mode_info.BytesPerScanLine; |
183 int color; | 184 int color; |
184 unsigned offset; | 185 unsigned offset; |
185 | 186 |
186 if (x < 0 || x >= x_res || y < 0 || y >= y_res) return; | 187 if (x < 0 || x >= x_res || y < 0 || y >= y_res) return; |
205 static void __vbeCopyBlock(unsigned long offset,uint8_t *image,unsigned long size) | 206 static void __vbeCopyBlock(unsigned long offset,uint8_t *image,unsigned long size) |
206 { | 207 { |
207 unsigned long delta,src_idx = 0; | 208 unsigned long delta,src_idx = 0; |
208 while(size) | 209 while(size) |
209 { | 210 { |
210 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset); | 211 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset); |
211 delta = min(size,win.high - offset); | 212 delta = min(size,win.high - offset); |
212 memcpy(VIDEO_PTR(offset),&image[src_idx],delta); | 213 memcpy(VIDEO_PTR(offset),&image[src_idx],delta); |
213 src_idx += delta; | 214 src_idx += delta; |
214 offset += delta; | 215 offset += delta; |
215 size -= delta; | 216 size -= delta; |
216 } | 217 } |
217 } | 218 } |
218 | 219 |
219 /* | 220 /* |
220 Copies frame to video memory. Data should be in the same format as video | 221 Copies frame to video memory. Data should be in the same format as video |
221 memory. | 222 memory. |
222 */ | 223 */ |
223 | 224 |
224 #define PIXEL_SIZE() ((video_mode_info.BitsPerPixel+7)/8) | 225 #define PIXEL_SIZE() ((dstBpp+7)/8) |
225 #define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) ) | 226 #define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) ) |
226 #define IMAGE_LINE_SIZE(pixel_size) (image_width*(pixel_size)) | 227 #define IMAGE_LINE_SIZE(pixel_size) (dstW*(pixel_size)) |
227 | 228 |
228 static void __vbeCopyData(uint8_t *image) | 229 static void __vbeCopyData(uint8_t *image) |
229 { | 230 { |
230 unsigned long i,j,image_offset,offset; | 231 unsigned long i,j,image_offset,offset; |
231 unsigned pixel_size,image_line_size,screen_line_size,x_shift; | 232 unsigned pixel_size,image_line_size,screen_line_size,x_shift; |
232 pixel_size = PIXEL_SIZE(); | 233 pixel_size = PIXEL_SIZE(); |
233 screen_line_size = SCREEN_LINE_SIZE(pixel_size); | 234 screen_line_size = SCREEN_LINE_SIZE(pixel_size); |
234 image_line_size = IMAGE_LINE_SIZE(pixel_size); | 235 image_line_size = IMAGE_LINE_SIZE(pixel_size); |
235 if(image_width == video_mode_info.XResolution) | 236 if(dstW == video_mode_info.XResolution) |
236 { | 237 { |
237 /* Special case for zooming */ | 238 /* Special case for zooming */ |
238 (*cpy_blk_fnc)(y_offset*screen_line_size,image,image_line_size*image_height); | 239 (*cpy_blk_fnc)(y_offset*screen_line_size,image,image_line_size*dstH); |
239 } | 240 } |
240 else | 241 else |
241 { | 242 { |
242 x_shift = x_offset*pixel_size; | 243 x_shift = x_offset*pixel_size; |
243 for(j=0,i=y_offset;j<image_height;i++,j++) | 244 for(j=0,i=y_offset;j<dstH;i++,j++) |
244 { | 245 { |
245 offset = i*screen_line_size+x_shift; | 246 offset = i*screen_line_size+x_shift; |
246 image_offset = j*image_line_size; | 247 image_offset = j*image_line_size; |
247 (*cpy_blk_fnc)(offset,&image[image_offset],image_line_size); | 248 (*cpy_blk_fnc)(offset,&image[image_offset],image_line_size); |
248 } | 249 } |
250 } | 251 } |
251 | 252 |
252 /* is called for yuv only */ | 253 /* is called for yuv only */ |
253 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | 254 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) |
254 { | 255 { |
256 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; | |
257 uint8_t *dst[3]= {dga_buffer, NULL, NULL}; | |
258 int dstStride[3]; | |
255 if(verbose > 2) | 259 if(verbose > 2) |
256 printf("vo_vesa: draw_slice was called: w=%u h=%u x=%u y=%u\n",w,h,x,y); | 260 printf("vo_vesa: draw_slice was called: w=%u h=%u x=%u y=%u\n",w,h,x,y); |
257 if(vesa_zoom) | 261 dstStride[0]=dstride*((dstBpp+7)/8); |
258 { | 262 dstStride[1]= |
259 uint8_t *dst[3]= {dga_buffer, NULL, NULL}; | 263 dstStride[2]=dstStride[0]>>1; |
260 int dst_stride; | 264 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); |
261 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); | 265 (*swScale)(sws,image,stride,y,h,dst,dstStride); |
262 dst_stride = PIXEL_SIZE()*(HAS_DGA()?video_mode_info.XResolution:image_width); | |
263 SwScale_YV12slice(image,stride,y,h,dst,dst_stride, | |
264 video_mode_info.BitsPerPixel, | |
265 scale_srcW, scale_srcH, image_width, image_height); | |
266 | |
267 } | |
268 else | |
269 { | |
270 uint8_t *yuv_slice; | |
271 int rgb_stride; | |
272 yuv_slice=dga_buffer; | |
273 if(HAS_DGA()) yuv_slice += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); | |
274 rgb_stride = HAS_DGA()?video_mode_info.XResolution:image_width; | |
275 yuv_slice+=(rgb_stride*y+x)*PIXEL_SIZE(); | |
276 rgb_stride *= PIXEL_SIZE(); | |
277 yuv2rgb(yuv_slice, image[0], image[1], image[2], w, h, | |
278 rgb_stride, stride[0], stride[1]); | |
279 } | |
280 flip_trigger = 1; | 266 flip_trigger = 1; |
281 return 0; | 267 return 0; |
282 } | 268 } |
283 | 269 |
284 static void draw_alpha_32(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | 270 static void draw_alpha_32(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
285 { | 271 { |
286 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | 272 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
287 vo_draw_alpha_rgb32(w,h,src,srca,stride,dga_buffer+4*(y0*dstride+x0),4*dstride); | 273 vo_draw_alpha_rgb32(w,h,src,srca,stride,dga_buffer+4*(y0*dstride+x0),4*dstride); |
288 } | 274 } |
289 | 275 |
290 static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | 276 static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
291 { | 277 { |
292 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | 278 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
293 vo_draw_alpha_rgb24(w,h,src,srca,stride,dga_buffer+3*(y0*dstride+x0),3*dstride); | 279 vo_draw_alpha_rgb24(w,h,src,srca,stride,dga_buffer+3*(y0*dstride+x0),3*dstride); |
294 } | 280 } |
295 | 281 |
296 static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | 282 static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
297 { | 283 { |
298 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | 284 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
299 vo_draw_alpha_rgb16(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); | 285 vo_draw_alpha_rgb16(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); |
300 } | 286 } |
301 | 287 |
302 static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | 288 static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
303 { | 289 { |
304 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | 290 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
305 vo_draw_alpha_rgb15(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); | 291 vo_draw_alpha_rgb15(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); |
306 } | 292 } |
307 | 293 |
308 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | 294 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
309 { | 295 { |
321 { | 307 { |
322 uint32_t w,h; | 308 uint32_t w,h; |
323 if(verbose > 2) | 309 if(verbose > 2) |
324 printf("vo_vesa: draw_osd was called\n"); | 310 printf("vo_vesa: draw_osd was called\n"); |
325 { | 311 { |
326 w = HAS_DGA()?video_mode_info.XResolution:image_width; | 312 w = HAS_DGA()?video_mode_info.XResolution:dstW; |
327 h = HAS_DGA()?video_mode_info.YResolution:image_height; | 313 h = HAS_DGA()?video_mode_info.YResolution:dstH; |
328 if(dga_buffer) vo_draw_text(w,h,draw_alpha_fnc); | 314 if(dga_buffer) vo_draw_text(w,h,draw_alpha_fnc); |
329 } | 315 } |
330 } | 316 } |
331 | 317 |
332 static void flip_page(void) | 318 static void flip_page(void) |
364 } | 350 } |
365 | 351 |
366 /* is called for rgb only */ | 352 /* is called for rgb only */ |
367 static uint32_t draw_frame(uint8_t *src[]) | 353 static uint32_t draw_frame(uint8_t *src[]) |
368 { | 354 { |
369 uint8_t *data = src[0]; | |
370 if(verbose > 2) | 355 if(verbose > 2) |
371 printf("vo_vesa: draw_frame was called\n"); | 356 printf("vo_vesa: draw_frame was called\n"); |
372 if(rgb2rgb_fnc) | 357 if(sws) |
373 { | 358 { |
374 if(HAS_DGA()) | 359 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
375 { | 360 int srcStride[1]; |
376 size_t i, psize, ssize, dsize; | 361 uint8_t *dst[3]= {dga_buffer, NULL, NULL}; |
377 uint8_t *dest; | 362 int dstStride[3]; |
378 const uint8_t *sptr; | 363 dstStride[0]=dstride*((dstBpp+7)/8); |
379 psize = PIXEL_SIZE(); | 364 dstStride[1]= |
380 dsize = SCREEN_LINE_SIZE(psize); | 365 dstStride[2]=dstStride[0]>>1; |
381 ssize = IMAGE_LINE_SIZE((image_bpp+7)/8); | 366 if(srcFourcc == IMGFMT_RGB32 || srcFourcc == IMGFMT_BGR32) |
382 dest = dga_buffer + y_offset*dsize + x_offset*psize; | 367 srcStride[0] = srcW*4; |
383 sptr = src[0]; | 368 else |
384 for(i=0;i<image_height;i++) | 369 if(srcFourcc == IMGFMT_RGB24 || srcFourcc == IMGFMT_BGR24) |
385 { | 370 srcStride[0] = srcW*3; |
386 (*rgb2rgb_fnc)(sptr,dest,ssize); | 371 else |
387 sptr += ssize; | 372 srcStride[0] = srcW*2; |
388 dest += dsize; | 373 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); |
389 } | 374 (*swScale)(sws,src,srcStride,0,srcH,dst,dstStride); |
390 } | 375 flip_trigger=1; |
391 else | 376 } |
392 { | 377 else if(!HAS_DGA()) __vbeCopyData(src[0]); |
393 (*rgb2rgb_fnc)(src[0],dga_buffer,image_width*image_height*image_bpp); | |
394 data = dga_buffer; | |
395 } | |
396 if(verbose > 2) | |
397 printf("vo_vesa: rgb2rgb_fnc was called\n"); | |
398 } | |
399 if(!rgb2rgb_fnc || !HAS_DGA()) __vbeCopyData(data); | |
400 return 0; | 378 return 0; |
401 } | 379 } |
402 | 380 |
403 #define SUBDEV_NODGA 0x00000001UL | 381 #define SUBDEV_NODGA 0x00000001UL |
404 #define SUBDEV_FORCEDGA 0x00000002UL | 382 #define SUBDEV_FORCEDGA 0x00000002UL |
414 if(memcmp(sd,"lvo:",4) == 0) lvo_name = &sd[4]; /* lvo_name will be valid within init() */ | 392 if(memcmp(sd,"lvo:",4) == 0) lvo_name = &sd[4]; /* lvo_name will be valid within init() */ |
415 #ifdef CONFIG_VIDIX | 393 #ifdef CONFIG_VIDIX |
416 else | 394 else |
417 if(memcmp(sd,"vidix",5) == 0) vidix_name = &sd[5]; /* vidix_name will be valid within init() */ | 395 if(memcmp(sd,"vidix",5) == 0) vidix_name = &sd[5]; /* vidix_name will be valid within init() */ |
418 #endif | 396 #endif |
419 else { printf("vo_vesa: Unknown subdevice: '%s'\n", sd); return -1; } | 397 else { printf("vo_vesa: Unknown subdevice: '%s'\n", sd); return 0xFFFFFFFFUL; } |
420 return flags; | 398 return flags; |
421 } | 399 } |
422 | 400 |
423 static uint32_t query_format(uint32_t format) | 401 static uint32_t query_format(uint32_t format) |
424 { | 402 { |
425 uint32_t retval; | |
426 if(verbose > 2) | 403 if(verbose > 2) |
427 printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format)); | 404 printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format)); |
428 switch(format) | 405 return 1; /* due new SwScale code */ |
429 { | |
430 case IMGFMT_YV12: | |
431 #if 0 /* Should be tested better */ | |
432 case IMGFMT_I420: | |
433 case IMGFMT_IYUV: | |
434 #endif | |
435 case IMGFMT_RGB8: | |
436 case IMGFMT_RGB15: | |
437 case IMGFMT_RGB16: | |
438 case IMGFMT_RGB24: | |
439 case IMGFMT_RGB32: | |
440 case IMGFMT_BGR8: | |
441 case IMGFMT_BGR15: | |
442 case IMGFMT_BGR16: | |
443 case IMGFMT_BGR24: | |
444 case IMGFMT_BGR32: | |
445 retval = 1; break; | |
446 default: | |
447 if(verbose) | |
448 printf("vo_vesa: unknown format: %x = %s\n",format,vo_format_name(format)); | |
449 retval = 0; | |
450 } | |
451 return retval; | |
452 } | 406 } |
453 | 407 |
454 static void paintBkGnd( void ) | 408 static void paintBkGnd( void ) |
455 { | 409 { |
456 int x_res = video_mode_info.XResolution; | 410 int x_res = video_mode_info.XResolution; |
510 | 464 |
511 unsigned fillMultiBuffer( unsigned long vsize, unsigned nbuffs ) | 465 unsigned fillMultiBuffer( unsigned long vsize, unsigned nbuffs ) |
512 { | 466 { |
513 unsigned long screen_size, offset; | 467 unsigned long screen_size, offset; |
514 unsigned total,i; | 468 unsigned total,i; |
515 screen_size = video_mode_info.XResolution*video_mode_info.YResolution*((video_mode_info.BitsPerPixel+7)/8); | 469 screen_size = video_mode_info.XResolution*video_mode_info.YResolution*((dstBpp+7)/8); |
516 if(screen_size%64) screen_size=((screen_size/64)*64)+64; | 470 if(screen_size%64) screen_size=((screen_size/64)*64)+64; |
517 total = vsize / screen_size; | 471 total = vsize / screen_size; |
518 if(verbose) printf("vo_vesa: Can use up to %u video buffers\n",total); | 472 if(verbose) printf("vo_vesa: Can use up to %u video buffers\n",total); |
519 i = 0; | 473 i = 0; |
520 offset = 0; | 474 offset = 0; |
540 struct VesaModeInfoBlock vmib; | 494 struct VesaModeInfoBlock vmib; |
541 size_t i,num_modes; | 495 size_t i,num_modes; |
542 uint32_t w,h; | 496 uint32_t w,h; |
543 unsigned short *mode_ptr,win_seg; | 497 unsigned short *mode_ptr,win_seg; |
544 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; | 498 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; |
545 int err,fs_mode,yuv_fmt; | 499 int err,fs_mode,yuv_fmt,use_scaler=0; |
546 image_width = width; | 500 dstW = width; |
547 image_height = height; | 501 dstH = height; |
548 fs_mode = 0; | 502 fs_mode = 0; |
549 rgb2rgb_fnc = NULL; | 503 rgb2rgb_fnc = NULL; |
550 if(subdev_flags == 0xFFFFFFFEUL) | 504 if(subdev_flags == 0xFFFFFFFEUL) |
551 { | 505 { |
552 printf("vo_vesa: detected internal fatal error: init is called before preinit\n"); | 506 printf("vo_vesa: detected internal fatal error: init is called before preinit\n"); |
553 return -1; | 507 return -1; |
554 } | 508 } |
555 if(subdev_flags == -1) return -1; | 509 if(subdev_flags == 0xFFFFFFFFUL) return -1; |
556 if(flags & 0x8) | 510 if(flags & 0x8) |
557 { | 511 { |
558 printf("vo_vesa: switch -flip is not supported\n"); | 512 printf("vo_vesa: switch -flip is not supported\n"); |
559 } | 513 } |
560 if(flags & 0x04) vesa_zoom = 1; | 514 if(flags & 0x04) use_scaler = 1; |
561 if(flags & 0x01) | 515 if(flags & 0x01) |
562 { | 516 { |
563 if(vesa_zoom) vesa_zoom = 2; | 517 if(use_scaler) use_scaler = 2; |
564 else fs_mode = 1; | 518 else fs_mode = 1; |
565 } | 519 } |
566 if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; } | 520 if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; } |
567 memcpy(vib.VESASignature,"VBE2",4); | 521 memcpy(vib.VESASignature,"VBE2",4); |
568 if((err=vbeGetControllerInfo(&vib)) != VBE_OK) | 522 if((err=vbeGetControllerInfo(&vib)) != VBE_OK) |
601 { | 555 { |
602 case IMGFMT_BGR8: | 556 case IMGFMT_BGR8: |
603 case IMGFMT_RGB8: bpp = 8; break; | 557 case IMGFMT_RGB8: bpp = 8; break; |
604 case IMGFMT_BGR15: | 558 case IMGFMT_BGR15: |
605 case IMGFMT_RGB15: bpp = 15; break; | 559 case IMGFMT_RGB15: bpp = 15; break; |
606 case IMGFMT_YV12: | |
607 case IMGFMT_I420: | |
608 case IMGFMT_IYUV: yuv_fmt = 1; | |
609 default: | |
610 case IMGFMT_BGR16: | 560 case IMGFMT_BGR16: |
611 case IMGFMT_RGB16: bpp = 16; break; | 561 case IMGFMT_RGB16: bpp = 16; break; |
612 case IMGFMT_BGR24: | 562 case IMGFMT_BGR24: |
613 case IMGFMT_RGB24: bpp = 24; break; | 563 case IMGFMT_RGB24: bpp = 24; break; |
614 case IMGFMT_BGR32: | 564 case IMGFMT_BGR32: |
615 case IMGFMT_RGB32: bpp = 32; break; | 565 case IMGFMT_RGB32: bpp = 32; break; |
616 } | 566 default: bpp = 16; yuv_fmt = 1; break; |
617 image_bpp = bpp; | 567 } |
568 srcBpp = bpp; | |
569 srcFourcc = format; | |
618 if(vo_dbpp) bpp = vo_dbpp; | 570 if(vo_dbpp) bpp = vo_dbpp; |
619 if(yuv_fmt) yuv2rgb_init(bpp, MODE_RGB); | |
620 switch(bpp) | 571 switch(bpp) |
621 { | 572 { |
622 case 15: draw_alpha_fnc = draw_alpha_15; break; | 573 case 15: draw_alpha_fnc = draw_alpha_15; |
623 case 16: draw_alpha_fnc = draw_alpha_16; break; | 574 dstFourcc = IMGFMT_BGR15; |
624 case 24: draw_alpha_fnc = draw_alpha_24; break; | 575 break; |
625 case 32: draw_alpha_fnc = draw_alpha_32; break; | 576 case 16: draw_alpha_fnc = draw_alpha_16; |
626 default: draw_alpha_fnc = draw_alpha_null; break; | 577 dstFourcc = IMGFMT_BGR16; |
627 } | 578 break; |
579 case 24: draw_alpha_fnc = draw_alpha_24; | |
580 dstFourcc = IMGFMT_BGR24; | |
581 break; | |
582 case 32: draw_alpha_fnc = draw_alpha_32; | |
583 dstFourcc = IMGFMT_BGR32; | |
584 break; | |
585 default: draw_alpha_fnc = draw_alpha_null; | |
586 dstFourcc = IMGFMT_BGR16; | |
587 break; | |
588 } | |
589 if(srcFourcc != dstFourcc) yuv_fmt=1; | |
628 if(verbose) | 590 if(verbose) |
629 { | 591 { |
630 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); | 592 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); |
631 printf("vo_vesa: Total modes found: %u\n",num_modes); | 593 printf("vo_vesa: Total modes found: %u\n",num_modes); |
632 mode_ptr = vib.VideoModePtr; | 594 mode_ptr = vib.VideoModePtr; |
636 printf(" %04X",mode_ptr[i]); | 598 printf(" %04X",mode_ptr[i]); |
637 } | 599 } |
638 printf("\nvo_vesa: Modes in detail:\n"); | 600 printf("\nvo_vesa: Modes in detail:\n"); |
639 } | 601 } |
640 mode_ptr = vib.VideoModePtr; | 602 mode_ptr = vib.VideoModePtr; |
641 if(vesa_zoom) | 603 if(use_scaler) |
642 { | 604 { |
643 image_width = d_width; | 605 dstW = d_width; |
644 image_height= d_height; | 606 dstH= d_height; |
645 } | 607 } |
646 if(vo_screenwidth) w = vo_screenwidth; | 608 if(vo_screenwidth) w = vo_screenwidth; |
647 else w = max(image_width,width); | 609 else w = max(dstW,width); |
648 if(vo_screenheight) h = vo_screenheight; | 610 if(vo_screenheight) h = vo_screenheight; |
649 else h = max(image_height,height); | 611 else h = max(dstH,height); |
650 for(i=0;i < num_modes;i++) | 612 for(i=0;i < num_modes;i++) |
651 { | 613 { |
652 if((err=vbeGetModeInfo(mode_ptr[i],&vmib)) != VBE_OK) | 614 if((err=vbeGetModeInfo(mode_ptr[i],&vmib)) != VBE_OK) |
653 { | 615 { |
654 PRINT_VBE_ERR("vbeGetModeInfo",err); | 616 PRINT_VBE_ERR("vbeGetModeInfo",err); |
699 PRINT_VBE_ERR("vbeGetModeInfo",err); | 661 PRINT_VBE_ERR("vbeGetModeInfo",err); |
700 return -1; | 662 return -1; |
701 } | 663 } |
702 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n" | 664 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n" |
703 ,best_mode_idx,video_mode,video_mode_info.XResolution | 665 ,best_mode_idx,video_mode,video_mode_info.XResolution |
704 ,video_mode_info.YResolution,video_mode_info.BitsPerPixel); | 666 ,video_mode_info.YResolution,dstBpp); |
667 dstBpp = video_mode_info.BitsPerPixel; | |
705 if(subdev_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0; | 668 if(subdev_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0; |
706 if( vesa_zoom || fs_mode ) | 669 if(use_scaler || fs_mode || yuv_fmt) |
707 { | 670 { |
708 if(format==IMGFMT_YV12 || lvo_name | |
709 #ifdef CONFIG_VIDIX | |
710 || vidix_name | |
711 #endif | |
712 ) | |
713 { | |
714 /* software scale */ | 671 /* software scale */ |
715 if(vesa_zoom > 1) | 672 if(use_scaler > 1) |
716 { | 673 { |
717 aspect_save_orig(width,height); | 674 aspect_save_orig(width,height); |
718 aspect_save_prescale(d_width,d_height); | 675 aspect_save_prescale(d_width,d_height); |
719 aspect_save_screenres(video_mode_info.XResolution,video_mode_info.YResolution); | 676 aspect_save_screenres(video_mode_info.XResolution,video_mode_info.YResolution); |
720 aspect(&image_width,&image_height,A_ZOOM); | 677 aspect(&dstW,&dstH,A_ZOOM); |
721 } | 678 } |
722 else | 679 else |
723 if(fs_mode) | 680 if(fs_mode) |
724 { | 681 { |
725 image_width = video_mode_info.XResolution; | 682 dstW = video_mode_info.XResolution; |
726 image_height = video_mode_info.YResolution; | 683 dstH = video_mode_info.YResolution; |
727 vesa_zoom = 1; | |
728 } | 684 } |
729 scale_srcW=width; | 685 srcW=width; |
730 scale_srcH=height; | 686 srcH=height; |
687 use_scaler = 1; | |
731 if(!lvo_name | 688 if(!lvo_name |
732 #ifdef CONFIG_VIDIX | 689 #ifdef CONFIG_VIDIX |
733 && !vidix_name | 690 && !vidix_name |
734 #endif | 691 #endif |
735 ) SwScale_Init(); | 692 ) |
736 if(verbose) printf("vo_vesa: Using SCALE\n"); | 693 { |
737 } | 694 sws = getSwsContextFromCmdLine(srcW,srcH,srcFourcc,dstW,dstH,dstFourcc); |
738 else | 695 if(!sws) |
739 { | 696 { |
740 printf("vo_vesa: Can't apply zooming to non YV12 formats\n"); | 697 printf("vo_vesa: Can't initialize SwScaler\n"); |
741 return -1; | 698 return -1; |
742 } | 699 } |
743 } | 700 else if(verbose) printf("vo_vesa: Using SW Scaler-YUV convertor\n"); |
744 if(format != IMGFMT_YV12 && image_bpp != video_mode_info.BitsPerPixel && !lvo_name | 701 } |
745 #ifdef CONFIG_VIDIX | 702 } |
746 && !vidix_name | |
747 #endif | |
748 ) | |
749 { | |
750 if(image_bpp == 24 && video_mode_info.BitsPerPixel == 32) rgb2rgb_fnc = rgb24to32; | |
751 else | |
752 if(image_bpp == 32 && video_mode_info.BitsPerPixel == 24) rgb2rgb_fnc = rgb32to24; | |
753 else | |
754 if(image_bpp == 32 && video_mode_info.BitsPerPixel == 16) rgb2rgb_fnc = rgb32to16; | |
755 else | |
756 if(image_bpp == 32 && video_mode_info.BitsPerPixel == 15) rgb2rgb_fnc = rgb32to15; | |
757 else | |
758 if(image_bpp == 24 && video_mode_info.BitsPerPixel == 16) rgb2rgb_fnc = rgb24to16; | |
759 else | |
760 if(image_bpp == 24 && video_mode_info.BitsPerPixel == 15) rgb2rgb_fnc = rgb24to15; | |
761 else | |
762 if(image_bpp == 15 && video_mode_info.BitsPerPixel == 16) rgb2rgb_fnc = rgb15to16; | |
763 else | |
764 { | |
765 printf("vo_vesa: Can't convert %u to %u\n",image_bpp,video_mode_info.BitsPerPixel); | |
766 return -1; | |
767 } | |
768 printf("vo_vesa: using %u-bpp to %u-bpp sw convertor\n",image_bpp,video_mode_info.BitsPerPixel); | |
769 } | |
770 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE) | 703 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE) |
771 win.idx = 0; /* frame A */ | 704 win.idx = 0; /* frame A */ |
772 else | 705 else |
773 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE) | 706 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE) |
774 win.idx = 1; /* frame B */ | 707 win.idx = 1; /* frame B */ |
820 win.low = 0L; | 753 win.low = 0L; |
821 win.high= video_mode_info.WinSize*1024; | 754 win.high= video_mode_info.WinSize*1024; |
822 printf("vo_vesa: Using bank switching mode (physical resources: %08lXh, %08lXh)\n" | 755 printf("vo_vesa: Using bank switching mode (physical resources: %08lXh, %08lXh)\n" |
823 ,(unsigned long)win.ptr,(unsigned long)win.high); | 756 ,(unsigned long)win.ptr,(unsigned long)win.high); |
824 } | 757 } |
825 if(video_mode_info.XResolution > image_width) | 758 if(video_mode_info.XResolution > dstW) |
826 x_offset = (video_mode_info.XResolution - image_width) / 2; | 759 x_offset = (video_mode_info.XResolution - dstW) / 2; |
827 else x_offset = 0; | 760 else x_offset = 0; |
828 if(video_mode_info.YResolution > image_height) | 761 if(video_mode_info.YResolution > dstH) |
829 y_offset = (video_mode_info.YResolution - image_height) / 2; | 762 y_offset = (video_mode_info.YResolution - dstH) / 2; |
830 else y_offset = 0; | 763 else y_offset = 0; |
831 if(verbose) | 764 if(verbose) |
832 printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n" | 765 printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n" |
833 ,image_width,image_height | 766 ,dstW,dstH |
834 ,video_mode_info.XResolution,video_mode_info.YResolution | 767 ,video_mode_info.XResolution,video_mode_info.YResolution |
835 ,x_offset,y_offset); | 768 ,x_offset,y_offset); |
836 if(HAS_DGA()) | 769 if(HAS_DGA()) |
837 { | 770 { |
838 dga_buffer = win.ptr; /* Trickly ;) */ | 771 dga_buffer = win.ptr; /* Trickly ;) */ |
845 #ifdef CONFIG_VIDIX | 778 #ifdef CONFIG_VIDIX |
846 && !vidix_name | 779 && !vidix_name |
847 #endif | 780 #endif |
848 ) | 781 ) |
849 { | 782 { |
850 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*video_mode_info.BitsPerPixel))) | 783 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*dstBpp))) |
851 { | 784 { |
852 printf("vo_vesa: Can't allocate temporary buffer\n"); | 785 printf("vo_vesa: Can't allocate temporary buffer\n"); |
853 return -1; | 786 return -1; |
854 } | 787 } |
855 if(verbose) printf("vo_vesa: dga emulator was allocated = %p\n",dga_buffer); | 788 if(verbose) printf("vo_vesa: dga emulator was allocated = %p\n",dga_buffer); |
872 printf("vo_vesa: Graphics mode was activated\n"); | 805 printf("vo_vesa: Graphics mode was activated\n"); |
873 fflush(stdout); | 806 fflush(stdout); |
874 } | 807 } |
875 if(lvo_name) | 808 if(lvo_name) |
876 { | 809 { |
877 if(vlvo_init(width,height,x_offset,y_offset,image_width,image_height,format,video_mode_info.BitsPerPixel) != 0) | 810 if(vlvo_init(width,height,x_offset,y_offset,dstW,dstH,format,dstBpp) != 0) |
878 { | 811 { |
879 printf("vo_vesa: Can't initialize Linux Video Overlay\n"); | 812 printf("vo_vesa: Can't initialize Linux Video Overlay\n"); |
880 lvo_name = NULL; | 813 lvo_name = NULL; |
881 vesa_term(); | 814 vesa_term(); |
882 return -1; | 815 return -1; |
885 } | 818 } |
886 #ifdef CONFIG_VIDIX | 819 #ifdef CONFIG_VIDIX |
887 else | 820 else |
888 if(vidix_name) | 821 if(vidix_name) |
889 { | 822 { |
890 if(vidix_init(width,height,x_offset,y_offset,image_width, | 823 if(vidix_init(width,height,x_offset,y_offset,dstW, |
891 image_height,format,video_mode_info.BitsPerPixel, | 824 dstH,format,dstBpp, |
892 video_mode_info.XResolution,video_mode_info.YResolution,info) != 0) | 825 video_mode_info.XResolution,video_mode_info.YResolution,info) != 0) |
893 { | 826 { |
894 printf("vo_vesa: Can't initialize VIDIX driver\n"); | 827 printf("vo_vesa: Can't initialize VIDIX driver\n"); |
895 vidix_name = NULL; | 828 vidix_name = NULL; |
896 vidix_term(); | 829 vidix_term(); |