summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-04-10 02:29:38 +0000
committerarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-04-10 02:29:38 +0000
commit2f46205ad3ecbd60fa17823290e3c4f91c8b407e (patch)
treeba9affc816ef4faf76d10e80bdae07cefb41ec1e /libvo
parent32205998de2fe0e230693d3053ef5053646de244 (diff)
downloadmpv-2f46205ad3ecbd60fa17823290e3c4f91c8b407e.tar.bz2
mpv-2f46205ad3ecbd60fa17823290e3c4f91c8b407e.tar.xz
OSD alpha renderers moved to osd.c
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@327 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/Makefile4
-rw-r--r--libvo/mga_common.c35
-rw-r--r--libvo/osd.c115
-rw-r--r--libvo/osd_template.c115
-rw-r--r--libvo/video_out_internal.h7
-rw-r--r--libvo/vo_x11.c34
-rw-r--r--libvo/vo_xv.c36
-rw-r--r--libvo/x11_common.c2
8 files changed, 265 insertions, 83 deletions
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<h;y++){
- uint8_t *dst = vid_data + bespitch * (y0+y) + x0;
- for(x=0;x<w;x++){
-// dst[x]=(dst[x]*srca[x]+src[x]*(srca[x]^255))>>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<h;y++){
- uint8_t *dst = vid_data + 2*(bespitch * (y0+y) + x0);
- for(x=0;x<w;x++){
-// dst[x]=(dst[x]*srca[x]+src[x]*(srca[x]^255))>>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<h;y++){
+ register int x;
+ for(x=0;x<w;x++){
+ if(srca[x]) dstbase[x]=((dstbase[x]*srca[x])>>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<h;y++){
+ register int x;
+ for(x=0;x<w;x++){
+ if(srca[x]) dstbase[2*x]=((dstbase[2*x]*srca[x])>>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<h;y++){
+ register unsigned char *dst = dstbase;
+ register int x;
+ for(x=0;x<w;x++){
+ 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+=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<h;y++){
+ register int x;
+ for(x=0;x<w;x++){
+ if(srca[x]){
+ dstbase[4*x+0]=((dstbase[4*x+0]*srca[x])>>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<h;y++){
+ register unsigned short *dst = (unsigned short*) dstbase;
+ register int x;
+ for(x=0;x<w;x++){
+ if(srca[x]){
+ unsigned char r=dst[x]&0x1F;
+ unsigned char g=(dst[x]>>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<h;y++){
+ register unsigned short *dst = (unsigned short*) dstbase;
+ register int x;
+ for(x=0;x<w;x++){
+ if(srca[x]){
+ unsigned char r=dst[x]&0x1F;
+ unsigned char g=(dst[x]>>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<h;y++){
+ register int x;
+ for(x=0;x<w;x++){
+ if(srca[x]) dstbase[x]=((dstbase[x]*srca[x])>>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<h;y++){
+ register int x;
+ for(x=0;x<w;x++){
+ if(srca[x]) dstbase[2*x]=((dstbase[2*x]*srca[x])>>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<h;y++){
+ register unsigned char *dst = dstbase;
+ register int x;
+ for(x=0;x<w;x++){
+ 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+=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<h;y++){
+ register int x;
+ for(x=0;x<w;x++){
+ if(srca[x]){
+ dstbase[4*x+0]=((dstbase[4*x+0]*srca[x])>>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<h;y++){
+ register unsigned short *dst = (unsigned short*) dstbase;
+ register int x;
+ for(x=0;x<w;x++){
+ if(srca[x]){
+ unsigned char r=dst[x]&0x1F;
+ unsigned char g=(dst[x]>>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<h;y++){
+ register unsigned short *dst = (unsigned short*) dstbase;
+ register int x;
+ for(x=0;x<w;x++){
+ if(srca[x]){
+ unsigned char r=dst[x]&0x1F;
+ unsigned char g=(dst[x]>>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<h;y++){
- uint8_t *dst = ImageData+ dbpp*((y+y0)*image_width+x0);
- for(x=0;x<w;x++){
-// dst[x]=(dst[x]*srca[x]+src[x]*(srca[x]^255))>>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;y<h;y++){
- uint8_t *dst = xvimage[0]->data + image_width * (y+y0) + x0;
- for(x=0;x<w;x++){
-// dst[x]=(dst[x]*srca[x]+src[x]*(srca[x]^255))>>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;y<h;y++){
- uint8_t *dst = xvimage[0]->data + 2*(image_width * (y+y0) + x0);
- for(x=0;x<w;x++){
-// dst[x]=(dst[x]*srca[x]+src[x]*(srca[x]^255))>>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
+}