changeset 947:76fd9463b9d3

FAST_OSD option to disable font outline antialiasing
author arpi_esp
date Sat, 02 Jun 2001 16:02:38 +0000
parents 5cbef0829f82
children 7f32481f3b4e
files configure libvo/font_load.c libvo/osd.c libvo/osd.h libvo/osd_template.c libvo/sub.c
diffstat 6 files changed, 140 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Sat Jun 02 15:36:33 2001 +0000
+++ b/configure	Sat Jun 02 16:02:38 2001 +0000
@@ -1118,6 +1118,10 @@
 /* gui support, please do not edit this option */
 $_gui
 
+/* Enable fast OSD/SUB renderer (looks ugly, but uses less CPU power) */
+#undef FAST_OSD
+#undef FAST_OSD_TABLE
+
 /* Define if your processor stores words with the most significant
    byte first (like Motorola and SPARC, unlike Intel and VAX).  */
 /* #define WORDS_BIGENDIAN */
--- a/libvo/font_load.c	Sat Jun 02 15:36:33 2001 +0000
+++ b/libvo/font_load.c	Sat Jun 02 16:02:38 2001 +0000
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "config.h"
 #include "font_load.h"
 
 char *get_path ( char * );
@@ -210,8 +211,12 @@
         int j;
         if(verbose) printf("font: resampling alpha by factor %5.3f (%d) ",factor,f);fflush(stdout);
         for(j=0;j<size;j++){
-            int x=desc->pic_a[i]->bmp[j];
-            int y=desc->pic_b[i]->bmp[j];
+            int x=desc->pic_a[i]->bmp[j];	// alpha
+            int y=desc->pic_b[i]->bmp[j];	// bitmap
+
+#ifdef FAST_OSD
+	    x=(x<(255-f))?0:1;
+#else
 
 	    x=255-((x*f)>>8); // scale
 	    //if(x<0) x=0; else if(x>255) x=255;
@@ -226,6 +231,7 @@
 
             if(x<1) x=1; else
             if(x>=252) x=0;
+#endif
 
             desc->pic_a[i]->bmp[j]=x;
 //            desc->pic_b[i]->bmp[j]=0; // hack
--- a/libvo/osd.c	Sat Jun 02 15:36:33 2001 +0000
+++ b/libvo/osd.c	Sat Jun 02 16:02:38 2001 +0000
@@ -1,14 +1,26 @@
 // Generic alpha renderers for all YUV modes and RGB depths.
 // These are "reference implementations", should be optimized later (MMX, etc)
 
+//#define FAST_OSD
+//#define FAST_OSD_TABLE
+
+#include "config.h"
 #include "osd.h"
 
 void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
     int y;
+#ifdef FAST_OSD
+    w=w>>1;
+#endif
     for(y=0;y<h;y++){
         register int x;
         for(x=0;x<w;x++){
+#ifdef FAST_OSD
+            if(srca[2*x+0]) dstbase[2*x+0]=src[2*x+0];
+            if(srca[2*x+1]) dstbase[2*x+1]=src[2*x+1];
+#else
             if(srca[x]) dstbase[x]=((dstbase[x]*srca[x])>>8)+src[x];
+#endif
         }
         src+=srcstride;
         srca+=srcstride;
@@ -19,10 +31,18 @@
 
 void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
     int y;
+#ifdef FAST_OSD
+    w=w>>1;
+#endif
     for(y=0;y<h;y++){
         register int x;
         for(x=0;x<w;x++){
+#ifdef FAST_OSD
+            if(srca[2*x+0]) dstbase[4*x+0]=src[2*x+0];
+            if(srca[2*x+1]) dstbase[4*x+2]=src[2*x+1];
+#else
             if(srca[x]) dstbase[2*x]=((dstbase[2*x]*srca[x])>>8)+src[x];
+#endif
         }
         src+=srcstride;
         srca+=srcstride;
@@ -38,9 +58,13 @@
         register int x;
         for(x=0;x<w;x++){
             if(srca[x]){
+#ifdef FAST_OSD
+		dst[0]=dst[1]=dst[2]=src[x];
+#else
 		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];
+#endif
             }
             dst+=3; // 24bpp
         }
@@ -57,9 +81,13 @@
         register int x;
         for(x=0;x<w;x++){
             if(srca[x]){
+#ifdef FAST_OSD
+		dstbase[4*x+0]=dstbase[4*x+1]=dstbase[4*x+2]=src[x];
+#else
 		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];
+#endif
             }
         }
         src+=srcstride;
@@ -69,6 +97,21 @@
     return;
 }
 
