Mercurial > mplayer.hg
changeset 1647:22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
author | atlka |
---|---|
date | Thu, 23 Aug 2001 11:04:23 +0000 |
parents | 231ff06582f1 |
children | 6185549842e7 |
files | libvo/vo_x11.c libvo/vo_xv.c |
diffstat | 2 files changed, 65 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/vo_x11.c Thu Aug 23 07:53:49 2001 +0000 +++ b/libvo/vo_x11.c Thu Aug 23 11:04:23 2001 +0000 @@ -49,6 +49,7 @@ /* private prototypes */ static void Display_Image ( XImage * myximage,unsigned char *ImageData ); +static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); /* since it doesn't seem to be defined on some platforms */ int XShmGetEventBase( Display* ); @@ -113,6 +114,25 @@ vo_x11_check_events(mDisplay); } +static void draw_alpha_32(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ + vo_draw_alpha_rgb32(w,h,src,srca,stride,ImageData+4*(y0*image_width+x0),4*image_width); +} + +static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ + vo_draw_alpha_rgb24(w,h,src,srca,stride,ImageData+3*(y0*image_width+x0),3*image_width); +} + +static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ + vo_draw_alpha_rgb16(w,h,src,srca,stride,ImageData+2*(y0*image_width+x0),2*image_width); +} + +static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ + vo_draw_alpha_rgb15(w,h,src,srca,stride,ImageData+2*(y0*image_width+x0),2*image_width); +} + +static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ +} + static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d_height,uint32_t flags,char *title,uint32_t format ) { // int screen; @@ -316,7 +336,17 @@ DeInstallXErrorHandler(); #endif - bpp=myximage->bits_per_pixel; + switch ((bpp=myximage->bits_per_pixel)){ + case 24: draw_alpha_fnc=draw_alpha_24; break; + case 32: draw_alpha_fnc=draw_alpha_32; break; + case 15: + case 16: if (depth==15) + draw_alpha_fnc=draw_alpha_15; + else + draw_alpha_fnc=draw_alpha_16; + break; + default: draw_alpha_fnc=draw_alpha_null; + } // printf( "X11 color mask: R:%lX G:%lX B:%lX\n",myximage->red_mask,myximage->green_mask,myximage->blue_mask ); @@ -334,8 +364,9 @@ } if( format==IMGFMT_YV12 ) yuv2rgb_init( ( depth == 24 ) ? bpp : depth,mode ); - + XSelectInput( mDisplay,mywindow,StructureNotifyMask | KeyPressMask ); + X_already_started++; // vo_initthread( mThread ); @@ -385,26 +416,8 @@ #endif } -static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ - switch(bpp){ - case 24: - vo_draw_alpha_rgb24(w,h,src,srca,stride,ImageData+3*(y0*image_width+x0),3*image_width); - break; - case 32: - vo_draw_alpha_rgb32(w,h,src,srca,stride,ImageData+4*(y0*image_width+x0),4*image_width); - break; - case 15: - case 16: - if(depth==15) - vo_draw_alpha_rgb15(w,h,src,srca,stride,ImageData+2*(y0*image_width+x0),2*image_width); - else - vo_draw_alpha_rgb16(w,h,src,srca,stride,ImageData+2*(y0*image_width+x0),2*image_width); - break; - } -} - static void draw_osd(void) -{ vo_draw_text(image_width,image_height,draw_alpha); } +{ vo_draw_text(image_width,image_height,draw_alpha_fnc); } static void flip_page( void ){ Display_Image( myximage,ImageData );
--- a/libvo/vo_xv.c Thu Aug 23 07:53:49 2001 +0000 +++ b/libvo/vo_xv.c Thu Aug 23 11:04:23 2001 +0000 @@ -94,6 +94,25 @@ static uint32_t mdwidth,mdheight; #endif + +static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); + +static void draw_alpha_yv12(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ + vo_draw_alpha_yv12(w,h,src,srca,stride,xvimage[current_buf]->data+image_width*y0+x0,image_width); +} + +static void draw_alpha_yuy2(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ + vo_draw_alpha_yuy2(w,h,src,srca,stride,xvimage[current_buf]->data+2*(image_width*y0+x0),2*image_width); +} + +static void draw_alpha_uyvy(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ + vo_draw_alpha_yuy2(w,h,src,srca,stride,xvimage[current_buf]->data+2*(image_width*y0+x0)+1,2*image_width); +} + +static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ +} + + /* * connect to server, create and map window, * allocate colors and (shared) memory @@ -215,8 +234,18 @@ if (xv_port != 0) { printf( "using Xvideo port %d for hw scaling\n",xv_port ); + + switch (xv_format){ + case IMGFMT_YV12: + case IMGFMT_I420: + case IMGFMT_IYUV: draw_alpha_fnc=draw_alpha_yv12; break; + case IMGFMT_YUY2: + case IMGFMT_YVYU: draw_alpha_fnc=draw_alpha_yuy2; break; + case IMGFMT_UYVY: draw_alpha_fnc=draw_alpha_uyvy; break; + default: draw_alpha_fnc=draw_alpha_null; + } - for(current_buf=0;current_buf<num_buffers;++current_buf) + for(current_buf=0;current_buf<num_buffers;++current_buf) allocate_xvimage(current_buf); current_buf=0; @@ -307,29 +336,8 @@ } } - -static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ - int x,y; - - switch (xv_format) { - case IMGFMT_YV12: - case IMGFMT_I420: - case IMGFMT_IYUV: - vo_draw_alpha_yv12(w,h,src,srca,stride,xvimage[current_buf]->data+image_width*y0+x0,image_width); - break; - case IMGFMT_YUY2: - case IMGFMT_YVYU: - vo_draw_alpha_yuy2(w,h,src,srca,stride,xvimage[current_buf]->data+2*(image_width*y0+x0),2*image_width); - break; - case IMGFMT_UYVY: - vo_draw_alpha_yuy2(w,h,src,srca,stride,xvimage[current_buf]->data+2*(image_width*y0+x0)+1,2*image_width); - break; - } - -} - static void draw_osd(void) -{ vo_draw_text(image_width,image_height,draw_alpha);} +{ vo_draw_text(image_width,image_height,draw_alpha_fnc);} static void flip_page(void) {