From 2f46205ad3ecbd60fa17823290e3c4f91c8b407e Mon Sep 17 00:00:00 2001 From: arpi_esp Date: Tue, 10 Apr 2001 02:29:38 +0000 Subject: OSD alpha renderers moved to osd.c git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@327 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/Makefile | 4 +- libvo/mga_common.c | 35 ++------------ libvo/osd.c | 115 +++++++++++++++++++++++++++++++++++++++++++++ libvo/osd_template.c | 115 +++++++++++++++++++++++++++++++++++++++++++++ libvo/video_out_internal.h | 7 +++ libvo/vo_x11.c | 34 ++++++-------- libvo/vo_xv.c | 36 +++----------- libvo/x11_common.c | 2 +- 8 files changed, 265 insertions(+), 83 deletions(-) create mode 100644 libvo/osd.c create mode 100644 libvo/osd_template.c diff --git a/libvo/Makefile b/libvo/Makefile index 3fd52fb9ba..a2387fbc7c 100644 --- a/libvo/Makefile +++ b/libvo/Makefile @@ -3,8 +3,8 @@ include config.mak LIBNAME = libvo.a -SRCS=font_load.c rgb15to16mmx.c yuv2rgb_mmx.c yuv2rgb.c video_out.c vo_null.c vo_pgm.c vo_md5.c vo_odivx.c x11_common.c $(OPTIONAL_SRCS) -OBJS=font_load.o rgb15to16mmx.o yuv2rgb_mmx.o yuv2rgb.o video_out.o vo_null.o vo_pgm.o vo_md5.o vo_odivx.o x11_common.o $(OPTIONAL_OBJS) +SRCS=osd.c font_load.c rgb15to16mmx.c yuv2rgb_mmx.c yuv2rgb.c video_out.c vo_null.c vo_pgm.c vo_md5.c vo_odivx.c x11_common.c $(OPTIONAL_SRCS) +OBJS=osd.o font_load.o rgb15to16mmx.o yuv2rgb_mmx.o yuv2rgb.o video_out.o vo_null.o vo_pgm.o vo_md5.o vo_odivx.o x11_common.o $(OPTIONAL_OBJS) CFLAGS = $(OPTFLAGS) -I. -I.. -DMPG12PLAY # -I/usr/X11R6/include/ diff --git a/libvo/mga_common.c b/libvo/mga_common.c index 4a97da69d0..11a56f5086 100644 --- a/libvo/mga_common.c +++ b/libvo/mga_common.c @@ -10,37 +10,10 @@ static int f; static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ int x,y; uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31; - - if (mga_vid_config.format==MGA_VID_FORMAT_YV12){ - - for(y=0;y>8; - if(srca[x]) - dst[x]=((dst[x]*srca[x])>>8)+src[x]; - //dst[x]=(dst[x]*(srca[x]^255)+src[x]*(srca[x]))>>8; - } - src+=stride; - srca+=stride; - } - - } else { - - for(y=0;y>8; - if(srca[x]) - dst[2*x]=((dst[2*x]*srca[x])>>8)+src[x]; - //dst[2*x]=(dst[2*x]*(srca[x]^255)+src[x]*(srca[x]))>>8; - } - src+=stride; - srca+=stride; - } - - } - + if (mga_vid_config.format==MGA_VID_FORMAT_YV12) + vo_draw_alpha_yv12(w,h,src,srca,stride,vid_data+bespitch*y0+x0,bespitch); + else + vo_draw_alpha_yuy2(w,h,src,srca,stride,vid_data+2*(bespitch*y0+x0),2*bespitch); } diff --git a/libvo/osd.c b/libvo/osd.c new file mode 100644 index 0000000000..b767f88f18 --- /dev/null +++ b/libvo/osd.c @@ -0,0 +1,115 @@ +// Generic alpha renderers for all YUV modes and RGB depths. +// These are "reference implementations", should be optimized later (MMX, etc) + +void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>8)+src[x]; + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + +void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>8)+src[x]; + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + +void vo_draw_alpha_rgb24(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>8)+src[x]; + dst[1]=((dst[1]*srca[x])>>8)+src[x]; + dst[2]=((dst[2]*srca[x])>>8)+src[x]; + } + dst+=3; // 24bpp + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + +void vo_draw_alpha_rgb32(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>8)+src[x]; + dstbase[4*x+1]=((dstbase[4*x+1]*srca[x])>>8)+src[x]; + dstbase[4*x+2]=((dstbase[4*x+2]*srca[x])>>8)+src[x]; + } + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + +void vo_draw_alpha_rgb15(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>5)&0x1F; + unsigned char b=(dst[x]>>10)&0x1F; + r=(((r*srca[x])>>5)+src[x])>>3; + g=(((g*srca[x])>>5)+src[x])>>3; + b=(((b*srca[x])>>5)+src[x])>>3; + dst[x]=(b<<10)|(g<<5)|r; + } + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + +void vo_draw_alpha_rgb16(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>5)&0x3F; + unsigned char b=(dst[x]>>11)&0x1F; + r=(((r*srca[x])>>5)+src[x])>>3; + g=(((g*srca[x])>>6)+src[x])>>2; + b=(((b*srca[x])>>5)+src[x])>>3; + dst[x]=(b<<11)|(g<<5)|r; + } + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + diff --git a/libvo/osd_template.c b/libvo/osd_template.c new file mode 100644 index 0000000000..b767f88f18 --- /dev/null +++ b/libvo/osd_template.c @@ -0,0 +1,115 @@ +// Generic alpha renderers for all YUV modes and RGB depths. +// These are "reference implementations", should be optimized later (MMX, etc) + +void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>8)+src[x]; + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + +void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>8)+src[x]; + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + +void vo_draw_alpha_rgb24(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>8)+src[x]; + dst[1]=((dst[1]*srca[x])>>8)+src[x]; + dst[2]=((dst[2]*srca[x])>>8)+src[x]; + } + dst+=3; // 24bpp + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + +void vo_draw_alpha_rgb32(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>8)+src[x]; + dstbase[4*x+1]=((dstbase[4*x+1]*srca[x])>>8)+src[x]; + dstbase[4*x+2]=((dstbase[4*x+2]*srca[x])>>8)+src[x]; + } + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + +void vo_draw_alpha_rgb15(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>5)&0x1F; + unsigned char b=(dst[x]>>10)&0x1F; + r=(((r*srca[x])>>5)+src[x])>>3; + g=(((g*srca[x])>>5)+src[x])>>3; + b=(((b*srca[x])>>5)+src[x])>>3; + dst[x]=(b<<10)|(g<<5)|r; + } + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + +void vo_draw_alpha_rgb16(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ + int y; + for(y=0;y>5)&0x3F; + unsigned char b=(dst[x]>>11)&0x1F; + r=(((r*srca[x])>>5)+src[x])>>3; + g=(((g*srca[x])>>6)+src[x])>>2; + b=(((b*srca[x])>>5)+src[x])>>3; + dst[x]=(b<<11)|(g<<5)|r; + } + } + src+=srcstride; + srca+=srcstride; + dstbase+=dststride; + } + return; +} + diff --git a/libvo/video_out_internal.h b/libvo/video_out_internal.h index cefd39d4e5..19d0b09762 100644 --- a/libvo/video_out_internal.h +++ b/libvo/video_out_internal.h @@ -41,3 +41,10 @@ static uint32_t query_format(uint32_t format); check_events,\ uninit,\ }; + +void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride); +void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride); + + + + diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c index ae39783e43..fa29809046 100644 --- a/libvo/vo_x11.c +++ b/libvo/vo_x11.c @@ -385,27 +385,21 @@ static void Display_Image( XImage *myximage,uint8_t *ImageData ) } static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ - int dbpp=( bpp+7 )/8; - int x,y; - - for(y=0;y>8; - if(srca[x]){ - dst[0]=((dst[0]*srca[x])>>8)+src[x]; - dst[1]=((dst[1]*srca[x])>>8)+src[x]; - dst[2]=((dst[2]*srca[x])>>8)+src[x]; - //dst[0]=(dst[0]*(srca[x]^255)+src[x]*(srca[x]))>>8; - //dst[1]=(dst[1]*(srca[x]^255)+src[x]*(srca[x]))>>8; - //dst[2]=(dst[2]*(srca[x]^255)+src[x]*(srca[x]))>>8; - } - dst+=dbpp; - } - src+=stride; - srca+=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; } - } diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index b7e1e18970..6f54335a9b 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -256,38 +256,16 @@ static void check_events(void) } +//void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride); +//void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride); + static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ int x,y; - if (xv_format==IMGFMT_YV12){ - - for(y=0;ydata + image_width * (y+y0) + x0; - for(x=0;x>8; - if(srca[x]) -// dst[x]=(dst[x]*(srca[x]^255)+src[x]*(srca[x]))>>8; - dst[x]=((dst[x]*srca[x])>>8)+src[x]; - } - src+=stride; - srca+=stride; - } - - } else { - - for(y=0;ydata + 2*(image_width * (y+y0) + x0); - for(x=0;x>8; - if(srca[x]) -// dst[2*x]=(dst[2*x]*(srca[x]^255)+src[x]*(srca[x]))>>8; - dst[2*x]=((dst[2*x]*srca[x])>>8)+src[x]; - } - src+=stride; - srca+=stride; - } - - } + if (xv_format==IMGFMT_YV12) + vo_draw_alpha_yv12(w,h,src,srca,stride,xvimage[0]->data+image_width*y0+x0,image_width); + else + vo_draw_alpha_yuy2(w,h,src,srca,stride,xvimage[0]->data+2*(image_width*y0+x0),2*image_width); } diff --git a/libvo/x11_common.c b/libvo/x11_common.c index c765f098fc..95c7b8bc62 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -199,4 +199,4 @@ void saver_off(Display *mDisplay) { if (timeout_save) XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp); // turning off screensaver -} \ No newline at end of file +} -- cgit v1.2.3