+#ifdef FAST_OSD_TABLE
+static unsigned short fast_osd_15bpp_table[256];
+static unsigned short fast_osd_16bpp_table[256];
+#endif
+
+void vo_draw_alpha_init(){
+#ifdef FAST_OSD_TABLE
+    int i;
+    for(i=0;i<256;i++){
+        fast_osd_15bpp_table[i]=((i>>3)<<10)|((i>>3)<<5)|(i>>3);
+        fast_osd_16bpp_table[i]=((i>>3)<<11)|((i>>2)<<5)|(i>>3);
+    }
+#endif
+}
+
 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++){
@@ -76,6 +119,14 @@
         register int x;
         for(x=0;x<w;x++){
             if(srca[x]){
+#ifdef FAST_OSD
+#ifdef FAST_OSD_TABLE
+                dst[x]=fast_osd_15bpp_table[src[x]];
+#else
+		register unsigned int a=src[x]>>3;
+                dst[x]=(a<<10)|(a<<5)|a;
+#endif
+#else
                 unsigned char r=dst[x]&0x1F;
                 unsigned char g=(dst[x]>>5)&0x1F;
                 unsigned char b=(dst[x]>>10)&0x1F;
@@ -83,6 +134,7 @@
                 g=(((g*srca[x])>>5)+src[x])>>3;
                 b=(((b*srca[x])>>5)+src[x])>>3;
                 dst[x]=(b<<10)|(g<<5)|r;
+#endif
             }
         }
         src+=srcstride;
@@ -99,6 +151,13 @@
         register int x;
         for(x=0;x<w;x++){
             if(srca[x]){
+#ifdef FAST_OSD
+#ifdef FAST_OSD_TABLE
+                dst[x]=fast_osd_16bpp_table[src[x]];
+#else
+                dst[x]=((src[x]>>3)<<11)|((src[x]>>2)<<5)|(src[x]>>3);
+#endif
+#else
                 unsigned char r=dst[x]&0x1F;
                 unsigned char g=(dst[x]>>5)&0x3F;
                 unsigned char b=(dst[x]>>11)&0x1F;
@@ -106,6 +165,7 @@
                 g=(((g*srca[x])>>6)+src[x])>>2;
                 b=(((b*srca[x])>>5)+src[x])>>3;
                 dst[x]=(b<<11)|(g<<5)|r;
+#endif
             }
         }
         src+=srcstride;
--- a/libvo/osd.h	Sat Jun 02 15:36:33 2001 +0000
+++ b/libvo/osd.h	Sat Jun 02 16:02:38 2001 +0000
@@ -5,6 +5,8 @@
 // Generic alpha renderers for all YUV modes and RGB depths.
 // These are "reference implementations", should be optimized later (MMX, etc)
 
+extern void vo_draw_alpha_init(); // build tables
+
 extern void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride);
 extern void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride);
 extern void vo_draw_alpha_rgb24(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride);
--- a/libvo/osd_template.c	Sat Jun 02 15:36:33 2001 +0000
+++ b/libvo/osd_template.c	Sat Jun 02 16:02:38 2001 +0000
@@ -1,14 +1,26 @@
 // Generic alpha renderers for all YUV modes and RGB depths.
 // These are "reference implementations", should be optimized later (MMX, etc)
 
+//#define FAST_OSD
+//#define FAST_OSD_TABLE
+
+#include "config.h"
 #include "osd.h"
 
 void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
     int y;
