comparison libvo/vo_vesa.c @ 4601:8cda24d7f074

Make code simple. Use swScaler even for fastmemcpy purposes :)
author nick
date Sat, 09 Feb 2002 10:24:44 +0000
parents c35d7ce151b3
children 95fa3901cafc
comparison
equal deleted inserted replaced
4600:bcaeff069237 4601:8cda24d7f074
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"
44 43
45 LIBVO_EXTERN(vesa) 44 LIBVO_EXTERN(vesa)
46 extern int verbose; 45 extern int verbose;
47 46
48 #define MAX_BUFFERS 3 47 #define MAX_BUFFERS 3
90 static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */ 89 static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */
91 static unsigned video_mode; /* selected video mode for playback */ 90 static unsigned video_mode; /* selected video mode for playback */
92 static struct VesaModeInfoBlock video_mode_info; 91 static struct VesaModeInfoBlock video_mode_info;
93 static int flip_trigger = 0; 92 static int flip_trigger = 0;
94 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); 93 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride);
95 static void (*rgb2rgb_fnc)(const uint8_t *src,uint8_t *dst,uint32_t src_size);
96 94
97 /* multibuffering */ 95 /* multibuffering */
98 uint8_t* video_base; /* should be never changed */ 96 uint8_t* video_base; /* should be never changed */
99 uint32_t multi_buff[MAX_BUFFERS]; /* contains offsets of buffers */ 97 uint32_t multi_buff[MAX_BUFFERS]; /* contains offsets of buffers */
100 uint8_t multi_size=0; /* total number of buffers */ 98 uint8_t multi_size=0; /* total number of buffers */
408 srcStride[0] = srcW*2; 406 srcStride[0] = srcW*2;
409 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); 407 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE();
410 sws->swScale(sws,src,srcStride,0,srcH,dst,dstStride); 408 sws->swScale(sws,src,srcStride,0,srcH,dst,dstStride);
411 flip_trigger=1; 409 flip_trigger=1;
412 } 410 }
413 else if(!HAS_DGA()) __vbeCopyData(src[0]);
414 return 0; 411 return 0;
415 } 412 }
416 413
417 #define SUBDEV_NODGA 0x00000001UL 414 #define SUBDEV_NODGA 0x00000001UL
418 #define SUBDEV_FORCEDGA 0x00000002UL 415 #define SUBDEV_FORCEDGA 0x00000002UL
530 struct VesaModeInfoBlock vmib; 527 struct VesaModeInfoBlock vmib;
531 size_t i,num_modes; 528 size_t i,num_modes;
532 uint32_t w,h; 529 uint32_t w,h;
533 unsigned short *mode_ptr,win_seg; 530 unsigned short *mode_ptr,win_seg;
534 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; 531 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX;
535 int err,fs_mode,yuv_fmt,use_scaler=0; 532 int err,fs_mode,use_scaler=0;
536 dstW = width; 533 srcW = dstW = width;
537 dstH = height; 534 srcH = dstH = height;
538 fs_mode = 0; 535 fs_mode = 0;
539 rgb2rgb_fnc = NULL;
540 if(subdev_flags == 0xFFFFFFFEUL) 536 if(subdev_flags == 0xFFFFFFFEUL)
541 { 537 {
542 printf("vo_vesa: detected internal fatal error: init is called before preinit\n"); 538 printf("vo_vesa: detected internal fatal error: init is called before preinit\n");
543 return -1; 539 return -1;
544 } 540 }
584 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n"); 580 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n");
585 /* Find best mode here */ 581 /* Find best mode here */
586 num_modes = 0; 582 num_modes = 0;
587 mode_ptr = vib.VideoModePtr; 583 mode_ptr = vib.VideoModePtr;
588 while(*mode_ptr++ != 0xffff) num_modes++; 584 while(*mode_ptr++ != 0xffff) num_modes++;
589 yuv_fmt = 0;
590 switch(format) 585 switch(format)
591 { 586 {
592 case IMGFMT_BGR8: 587 case IMGFMT_BGR8:
593 case IMGFMT_RGB8: bpp = 8; break; 588 case IMGFMT_RGB8: bpp = 8; break;
594 case IMGFMT_BGR15: 589 case IMGFMT_BGR15:
597 case IMGFMT_RGB16: bpp = 16; break; 592 case IMGFMT_RGB16: bpp = 16; break;
598 case IMGFMT_BGR24: 593 case IMGFMT_BGR24:
599 case IMGFMT_RGB24: bpp = 24; break; 594 case IMGFMT_RGB24: bpp = 24; break;
600 case IMGFMT_BGR32: 595 case IMGFMT_BGR32:
601 case IMGFMT_RGB32: bpp = 32; break; 596 case IMGFMT_RGB32: bpp = 32; break;
602 default: bpp = 16; yuv_fmt = 1; break; 597 default: bpp = 16; break;
603 } 598 }
604 srcBpp = bpp; 599 srcBpp = bpp;
605 srcFourcc = format; 600 srcFourcc = format;
606 if(vo_dbpp) bpp = vo_dbpp; 601 if(vo_dbpp) bpp = vo_dbpp;
607 switch(bpp) 602 switch(bpp)
620 break; 615 break;
621 default: draw_alpha_fnc = draw_alpha_null; 616 default: draw_alpha_fnc = draw_alpha_null;
622 dstFourcc = IMGFMT_BGR16; 617 dstFourcc = IMGFMT_BGR16;
623 break; 618 break;
624 } 619 }
625 if(srcFourcc != dstFourcc) yuv_fmt=1;
626 if(verbose) 620 if(verbose)
627 { 621 {
628 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); 622 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format));
629 printf("vo_vesa: Total modes found: %u\n",num_modes); 623 printf("vo_vesa: Total modes found: %u\n",num_modes);
630 mode_ptr = vib.VideoModePtr; 624 mode_ptr = vib.VideoModePtr;
637 } 631 }
638 mode_ptr = vib.VideoModePtr; 632 mode_ptr = vib.VideoModePtr;
639 if(use_scaler) 633 if(use_scaler)
640 { 634 {
641 dstW = d_width; 635 dstW = d_width;
642 dstH= d_height; 636 dstH = d_height;
643 } 637 }
644 if(vo_screenwidth) w = vo_screenwidth; 638 if(vo_screenwidth) w = vo_screenwidth;
645 else w = max(dstW,width); 639 else w = max(dstW,width);
646 if(vo_screenheight) h = vo_screenheight; 640 if(vo_screenheight) h = vo_screenheight;
647 else h = max(dstH,height); 641 else h = max(dstH,height);
700 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n" 694 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n"
701 ,best_mode_idx,video_mode,video_mode_info.XResolution 695 ,best_mode_idx,video_mode,video_mode_info.XResolution
702 ,video_mode_info.YResolution,dstBpp); 696 ,video_mode_info.YResolution,dstBpp);
703 dstBpp = video_mode_info.BitsPerPixel; 697 dstBpp = video_mode_info.BitsPerPixel;
704 if(subdev_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0; 698 if(subdev_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0;
705 if(use_scaler || fs_mode || yuv_fmt) 699 if(use_scaler || fs_mode)
706 { 700 {
707 /* software scale */ 701 /* software scale */
708 if(use_scaler > 1) 702 if(use_scaler > 1)
709 { 703 {
710 aspect_save_orig(width,height); 704 aspect_save_orig(width,height);
716 if(fs_mode) 710 if(fs_mode)
717 { 711 {
718 dstW = video_mode_info.XResolution; 712 dstW = video_mode_info.XResolution;
719 dstH = video_mode_info.YResolution; 713 dstH = video_mode_info.YResolution;
720 } 714 }
721 srcW=width;
722 srcH=height;
723 use_scaler = 1; 715 use_scaler = 1;
724 if(!lvo_name 716 }
717 if(!lvo_name
725 #ifdef CONFIG_VIDIX 718 #ifdef CONFIG_VIDIX
726 && !vidix_name 719 && !vidix_name
727 #endif 720 #endif
728 ) 721 )
729 { 722 {
730 sws = getSwsContextFromCmdLine(srcW,srcH,srcFourcc,dstW,dstH,dstFourcc); 723 sws = getSwsContextFromCmdLine(srcW,srcH,srcFourcc,dstW,dstH,dstFourcc);
731 if(!sws) 724 if(!sws)
732 { 725 {
733 printf("vo_vesa: Can't initialize SwScaler\n"); 726 printf("vo_vesa: Can't initialize SwScaler\n");
734 return -1; 727 return -1;
735 } 728 }
736 else if(verbose) printf("vo_vesa: Using SW Scaler-YUV convertor\n"); 729 else if(verbose) printf("vo_vesa: Using SW BES emulator\n");
737 }
738 } 730 }
739 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE) 731 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE)
740 win.idx = 0; /* frame A */ 732 win.idx = 0; /* frame A */
741 else 733 else
742 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE) 734 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE)
808 cpy_blk_fnc = __vbeCopyBlockFast; 800 cpy_blk_fnc = __vbeCopyBlockFast;
809 } 801 }
810 else 802 else
811 { 803 {
812 cpy_blk_fnc = __vbeCopyBlock; 804 cpy_blk_fnc = __vbeCopyBlock;
813 if((yuv_fmt || rgb2rgb_fnc) && !lvo_name 805 if(!lvo_name
814 #ifdef CONFIG_VIDIX 806 #ifdef CONFIG_VIDIX
815 && !vidix_name 807 && !vidix_name
816 #endif 808 #endif
817 ) 809 )
818 { 810 {
819 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*dstBpp))) 811 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*dstBpp)))
820 { 812 {
821 printf("vo_vesa: Can't allocate temporary buffer\n"); 813 printf("vo_vesa: Can't allocate temporary buffer\n");
822 return -1; 814 return -1;