# HG changeset patch # User arpi_esp # Date 985408577 0 # Node ID 6ad0715dfac82d5bb45473d07ba1c24e76ff5022 # Parent 4678d821252481d1f38abf3d072cab6c5e670008 grey+alpha rendering support (for .sub) diff -r 4678d8212524 -r 6ad0715dfac8 libvo/mga_common.c --- a/libvo/mga_common.c Fri Mar 23 18:30:19 2001 +0000 +++ b/libvo/mga_common.c Sat Mar 24 04:36:17 2001 +0000 @@ -7,64 +7,40 @@ static uint8_t *vid_data, *frames[4]; 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; -static void -write_frame_g200(uint8_t *y,uint8_t *cr, uint8_t *cb) -{ - uint8_t *dest; - uint32_t bespitch,h,w; - - dest = vid_data; - bespitch = (mga_vid_config.src_width + 31) & ~31; + if (mga_vid_config.format==MGA_VID_FORMAT_YV12){ - for(h=0; h < mga_vid_config.src_height; h++) - { - memcpy(dest, y, mga_vid_config.src_width); - y += mga_vid_config.src_width; - dest += bespitch; - } + for(y=0;y>8; + if(srca[x]) + dst[x]=(dst[x]*(srca[x]^255)+src[x]*(srca[x]))>>8; + } + src+=stride; + srca+=stride; + } + + } else { - for(h=0; h < mga_vid_config.src_height/2; h++) - { - for(w=0; w < mga_vid_config.src_width/2; w++) - { - *dest++ = *cb++; - *dest++ = *cr++; - } - dest += bespitch - mga_vid_config.src_width; - } + for(y=0;y>8; + if(srca[x]) + dst[2*x]=(dst[2*x]*(srca[x]^255)+src[x]*(srca[x]))>>8; + } + src+=stride; + srca+=stride; + } + + } + } -static void -write_frame_g400(uint8_t *y,uint8_t *cr, uint8_t *cb) -{ - uint8_t *dest; - uint32_t bespitch,h; - - dest = vid_data; - bespitch = (mga_vid_config.src_width + 31) & ~31; - - for(h=0; h < mga_vid_config.src_height; h++) - { - memcpy(dest, y, mga_vid_config.src_width); - y += mga_vid_config.src_width; - dest += bespitch; - } - - for(h=0; h < mga_vid_config.src_height/2; h++) - { - memcpy(dest, cb, mga_vid_config.src_width/2); - cb += mga_vid_config.src_width/2; - dest += bespitch/2; - } - - for(h=0; h < mga_vid_config.src_height/2; h++) - { - memcpy(dest, cr, mga_vid_config.src_width/2); - cr += mga_vid_config.src_width/2; - dest += bespitch/2; - } -} //static void //write_slice_g200(uint8_t *y,uint8_t *cr, uint8_t *cb,uint32_t slice_num) @@ -200,13 +176,6 @@ { if (mga_vid_config.format==MGA_VID_FORMAT_YUY2) write_frame_yuy2(src[0]); - else - if (mga_vid_config.card_type == MGA_G200) - write_frame_g200(src[0], src[2], src[1]); - else - write_frame_g400(src[0], src[2], src[1]); - - //flip_page(); return 0; } diff -r 4678d8212524 -r 6ad0715dfac8 libvo/sub.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libvo/sub.c Sat Mar 24 04:36:17 2001 +0000 @@ -0,0 +1,71 @@ + +typedef struct { + unsigned char *bmp; + unsigned char *pal; + int w,h,c; +} raw_file; + +raw_file* load_raw(char *name){ + int bpp; + raw_file* raw=malloc(sizeof(raw_file)); + unsigned char head[32]; + FILE *f=fopen(name,"rb"); + if(!f) return NULL; // can't open + if(fread(head,32,1,f)<1) return NULL; // too small + if(memcmp(head,"mhwanh",6)) return NULL; // not raw file + raw->w=head[8]*256+head[9]; + raw->h=head[10]*256+head[11]; + raw->c=head[12]*256+head[13]; + if(raw->c>256) return NULL; // too many colors!? + printf("RAW: %d x %d, %d colors\n",raw->w,raw->h,raw->c); + if(raw->c){ + raw->pal=malloc(raw->c*3); + fread(raw->pal,3,raw->c,f); + bpp=1; + } else { + raw->pal=NULL; + bpp=3; + } + raw->bmp=malloc(raw->h*raw->w*bpp); + fread(raw->bmp,raw->h*raw->w*bpp,1,f); + fclose(f); + return raw; +} + +static int vo_font_loaded=-1; +static raw_file* vo_font_bmp=NULL; +static raw_file* vo_font_alpha=NULL; + +void vo_load_font(char *bmpname,char *alphaname){ + vo_font_loaded=0; + if(!(vo_font_bmp=load_raw(bmpname))) + printf("vo: Can't load font BMP\n"); else + if(!(vo_font_alpha=load_raw(alphaname))) + printf("vo: Can't load font Alpha\n"); else + vo_font_loaded=1; +} + +int vo_sub_lines=2; +char* vo_sub_text[8]; + + +void vo_draw_text(void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ + int i; + int y=100; + + if(vo_sub_lines<=0) return; // no text + + if(vo_font_loaded==-1) vo_load_font("font_b.raw","font_a.raw"); + if(!vo_font_loaded) return; // no font + +// if(!vo_font_bmp) vo_load_font("mplayer_font_lowres_bitmap.raw","mplayer_font_lowres_alpha.raw"); + + for(i=0;ih,vo_font_bmp->bmp,vo_font_alpha->bmp,vo_font_bmp->w); +// x11_draw_alpha(100,y,50,vo_font_bmp->h,vo_font_bmp->bmp,vo_font_alpha->bmp,vo_font_bmp->w); + y+=50; + } + +} + diff -r 4678d8212524 -r 6ad0715dfac8 libvo/video_out.c --- a/libvo/video_out.c Fri Mar 23 18:30:19 2001 +0000 +++ b/libvo/video_out.c Sat Mar 24 04:36:17 2001 +0000 @@ -87,4 +87,4 @@ NULL }; - +#include "sub.c" diff -r 4678d8212524 -r 6ad0715dfac8 libvo/vo_mga.c --- a/libvo/vo_mga.c Fri Mar 23 18:30:19 2001 +0000 +++ b/libvo/vo_mga.c Sat Mar 24 04:36:17 2001 +0000 @@ -105,6 +105,7 @@ static void flip_page(void) { + vo_draw_text(draw_alpha); vo_mga_flip_page(); } diff -r 4678d8212524 -r 6ad0715dfac8 libvo/vo_x11.c --- a/libvo/vo_x11.c Fri Mar 23 18:30:19 2001 +0000 +++ b/libvo/vo_x11.c Sat Mar 24 04:36:17 2001 +0000 @@ -328,7 +328,30 @@ #endif } +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>8; + if(srca[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; + } + +} + + static void flip_page( void ){ + vo_draw_text(draw_alpha); check_events(); Display_Image( myximage,ImageData ); } diff -r 4678d8212524 -r 6ad0715dfac8 libvo/vo_xmga.c --- a/libvo/vo_xmga.c Fri Mar 23 18:30:19 2001 +0000 +++ b/libvo/vo_xmga.c Sat Mar 24 04:36:17 2001 +0000 @@ -151,6 +151,8 @@ timer=t; #endif + vo_draw_text(draw_alpha); + check_events(); vo_mga_flip_page(); }