2001-04-10 02:29:38 +00:00
|
|
|
// Generic alpha renderers for all YUV modes and RGB depths.
|
|
|
|
// These are "reference implementations", should be optimized later (MMX, etc)
|
|
|
|
|
2001-06-02 16:02:38 +00:00
|
|
|
//#define FAST_OSD
|
|
|
|
//#define FAST_OSD_TABLE
|
|
|
|
|
|
|
|
#include "config.h"
|
2001-04-24 20:03:13 +00:00
|
|
|
#include "osd.h"
|
|
|
|
|
2001-04-10 02:29:38 +00:00
|
|
|
void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
|
|
|
|
int y;
|
2001-06-02 16:02:38 +00:00
|
|
|
#ifdef FAST_OSD
|
|
|
|
w=w>>1;
|
|
|
|
#endif
|
2001-04-10 02:29:38 +00:00
|
|
|
for(y=0;y<h;y++){
|
|
|
|
register int x;
|
|
|
|
for(x=0;x<w;x++){
|
2001-06-02 16:02:38 +00:00
|
|
|
#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
|
2001-04-10 02:29:38 +00:00
|
|
|
if(srca[x]) dstbase[x]=((dstbase[x]*srca[x])>>8)+src[x];
|
2001-06-02 16:02:38 +00:00
|
|
|
#endif
|
2001-04-10 02:29:38 +00:00
|
|
|
}
|
|
|
|
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;
|
2001-06-02 16:02:38 +00:00
|
|
|
#ifdef FAST_OSD
|
|
|
|
w=w>>1;
|
|
|
|
#endif
|
2001-04-10 02:29:38 +00:00
|
|
|
for(y=0;y<h;y++){
|
|
|
|
register int x;
|
|
|
|
for(x=0;x<w;x++){
|
2001-06-02 16:02:38 +00:00
|
|
|
#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
|
2001-04-10 02:29:38 +00:00
|
|
|
if(srca[x]) dstbase[2*x]=((dstbase[2*x]*srca[x])>>8)+src[x];
|
2001-06-02 16:02:38 +00:00
|
|
|
#endif
|
2001-04-10 02:29:38 +00:00
|
|
|
}
|
|
|
|
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]){
|
2001-06-02 16:02:38 +00:00
|
|
|
#ifdef FAST_OSD
|
|
|
|
dst[0]=dst[1]=dst[2]=src[x];
|
|
|
|
#else
|
2001-04-10 02:29:38 +00:00
|
|
|
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];
|
2001-06-02 16:02:38 +00:00
|
|
|
#endif
|
2001-04-10 02:29:38 +00:00
|
|
|
}
|
|
|
|
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]){
|
2001-06-02 16:02:38 +00:00
|
|
|
#ifdef FAST_OSD
|
|
|
|
dstbase[4*x+0]=dstbase[4*x+1]=dstbase[4*x+2]=src[x];
|
|
|
|
#else
|
2001-04-10 02:29:38 +00:00
|
|
|
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];
|
2001-06-02 16:02:38 +00:00
|
|
|
#endif
|
2001-04-10 02:29:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
src+=srcstride;
|
|
|
|
srca+=srcstride;
|
|
|
|
dstbase+=dststride;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-06-02 16:02:38 +00:00
|
|
|
#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
|
|
|
|
}
|
|
|
|
|
2001-04-10 02:29:38 +00:00
|
|
|
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]){
|
2001-06-02 16:02:38 +00:00
|
|
|
#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
|
2001-04-10 02:29:38 +00:00
|
|
|
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;
|
2001-06-02 16:02:38 +00:00
|
|
|
#endif
|
2001-04-10 02:29:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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]){
|
2001-06-02 16:02:38 +00:00
|
|
|
#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
|
2001-04-10 02:29:38 +00:00
|
|
|
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;
|
2001-06-02 16:02:38 +00:00
|
|
|
#endif
|
2001-04-10 02:29:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
src+=srcstride;
|
|
|
|
srca+=srcstride;
|
|
|
|
dstbase+=dststride;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|