+#ifdef FAST_OSD
+    w=w>>1;
+#endif
     for(y=0;y<h;y++){
         register int x;
         for(x=0;x<w;x++){
+#ifdef FAST_OSD
+            if(srca[2*x+0]) dstbase[2*x+0]=src[2*x+0];
+            if(srca[2*x+1]) dstbase[2*x+1]=src[2*x+1];
+#else
             if(srca[x]) dstbase[x]=((dstbase[x]*srca[x])>>8)+src[x];
+#endif
         }
         src+=srcstride;
         srca+=srcstride;
@@ -19,10 +31,18 @@
 
 void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
     int y;
+#ifdef FAST_OSD
+    w=w>>1;
+#endif
     for(y=0;y<h;y++){
         register int x;
         for(x=0;x<w;x++){
+#ifdef FAST_OSD
+            if(srca[2*x+0]) dstbase[4*x+0]=src[2*x+0];
+            if(srca[2*x+1]) dstbase[4*x+2]=src[2*x+1];
+#else
             if(srca[x]) dstbase[2*x]=((dstbase[2*x]*srca[x])>>8)+src[x];
+#endif
         }
         src+=srcstride;
         srca+=srcstride;
@@ -38,9 +58,13 @@
         register int x;
         for(x=0;x<w;x++){
             if(srca[x]){
+#ifdef FAST_OSD
+		dst[0]=dst[1]=dst[2]=src[x];
+#else
 		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];
+#endif
             }
             dst+=3; // 24bpp
         }
@@ -57,9 +81,13 @@
         register int x;
         for(x=0;x<w;x++){
             if(srca[x]){
+#ifdef FAST_OSD
+		dstbase[4*x+0]=dstbase[4*x+1]=dstbase[4*x+2]=src[x];
+#else
 		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];
+#endif
             }
         }
         src+=srcstride;
@@ -69,6 +97,21 @@
     return;
 }
 
+#ifdef FAST_OSD_TABLE
+static unsigned short fast_osd_15bpp_table[256];
+static unsigned short fast_osd_16bpp_table[256];
+#endif
+
+void vo_draw_alpha_init(){
+#ifdef FAST_OSD_TABLE
+    int i;
+    for(i=0;i<256;i++){
+        fast_osd_15bpp_table[i]=((i>>3)<<10)|((i>>3)<<5)|(i>>3);
+        fast_osd_16bpp_table[i]=((i>>3)<<11)|((i>>2)<<5)|(i>>3);
+    }
+#endif
+}
+
 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++){
@@ -76,6 +119,14 @@
         register int x;
         for(x=0;x<w;x++){
             if(srca[x]){
+#ifdef FAST_OSD
+#ifdef FAST_OSD_TABLE
+                dst[x]=fast_osd_15bpp_table[src[x]];
+#else
+		register unsigned int a=src[x]>>3;
+                dst[x]=(a<<10)|(a<<5)|a;
+#endif
+#else
                 unsigned char r=dst[x]&0x1F;
                 unsigned char g=(dst[x]>>5)&0x1F;
                 unsigned char b=(dst[x]>>10)&0x1F;
@@ -83,6 +134,7 @@
                 g=(((g*srca[x])>>5)+src[x])>>3;
                 b=(((b*srca[x])>>5)+src[x])>>3;
                 dst[x]=(b<<10)|(g<<5)|r;
+#endif
             }
         }
         src+=srcstride;
@@ -99,6 +151,13 @@
         register int x;
         for(x=0;x<w;x++){
             if(srca[x]){
+#ifdef FAST_OSD
+#ifdef FAST_OSD_TABLE
+                dst[x]=fast_osd_16bpp_table[src[x]];
+#else
+                dst[x]=((src[x]>>3)<<11)|((src[x]>>2)<<5)|(src[x]>>3);
+#endif
+#else
                 unsigned char r=dst[x]&0x1F;
                 unsigned char g=(dst[x]>>5)&0x3F;
                 unsigned char b=(dst[x]>>11)&0x1F;
@@ -106,6 +165,7 @@
                 g=(((g*srca[x])>>6)+src[x])>>2;
                 b=(((b*srca[x])>>5)+src[x])>>3;
                 dst[x]=(b<<11)|(g<<5)|r;
+#endif
             }
         }
         src+=srcstride;
--- a/libvo/sub.c	Sat Jun 02 15:36:33 2001 +0000
+++ b/libvo/sub.c	Sat Jun 02 16:02:38 2001 +0000
@@ -186,11 +186,17 @@
 
 }
 
+static int draw_alpha_init_flag=0;
 
 void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
 
     if(!vo_font) return; // no font
 
+    if(!draw_alpha_init_flag){
+	draw_alpha_init_flag=1;
+	vo_draw_alpha_init();
+    }
+
     if(vo_osd_text){
         vo_draw_text_osd(dxs,dys,draw_alpha);
     }