3 Video driver for SVGAlib
4 by Zoltan Mark Vician <se7en@sch.bme.hu>
5 Code started: Mon Apr 1 23:25:47 2001
6 Some changes by Matan Ziv-Av <matan@svgalib.org>
7 Compleat rewrite by Ivan Kalvachev 19 Mar 2003:
10 - 1bpp doesn't work right for me with '-double' and svgalib 1.4.3,
11 but works OK with svgalib 1.9.17
12 - The HW acceleration is not tested - svgalibs supports few chipsets,
13 and i don't have any of them. If it works for you then let me know.
14 I will remove this warning after confirm its status.
15 - retrace sync works only in doublebuffer mode.
16 - the retrace sync may slow down decoding a lot - mplayer is blocked while
18 - denoise3d fails to find common colorspace, use -vf denoise3d,scale
21 - let choose_best_mode take aspect into account
22 - set palette from mpi->palette or mpi->plane[1]
23 - make faster OSD black bars clear - need some OSD changes
24 - Make nicer CONFIG parsing
25 - change video mode logical width to match img->stride[0] - for HW only
37 #include "video_out.h"
38 #include "video_out_internal.h"
39 #include "fastmemcpy.h"
40 #include "osdep/getch2.h"
42 #include "vosub_vidix.h"
49 //#include "mp_image.h"
53 //silence warnings, probably it have to go in some global header
54 #define UNUSED(x) ((void)(x))
57 static void draw_alpha(int x0
, int y0
, int w
, int h
, unsigned char *src
,
58 unsigned char *srca
, int stride
);
59 static uint32_t get_image(mp_image_t
*mpi
);
65 #define CAP_ACCEL_CLEAR 8
66 #define CAP_ACCEL_PUTIMAGE 4
67 #define CAP_ACCEL_BACKGR 2
70 static uint8_t zerobuf
[8192];//used when clear screen with vga_draw
73 static int force_vm
=0;
74 static int force_native
=0;
75 static int sync_flip
=0;
76 static int blackbar_osd
=0;
77 static int cpage
,max_pages
,old_page
;
79 static vga_modeinfo
* modeinfo
;
80 static int mode_stride
; //keep it in case of vga_setlogicalwidth
81 static int stride_granularity
; //not yet used
83 static int mode_capabilities
;
85 static int image_width
,image_height
; // used by OSD
86 static int x_pos
, y_pos
;
89 int yoffset
;//y position of the page
90 int doffset
;//display start of the page
91 void * vbase
;//memory start address of the page
95 static const vo_info_t info
= {
98 "Ivan Kalvachev <iive@users.sf.net>",
103 static char vidix_name
[32] = "";
104 static vidix_grkey_t gr_key
;
110 //return number of 1'st free page or -1 if no free one
111 static inline int page_find_free(void){
113 for(i
=0;i
<max_pages
;i
++)
114 if(PageStore
[i
].locks
== PAGE_EMPTY
) return i
;
118 static int preinit(const char *arg
)
124 memset(zerobuf
,0,sizeof(zerobuf
));
125 force_vm
=force_native
=squarepix
=0;
131 if(memcmp(arg
,"vidix",5)==0) {
133 while(arg
[i
] && arg
[i
]!=':') i
++;
134 strncpy(vidix_name
, arg
+6, i
-6);
138 vidix_preinit(vidix_name
, &video_out_svga
);
141 if(!strncmp(arg
,"sq",2)) {
144 if( *arg
== ':' ) arg
++;
147 if(!strncmp(arg
,"native",6)) {
150 if( *arg
== ':' ) arg
++;
153 if(!strncmp(arg
,"bbosd",5)) {
156 if( *arg
== ':' ) arg
++;
159 if(!strncmp(arg
,"retrace",7)) {
162 if( *arg
== ':' ) arg
++;
167 while(arg
[i
] && arg
[i
]!=':')i
++;
172 force_vm
=vga_getmodenumber(s
);
174 if( mp_msg_test(MSGT_VO
,MSGL_V
) ) mp_msg(MSGT_VO
,MSGL_V
, "vo_svga: Forcing mode %i\n",force_vm
);
188 static void svga_clear_box(int x
,int y
,int w
,int h
){
192 if (mode_capabilities
&CAP_ACCEL_CLEAR
){
193 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) )
194 mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga: clearing box %d,%d - %d,%d with HW acceleration\n",
196 if(mode_capabilities
&CAP_ACCEL_BACKGR
)
197 vga_accel(ACCEL_SYNC
);
198 vga_accel(ACCEL_SETFGCOLOR
,0);//black
199 vga_accel(ACCEL_FILLBOX
,x
,y
,w
,h
);
202 if (mode_capabilities
& CAP_LINEAR
){
203 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) )
204 mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga: clearing box %d,%d - %d,%d with memset\n",x
,y
,w
,h
);
205 rgbplane
=PageStore
[0].vbase
+ (y
*mode_stride
) + (x
*modeinfo
->bytesperpixel
);
207 //i'm afraid that memcpy is better optimized than memset;)
208 fast_memcpy(rgbplane
,zerobuf
,w
*modeinfo
->bytesperpixel
);
209 // memset(rgbplane,0,w*modeinfo->bytesperpixel);
210 rgbplane
+=mode_stride
;
215 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) )
216 mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga: clearing box %d,%d - %d,%d with native draw \n",x
,y
,w
,h
);
217 if(modeinfo
->bytesperpixel
!=0) w
*=modeinfo
->bytesperpixel
;
219 vga_drawscansegment(zerobuf
,x
,y
+i
,w
);
223 static uint32_t svga_draw_image(mp_image_t
*mpi
){
226 uint8_t *rgbplane
, *base
;
230 if(mpi
->flags
& MP_IMGFLAG_DIRECT
){
231 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) )
232 mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga: drawing direct rendered surface\n");
233 cpage
=(uint32_t)mpi
->priv
;
234 assert((cpage
>=0)&&(cpage
<max_pages
));
235 return VO_TRUE
; //it's already done
237 // if (mpi->flags&MP_IMGFLAGS_DRAWBACK)
238 // return VO_TRUE;//direct render method 2
240 //find a free page to draw into
241 //if there is no one then use the current one
242 page
= page_find_free();
243 if(page
>=0) cpage
=page
;
244 PageStore
[cpage
].locks
=PAGE_BUSY
;
246 // these variables are used in loops
251 stride
= mpi
->stride
[0];
252 rgbplane
= mpi
->planes
[0] + y
*stride
+ (x
*mpi
->bpp
)/8;
256 if(mpi
->bpp
>= 8){//for modes<8 use only native
257 if( (mode_capabilities
&CAP_ACCEL_PUTIMAGE
) && (x
==0) && (w
==mpi
->width
) &&
258 (stride
== mode_stride
) ){ //only monolite image can be accelerated
259 w
=(stride
*8)/mpi
->bpp
;//we transfer pixels in the stride so the source
261 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) )
262 mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga: using HW PutImage (x=%d,y=%d,w=%d,h=%d)\n",x
,y
,w
,h
);
263 if(mode_capabilities
& CAP_ACCEL_BACKGR
)
264 vga_accel(ACCEL_SYNC
);
266 vga_accel(ACCEL_PUTIMAGE
,x
,y
+PageStore
[cpage
].yoffset
,w
,h
,rgbplane
);
270 if( mode_capabilities
&CAP_LINEAR
){
272 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) )
273 mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga: using Direct memcpy (x=%d,y=%d,w=%d,h=%d)\n",x
,y
,w
,h
);
274 bytesperline
=(w
*mpi
->bpp
)/8;
275 base
=PageStore
[cpage
].vbase
+ (y
*mode_stride
) + (x
*mpi
->bpp
)/8;
278 mem2agpcpy(base
,rgbplane
,bytesperline
);
290 length
=(w
*mpi
->bpp
)/8;
291 //one byte per pixel! svgalib innovation
292 if(mpi
->imgfmt
==IMGFMT_RG4B
|| mpi
->imgfmt
==IMGFMT_BG4B
) length
=w
;
294 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) )
295 mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga: using Native vga_draw(x=%d,y=%d,w=%d,h=%d)\n",x
,y
,w
,h
);
296 y
+=PageStore
[cpage
].yoffset
;//y position of the page beggining
298 vga_drawscansegment(rgbplane
,x
,y
+i
,length
);
305 static int bpp_from_vminfo(vga_modeinfo
*vminfo
){
306 switch(vminfo
->colors
){
310 case 32768: return 15;
311 case 65536: return 16;
312 case 1<<24: return 8*vminfo
->bytesperpixel
;
317 static int find_best_svga_mode(int req_w
,int req_h
, int req_bpp
){
318 int badness
,prev_badness
;
319 int bestmode
,lastmode
;
321 vga_modeinfo
*vminfo
;
322 //int best aspect mode // best linear mode // best normal mode (no modeX)
324 prev_badness
= 0;//take care of special case below
325 bestmode
= 0; //0 is the TEXT mode
326 lastmode
= vga_lastmodenumber();
327 for(i
=1;i
<=lastmode
;i
++){
328 vminfo
= vga_getmodeinfo(i
);
329 if( vminfo
== NULL
) continue;
330 if( mp_msg_test(MSGT_VO
,MSGL_DBG4
) )
331 mp_msg(MSGT_VO
,MSGL_DBG4
, "vo_svga: testing mode %d (%s)\n",i
,vga_getmodename(i
));
332 if( vga_hasmode(i
) == 0 ) continue;
333 if( req_bpp
!= bpp_from_vminfo(vminfo
) )continue;
334 if( (vminfo
->width
< req_w
) || (vminfo
->height
< req_h
) ) continue;
335 badness
=(vminfo
->width
* vminfo
->height
) - (req_h
* req_w
);
336 //put here aspect calculations
338 if( vminfo
->width
*3 != vminfo
->height
*4 ) continue;
340 if( bestmode
==0 || prev_badness
>= badness
){//modeX etc...
341 prev_badness
=badness
;
343 if( mp_msg_test(MSGT_VO
,MSGL_DBG4
) )
344 mp_msg(MSGT_VO
,MSGL_DBG4
, "vo_svga: found good mode %d with badness %d\n",i
,badness
);
350 static int control(uint32_t request
, void *data
, ...)
353 case VOCTRL_QUERY_FORMAT
:
354 return query_format(*((uint32_t*)data
));
355 case VOCTRL_DRAW_IMAGE
:
356 return svga_draw_image( (mp_image_t
*)data
);
357 case VOCTRL_GET_IMAGE
:
358 return get_image(data
);
364 case VOCTRL_SET_EQUALIZER
:
370 value
= va_arg(ap
, int);
373 return vidix_control(request
, data
, value
);
375 case VOCTRL_GET_EQUALIZER
:
381 value
= va_arg(ap
, int*);
384 return vidix_control(request
, data
, value
);
387 return vidix_control(request
, data
);
395 // This function is called to init the video driver for specific mode
397 static int config(uint32_t width
, uint32_t height
, uint32_t d_width
,
398 uint32_t d_height
, uint32_t flags
, char *title
,
400 int32_t req_w
= width
;// (d_width > 0 ? d_width : width);
401 int32_t req_h
= height
;// (d_height > 0 ? d_height : height);
402 uint16_t vid_mode
= 0;
406 if( mp_msg_test(MSGT_VO
,MSGL_V
) )
407 mp_msg(MSGT_VO
,MSGL_V
, "vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width
, height
,
408 d_width
, d_height
, flags
, title
, format
);
409 //Only RGB modes supported
410 if (!IMGFMT_IS_RGB(format
) && !IMGFMT_IS_BGR(format
)) {assert(0);return -1;}
411 req_bpp
= IMGFMT_BGR_DEPTH(format
);
413 if( vo_dbpp
!=0 && vo_dbpp
!=req_bpp
) {assert(0);return-1;}
416 if ( mp_msg_test(MSGT_VO
,MSGL_V
) ) {
417 mp_msg(MSGT_VO
,MSGL_V
, "vo_svga: Looking for the best resolution...\n");
418 mp_msg(MSGT_VO
,MSGL_V
, "vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w
,req_h
,req_bpp
);
420 vid_mode
=find_best_svga_mode(req_w
,req_h
,req_bpp
);
423 modeinfo
=vga_getmodeinfo(vid_mode
);
426 if(vga_hasmode(vid_mode
) == 0){
427 mp_msg(MSGT_VO
,MSGL_ERR
, MSGTR_LIBVO_SVGA_ForcedVidmodeNotAvailable
,
428 vid_mode
,vga_getmodename(vid_mode
));
431 modeinfo
=vga_getmodeinfo(vid_mode
);
432 if( (modeinfo
->width
< req_w
) || (modeinfo
->height
< req_h
) ){
433 mp_msg(MSGT_VO
,MSGL_ERR
, MSGTR_LIBVO_SVGA_ForcedVidmodeTooSmall
,
434 vid_mode
,vga_getmodename(vid_mode
));
438 mode_bpp
=bpp_from_vminfo(modeinfo
);
440 mp_msg(MSGT_VO
,MSGL_INFO
, MSGTR_LIBVO_SVGA_Vidmode
,
441 vid_mode
,modeinfo
->width
,modeinfo
->height
,mode_bpp
);
443 if (vga_setmode(vid_mode
) == -1) {
444 mp_msg(MSGT_VO
,MSGL_ERR
, MSGTR_LIBVO_SVGA_VgasetmodeFailed
,vid_mode
);
448 /* set 332 palette for 8 bpp */
452 vga_setpalette(i
, ((i
>>5)&7)*9, ((i
>>2)&7)*9, (i
&3)*21);
454 /* set 121 palette for 4 bpp */
455 else if(mode_bpp
==4){
458 vga_setpalette(i
, ((i
>>3)&1)*63, ((i
>>1)&3)*21, (i
&1)*63);
460 //if we change the logical width, we should know the granularity
461 stride_granularity
=8;//according to man vga_logicalwidth
462 if(modeinfo
->flags
& EXT_INFO_AVAILABLE
){
463 stride_granularity
=modeinfo
->linewidth_unit
;
465 //look for hardware acceleration
466 mode_capabilities
=0;//NATIVE;
467 if(!force_native
){//if we want to use only native drawers
468 if(modeinfo
->flags
& HAVE_EXT_SET
){//support for hwaccel interface
469 accflags
=vga_ext_set(VGA_EXT_AVAILABLE
,VGA_AVAIL_ACCEL
);
470 if(accflags
& ACCELFLAG_FILLBOX
) // clear screen
471 mode_capabilities
|=CAP_ACCEL_CLEAR
;
472 if(accflags
& ACCELFLAG_PUTIMAGE
)//support for mem->vid transfer
473 mode_capabilities
|=CAP_ACCEL_PUTIMAGE
;
474 if((accflags
& ACCELFLAG_SETMODE
) && (accflags
& ACCELFLAG_SYNC
)){
475 vga_accel(ACCEL_SETMODE
,BLITS_IN_BACKGROUND
);
476 mode_capabilities
|=CAP_ACCEL_BACKGR
;//can draw in backgraund
479 if(modeinfo
->flags
& IS_LINEAR
){
480 mode_capabilities
|=CAP_LINEAR
; //don't use bank & vga_draw
483 if(modeinfo
->flags
& CAPABLE_LINEAR
){
485 vid_mem_size
= vga_setlinearaddressing();
486 if(vid_mem_size
!= -1){
487 modeinfo
=vga_getmodeinfo(vid_mode
);//sometimes they change parameters
488 mode_capabilities
|=CAP_LINEAR
;
493 if(mode_capabilities
&CAP_LINEAR
){
494 mp_msg(MSGT_VO
,MSGL_INFO
, MSGTR_LIBVO_SVGA_VideoModeIsLinearAndMemcpyCouldBeUsed
);
496 if(mode_capabilities
&CAP_ACCEL_PUTIMAGE
){
497 mp_msg(MSGT_VO
,MSGL_INFO
, MSGTR_LIBVO_SVGA_VideoModeHasHardwareAcceleration
);
498 mp_msg(MSGT_VO
,MSGL_INFO
, MSGTR_LIBVO_SVGA_IfItWorksForYouIWouldLikeToKnow
);
501 //here is the place to handle strides for accel_ modes;
502 mode_stride
=modeinfo
->linewidth
;
503 //we may try to set a bigger stride for video mode that will match the mpi->stride,
504 //this way we will transfer more data, but HW put_image can do it in backgraund!
506 //now let's see how many pages we can use
507 max_pages
= modeinfo
->maxpixels
/(modeinfo
->height
* modeinfo
->width
);
508 if(max_pages
> MAXPAGES
) max_pages
= MAXPAGES
;
509 if(!vo_doublebuffering
) max_pages
=1;
510 //fill PageStore structs
515 GRAPH_MEM
=vga_getgraphmem();
516 for(i
=0;i
<max_pages
;i
++){
517 //calculate display offset
518 dof
= i
* modeinfo
->height
* modeinfo
->width
;
519 if(modeinfo
->bytesperpixel
!= 0) dof
*=modeinfo
->bytesperpixel
;
520 //check video chip limitations
521 if( dof
!= (dof
& modeinfo
->startaddressrange
) ){
522 max_pages
=i
;//page 0 will never come here
525 PageStore
[i
].yoffset
= i
* modeinfo
->height
;//starting y offset
526 PageStore
[i
].vbase
= GRAPH_MEM
+ i
*modeinfo
->height
*mode_stride
; //memory base address
527 PageStore
[i
].doffset
= dof
; //display offset
528 PageStore
[i
].locks
= PAGE_EMPTY
;
532 mp_msg(MSGT_VO
,MSGL_INFO
, MSGTR_LIBVO_SVGA_VideoModeHas
,max_pages
);
534 if(modeinfo
->bytesperpixel
!=0)
535 vga_claimvideomemory(max_pages
* modeinfo
->height
* modeinfo
->width
* modeinfo
->bytesperpixel
);
537 vga_claimvideomemory(max_pages
* modeinfo
->height
* modeinfo
->width
* mode_bpp
/ 8);
540 svga_clear_box(0,0,modeinfo
->width
,modeinfo
->height
* max_pages
);
544 x_pos
= (modeinfo
->width
- req_w
) / 2;
545 y_pos
= (modeinfo
->height
- req_h
) / 2;
546 x_pos
&= ~(15); //align x offset position to 16 pixels
547 mp_msg(MSGT_VO
,MSGL_INFO
, MSGTR_LIBVO_SVGA_CenteringImageStartAt
,x_pos
,y_pos
);
552 vidix_init(width
, height
, x_pos
, y_pos
, modeinfo
->width
, modeinfo
->height
,
553 format
, mode_bpp
, modeinfo
->width
,modeinfo
->height
);
554 mp_msg(MSGT_VO
,MSGL_INFO
, MSGTR_LIBVO_SVGA_UsingVidix
,width
,height
,
555 modeinfo
->width
,modeinfo
->height
);
558 if(vidix_grkey_support()){
559 vidix_grkey_get(&gr_key
);
560 gr_key
.key_op
= KEYS_PUT
;
561 if (!(vo_colorkey
& 0xFF000000)) {
562 gr_key
.ckey
.op
= CKEY_TRUE
;
563 gr_key
.ckey
.red
= (vo_colorkey
& 0x00FF0000) >> 16;
564 gr_key
.ckey
.green
= (vo_colorkey
& 0x0000FF00) >> 8;
565 gr_key
.ckey
.blue
= vo_colorkey
& 0x000000FF;
567 gr_key
.ckey
.op
= CKEY_FALSE
;
568 vidix_grkey_set(&gr_key
);
573 vga_setdisplaystart(0);
577 static int draw_slice(uint8_t *image
[],int stride
[],
578 int w
, int h
, int x
, int y
) {
580 UNUSED(image
);UNUSED(stride
);
584 return VO_ERROR
;//this is yv12 only -> vf_scale should do all transforms
587 static int draw_frame(uint8_t *src
[]) {
590 return VO_ERROR
;//this one should not be called
593 static void draw_osd(void)
595 if( mp_msg_test(MSGT_VO
,MSGL_DBG4
) )
596 mp_msg(MSGT_VO
,MSGL_DBG4
, "vo_svga: draw_osd()\n");
597 //only modes with bytesperpixel>0 can draw OSD
598 if(modeinfo
->bytesperpixel
==0) return;
599 if(!(mode_capabilities
&CAP_LINEAR
)) return;//force_native will remove OSD
605 svga_clear_box(0,0 + PageStore
[cpage
].yoffset
,
606 modeinfo
->width
, y_pos
);
607 svga_clear_box(0, image_height
+ y_pos
+ PageStore
[cpage
].yoffset
,
608 modeinfo
->width
, modeinfo
->height
-(image_height
+ y_pos
));
609 svga_clear_box(0, y_pos
+ PageStore
[cpage
].yoffset
,
610 x_pos
, image_height
);
611 svga_clear_box(image_width
+ x_pos
, y_pos
+ PageStore
[cpage
].yoffset
,
612 modeinfo
->width
-(x_pos
+image_width
), image_height
);
613 // vo_remove_text(modeinfo->width, modeinfo->height, clear_alpha);
614 vo_draw_text(modeinfo
->width
, modeinfo
->height
, draw_alpha
);
616 vo_draw_text(image_width
, image_height
, draw_alpha
);
620 static void flip_page(void) {
621 PageStore
[old_page
].locks
=PAGE_EMPTY
;
622 PageStore
[cpage
].locks
=PAGE_BUSY
;
624 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) )
625 mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga: viewing page %d\n",cpage
);
626 if(sync_flip
&& old_page
!=cpage
){
627 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) ) mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga:vga_waitretrace\n");
630 vga_setdisplaystart(PageStore
[cpage
].doffset
);
632 old_page
=cpage
;//cpage will be overwriten on next draw_image
635 static void check_events(void) {
638 static void uninit(void) {
641 if(vidix_name
[0])vidix_term();
646 /* --------------------------------------------------------------------- */
647 static int query_format(uint32_t format
) {
648 int32_t req_bpp
,flags
;
650 vga_modeinfo
* vminfo
;
652 if ( mp_msg_test(MSGT_VO
,MSGL_DBG4
) )
653 mp_msg(MSGT_VO
,MSGL_DBG4
, "vo_svga: query_format=%X \n",format
);
654 //only RGB modes supported
655 if( (!IMGFMT_IS_RGB(format
)) && (!IMGFMT_IS_BGR(format
)) ) return 0;
657 // Reject different endian
658 #ifdef WORDS_BIGENDIAN
659 if (IMGFMT_IS_BGR(format
)) return 0;
661 if (IMGFMT_IS_RGB(format
)) return 0;
664 //svgalib supports only BG4B! if we want BGR4 we have to emulate it (sw)
665 if( format
==IMGFMT_BGR4
|| format
==IMGFMT_RGB4
) return 0;
666 req_bpp
= IMGFMT_RGB_DEPTH(format
);
667 if( vo_dbpp
>0 && vo_dbpp
!=req_bpp
) return 0; //support -bpp options
669 lastmode
= vga_lastmodenumber();
670 for(i
=1;i
<=lastmode
;i
++){
671 vminfo
= vga_getmodeinfo(i
);
672 if( vminfo
== NULL
) continue;
673 if( vga_hasmode(i
) == 0 ) continue;
674 if( req_bpp
!= bpp_from_vminfo(vminfo
) ) continue;
675 if( (force_vm
> 0) && (force_vm
!= i
) ) continue;//quick hack
676 flags
= VFCAP_CSP_SUPPORTED
|
677 VFCAP_CSP_SUPPORTED_BY_HW
|
680 if(req_bpp
>8) flags
|=VFCAP_OSD
;
686 static void draw_alpha(int x0
, int y0
, int w
, int h
, unsigned char *src
,
687 unsigned char *srca
, int stride
) {
690 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) )
691 mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga: draw_alpha(x0=%d,y0=%d,w=%d,h=%d,src=%p,srca=%p,stride=%d\n",
692 x0
,y0
,w
,h
,src
,srca
,stride
);
694 //drawing in the image, so place the stuff there
699 if( mp_msg_test(MSGT_VO
,MSGL_DBG4
) )
700 mp_msg(MSGT_VO
,MSGL_DBG4
, "vo_svga: OSD draw in page %d\n",cpage
);
701 base
=PageStore
[cpage
].vbase
+ y0
*mode_stride
+ x0
*modeinfo
->bytesperpixel
;
704 vo_draw_alpha_rgb32(w
, h
, src
, srca
, stride
, base
, mode_stride
);
707 vo_draw_alpha_rgb24(w
, h
, src
, srca
, stride
, base
, mode_stride
);
710 vo_draw_alpha_rgb16(w
, h
, src
, srca
, stride
, base
, mode_stride
);
713 vo_draw_alpha_rgb15(w
, h
, src
, srca
, stride
, base
, mode_stride
);
718 static uint32_t get_image(mp_image_t
*mpi
){
721 if(!IMGFMT_IS_BGR(mpi
->imgfmt
) && !IMGFMT_IS_RGB(mpi
->imgfmt
) ){
722 assert(0);//should never happen
727 ( (mpi
->type
!= MP_IMGTYPE_STATIC
) && (mpi
->type
!= MP_IMGTYPE_TEMP
)) ||
728 (mpi
->flags
& MP_IMGFLAG_PLANAR
) ||
729 (mpi
->flags
& MP_IMGFLAG_YUV
)
733 //reading from video memory is horribly slow
734 if( !(mpi
->flags
& MP_IMGFLAG_READABLE
) && vo_directrendering
&&
735 (mode_capabilities
& CAP_LINEAR
) ){
737 //find free page and reserve it
738 page
=page_find_free();
740 PageStore
[page
].locks
=PAGE_BUSY
;
742 mpi
->flags
|= MP_IMGFLAG_DIRECT
;
743 mpi
->stride
[0] = mode_stride
;
744 mpi
->planes
[0] = PageStore
[page
].vbase
+
745 y_pos
*mode_stride
+ (x_pos
*mpi
->bpp
)/8;
746 mpi
->priv
=(void *)page
;
747 if( mp_msg_test(MSGT_VO
,MSGL_DBG3
) )
748 mp_msg(MSGT_VO
,MSGL_DBG3
, "vo_svga: direct render allocated! page=%d\n",page
);