changeset 326:f6b5c2dbc88e

OSD alpha renderers moved to osd.c
author arpi_esp
date Tue, 10 Apr 2001 02:29:38 +0000
parents b2fd5c172f80
children e7731f5c76cc
files libvo/Makefile libvo/mga_common.c libvo/osd.c libvo/osd_template.c libvo/video_out_internal.h libvo/vo_x11.c libvo/vo_xv.c libvo/x11_common.c
diffstat 8 files changed, 265 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/Makefile	Tue Apr 10 00:18:41 2001 +0000
+++ b/libvo/Makefile	Tue Apr 10 02:29:38 2001 +0000
@@ -3,8 +3,8 @@
 
 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/
--- a/libvo/mga_common.c	Tue Apr 10 00:18:41 2001 +0000
+++ b/libvo/mga_common.c	Tue Apr 10 02:29:38 2001 +0000
@@ -10,37 +10,10 @@
 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);
 }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libvo/osd.c	Tue Apr 10 02:29:38 2001 +0000
@@ -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;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libvo/osd_template.c	Tue Apr 10 02:29:38 2001 +0000
@@ -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;
+}
+
--- a/libvo/video_out_internal.h	Tue Apr 10 00:18:41 2001 +0000
+++ b/libvo/video_out_internal.h	Tue Apr 10 02:29:38 2001 +0000
@@ -41,3 +41,10 @@
 	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);
+
+
+
+
--- a/libvo/vo_x11.c	Tue Apr 10 00:18:41 2001 +0000
+++ b/libvo/vo_x11.c	Tue Apr 10 02:29:38 2001 +0000
@@ -385,27 +385,21 @@
 }
 
 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;
     }
-
 }
 
 
--- a/libvo/vo_xv.c	Tue Apr 10 00:18:41 2001 +0000
+++ b/libvo/vo_xv.c	Tue Apr 10 02:29:38 2001 +0000
@@ -256,38 +256,16 @@
 }
 
 
+//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);
 
 }
 
--- a/libvo/x11_common.c	Tue Apr 10 00:18:41 2001 +0000
+++ b/libvo/x11_common.c	Tue Apr 10 02:29:38 2001 +0000
@@ -199,4 +199,4 @@
     if (timeout_save)
 	XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp);
 		    // turning off screensaver
-}
\ No newline at end of file
+}