Mercurial > mplayer.hg
comparison libvo/vo_vesa.c @ 2337:e6d8e9a54afa
OSD support
author | nick |
---|---|
date | Sun, 21 Oct 2001 15:04:04 +0000 |
parents | b2e0b131c1a7 |
children | aa4d96380b7f |
comparison
equal
deleted
inserted
replaced
2336:b2e0b131c1a7 | 2337:e6d8e9a54afa |
---|---|
24 #include "video_out.h" | 24 #include "video_out.h" |
25 #include "video_out_internal.h" | 25 #include "video_out_internal.h" |
26 | 26 |
27 #include "fastmemcpy.h" | 27 #include "fastmemcpy.h" |
28 #include "yuv2rgb.h" | 28 #include "yuv2rgb.h" |
29 | 29 #include "sub.h" |
30 #include "linux/lrmi.h" | |
31 #include "linux/vbelib.h" | 30 #include "linux/vbelib.h" |
32 #include "bswap.h" | 31 #include "bswap.h" |
33 | 32 |
34 #include "../postproc/swscale.h" | 33 #include "../postproc/swscale.h" |
35 | 34 |
80 static struct win_frame win; /* real-mode window to video memory */ | 79 static struct win_frame win; /* real-mode window to video memory */ |
81 static uint8_t *yuv_buffer = NULL; /* for yuv2rgb and sw_scaling */ | 80 static uint8_t *yuv_buffer = NULL; /* for yuv2rgb and sw_scaling */ |
82 static unsigned video_mode; /* selected video mode for playback */ | 81 static unsigned video_mode; /* selected video mode for playback */ |
83 static struct VesaModeInfoBlock video_mode_info; | 82 static struct VesaModeInfoBlock video_mode_info; |
84 static int flip_trigger = 0; | 83 static int flip_trigger = 0; |
84 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); | |
85 | 85 |
86 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS) | 86 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS) |
87 #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) |
88 static char * vbeErrToStr(int err) | 88 static char * vbeErrToStr(int err) |
89 { | 89 { |
111 static void vesa_term( void ) | 111 static void vesa_term( void ) |
112 { | 112 { |
113 int err; | 113 int err; |
114 if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err); | 114 if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err); |
115 if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err); | 115 if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err); |
116 free(yuv_buffer); | 116 if(yuv_buffer) free(yuv_buffer); |
117 vbeDestroy(); | 117 vbeDestroy(); |
118 } | 118 } |
119 | 119 |
120 #define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high) | 120 #define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high) |
121 #define VIDEO_PTR(offset) (win.ptr + offset - win.low) | 121 #define VIDEO_PTR(offset) (win.ptr + offset - win.low) |
256 } | 256 } |
257 flip_trigger = 1; | 257 flip_trigger = 1; |
258 return 0; | 258 return 0; |
259 } | 259 } |
260 | 260 |
261 static void draw_alpha_32(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ | |
262 vo_draw_alpha_rgb32(w,h,src,srca,stride,yuv_buffer+4*(y0*image_width+x0),4*image_width); | |
263 } | |
264 | |
265 static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ | |
266 vo_draw_alpha_rgb24(w,h,src,srca,stride,yuv_buffer+3*(y0*image_width+x0),3*image_width); | |
267 } | |
268 | |
269 static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ | |
270 vo_draw_alpha_rgb16(w,h,src,srca,stride,yuv_buffer+2*(y0*image_width+x0),2*image_width); | |
271 } | |
272 | |
273 static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ | |
274 vo_draw_alpha_rgb15(w,h,src,srca,stride,yuv_buffer+2*(y0*image_width+x0),2*image_width); | |
275 } | |
276 | |
277 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ | |
278 } | |
279 | |
280 | |
261 static void draw_osd(void) | 281 static void draw_osd(void) |
262 { | 282 { |
263 /* nothing to do for now */ | 283 if(yuv_buffer) vo_draw_text(image_width,image_height,draw_alpha_fnc); |
264 } | 284 } |
265 | 285 |
266 static void flip_page(void) | 286 static void flip_page(void) |
267 { | 287 { |
268 if(flip_trigger) { __vbeCopyData(yuv_buffer); flip_trigger = 0; } | 288 if(flip_trigger) { __vbeCopyData(yuv_buffer); flip_trigger = 0; } |
352 struct VesaModeInfoBlock vmib; | 372 struct VesaModeInfoBlock vmib; |
353 size_t i,num_modes; | 373 size_t i,num_modes; |
354 uint32_t w,h; | 374 uint32_t w,h; |
355 unsigned short *mode_ptr,win_seg; | 375 unsigned short *mode_ptr,win_seg; |
356 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; | 376 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; |
357 int err,fs_mode; | 377 int err,fs_mode,yuv_fmt; |
358 image_width = width; | 378 image_width = width; |
359 image_height = height; | 379 image_height = height; |
360 fs_mode = 0; | 380 fs_mode = 0; |
361 if(flags & 0x8) | 381 if(flags & 0x8) |
362 { | 382 { |
399 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n"); | 419 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n"); |
400 /* Find best mode here */ | 420 /* Find best mode here */ |
401 num_modes = 0; | 421 num_modes = 0; |
402 mode_ptr = vib.VideoModePtr; | 422 mode_ptr = vib.VideoModePtr; |
403 while(*mode_ptr++ != 0xffff) num_modes++; | 423 while(*mode_ptr++ != 0xffff) num_modes++; |
424 yuv_fmt = format == IMGFMT_YV12 || format == IMGFMT_I420 || format == IMGFMT_IYUV; | |
404 if(vo_dbpp) | 425 if(vo_dbpp) |
405 { | 426 { |
406 bpp = vo_dbpp; | 427 bpp = vo_dbpp; |
407 if(format == IMGFMT_YV12 || format == IMGFMT_I420 || format == IMGFMT_IYUV) | 428 if(yuv_fmt) yuv2rgb_init(bpp, MODE_RGB); |
408 yuv2rgb_init(bpp, MODE_RGB); | |
409 } | 429 } |
410 else | 430 else |
411 switch(format) | 431 switch(format) |
412 { | 432 { |
413 case IMGFMT_BGR8: | 433 case IMGFMT_BGR8: |
423 case IMGFMT_RGB16: bpp = 16; break; | 443 case IMGFMT_RGB16: bpp = 16; break; |
424 case IMGFMT_BGR24: | 444 case IMGFMT_BGR24: |
425 case IMGFMT_RGB24: bpp = 24; break; | 445 case IMGFMT_RGB24: bpp = 24; break; |
426 case IMGFMT_BGR32: | 446 case IMGFMT_BGR32: |
427 case IMGFMT_RGB32: bpp = 32; break; | 447 case IMGFMT_RGB32: bpp = 32; break; |
448 } | |
449 switch(bpp) | |
450 { | |
451 case 15: draw_alpha_fnc = draw_alpha_15; break; | |
452 case 16: draw_alpha_fnc = draw_alpha_16; break; | |
453 case 24: draw_alpha_fnc = draw_alpha_24; break; | |
454 case 32: draw_alpha_fnc = draw_alpha_32; break; | |
455 default: draw_alpha_fnc = draw_alpha_null; break; | |
428 } | 456 } |
429 if(verbose) | 457 if(verbose) |
430 { | 458 { |
431 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); | 459 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); |
432 printf("vo_vesa: Total modes found: %u\n",num_modes); | 460 printf("vo_vesa: Total modes found: %u\n",num_modes); |
555 if(verbose) | 583 if(verbose) |
556 printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n" | 584 printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n" |
557 ,image_width,image_height | 585 ,image_width,image_height |
558 ,video_mode_info.XResolution,video_mode_info.YResolution | 586 ,video_mode_info.XResolution,video_mode_info.YResolution |
559 ,x_offset,y_offset); | 587 ,x_offset,y_offset); |
560 if(!(yuv_buffer = malloc(image_width*image_height*bpp))) | 588 if(yuv_fmt) |
561 { | 589 if(!(yuv_buffer = malloc(image_width*image_height*bpp))) |
562 printf("vo_vesa: Can't allocate temporary buffer\n"); | 590 { |
563 return -1; | 591 printf("vo_vesa: Can't allocate temporary buffer\n"); |
564 } | 592 return -1; |
593 } | |
565 if((err=vbeSaveState(&init_state)) != VBE_OK) | 594 if((err=vbeSaveState(&init_state)) != VBE_OK) |
566 { | 595 { |
567 PRINT_VBE_ERR("vbeSaveState",err); | 596 PRINT_VBE_ERR("vbeSaveState",err); |
568 return -1; | 597 return -1; |
569 } | 598 } |
570 /* Below 'return -1' is impossible */ | |
571 if((err=vbeSetMode(video_mode,NULL)) != VBE_OK) | 599 if((err=vbeSetMode(video_mode,NULL)) != VBE_OK) |
572 { | 600 { |
573 PRINT_VBE_ERR("vbeSetMode",err); | 601 PRINT_VBE_ERR("vbeSetMode",err); |
574 return -1; | 602 return -1; |
575 } | 603 } |
576 /* Now we are in video mode!!!*/ | 604 /* Now we are in video mode!!!*/ |
605 /* Below 'return -1' is impossible */ | |
577 if(verbose) | 606 if(verbose) |
578 { | 607 { |
579 printf("vo_vesa: Graphics mode was activated\n"); | 608 printf("vo_vesa: Graphics mode was activated\n"); |
580 fflush(stdout); | 609 fflush(stdout); |
581 } | 610 } |