OSD alpha renderers moved to osd.c

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@327 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi_esp 2001-04-10 02:29:38 +00:00
parent 32205998de
commit 2f46205ad3
8 changed files with 265 additions and 83 deletions

View File

@ -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/

View File

@ -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);
}

115
libvo/osd.c Normal file
View File

@ -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;
}

115
libvo/osd_template.c Normal file
View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -199,4 +199,4 @@ void saver_off(Display *mDisplay) {
if (timeout_save)
XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp);
// turning off screensaver
}
}