diff -ur --exclude-from dontdiff vanilla/main/libmpcodecs/vf_expand.c main/libmpcodecs/vf_expand.c --- vanilla/main/libmpcodecs/vf_expand.c 2002-10-17 09:26:04.000000000 +0200 +++ main/libmpcodecs/vf_expand.c 2002-11-05 18:53:42.000000000 +0100 @@ -67,7 +67,7 @@ } static void draw_func(int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){ - unsigned char* dst; + unsigned char* dst, *dst2, *dst3; if(!vo_osd_changed_flag && vf->priv->dmpi->planes[0]==vf->priv->fb_ptr){ // ok, enough to update the area inside the video, leave the black bands // untouched! @@ -115,7 +115,15 @@ case IMGFMT_IF09: case IMGFMT_Y800: case IMGFMT_Y8: - vo_draw_alpha_yv12(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0]); + dst2=vf->priv->dmpi->planes[1]+ + vf->priv->dmpi->stride[1]*y0+ + (vf->priv->dmpi->bpp>>4)*x0; + dst3=vf->priv->dmpi->planes[2]+ + vf->priv->dmpi->stride[2]*y0+ + (vf->priv->dmpi->bpp>>4)*x0; + vo_draw_alpha_yv12(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0], + dst2,vf->priv->dmpi->stride[1], + dst3,vf->priv->dmpi->stride[2]); break; case IMGFMT_YUY2: vo_draw_alpha_yuy2(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0]); @@ -137,10 +145,10 @@ remove_func(0,0,vf->priv->exp_w,vf->priv->exp_h); } else { // partial clear: - vo_remove_text(vf->priv->exp_w,vf->priv->exp_h,remove_func); + vo_remove_text(vf->priv->exp_w,vf->priv->exp_h,vf->priv->dmpi->imgfmt,remove_func); } } - vo_draw_text(vf->priv->exp_w,vf->priv->exp_h,draw_func); + vo_draw_text(vf->priv->exp_w,vf->priv->exp_h,vf->priv->dmpi->imgfmt,draw_func); // save buffer pointer for double buffering detection - yes, i know it's // ugly method, but note that codecs with DR support does the same... vf->priv->fb_ptr=vf->priv->dmpi->planes[0]; @@ -187,7 +195,7 @@ #ifdef OSD_SUPPORT if(vf->priv->osd && (mpi->flags&MP_IMGFLAG_PRESERVE)){ // check if we have to render osd! - vo_update_osd(vf->priv->exp_w, vf->priv->exp_h); + vo_update_osd(vf->priv->exp_w, vf->priv->exp_h, vf->priv->dmpi->imgfmt); if(vo_osd_check_range_update(vf->priv->exp_x,vf->priv->exp_y, vf->priv->exp_x+mpi->w,vf->priv->exp_y+mpi->h)) return; } diff -ur --exclude-from dontdiff vanilla/main/libvo/osd.c main/libvo/osd.c --- vanilla/main/libvo/osd.c 2002-05-02 12:46:25.000000000 +0200 +++ main/libvo/osd.c 2002-11-05 18:53:42.000000000 +0100 @@ -2,9 +2,6 @@ // These are "reference implementations", should be optimized later (MMX, etc) // Templating Code from Michael Niedermayer (michaelni@gmx.at) is under GPL -//#define FAST_OSD -//#define FAST_OSD_TABLE - #include "config.h" #include "osd.h" #include "mp_msg.h" @@ -16,6 +13,8 @@ extern int verbose; // defined in mplayer.c +#undef ARCH_X86 + #ifdef ARCH_X86 #define CAN_COMPILE_X86_ASM #endif @@ -28,9 +27,9 @@ //Note: we have C, X86-nommx, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one //Plain C versions -#if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT) +//#if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT) #define COMPILE_C -#endif +//#endif #ifdef CAN_COMPILE_X86_ASM @@ -52,14 +51,14 @@ #undef HAVE_3DNOW #undef ARCH_X86 -#ifdef COMPILE_C +//#ifdef COMPILE_C #undef HAVE_MMX #undef HAVE_MMX2 #undef HAVE_3DNOW #undef ARCH_X86 #define RENAME(a) a ## _C #include "osd_template.c" -#endif +//#endif #ifdef CAN_COMPILE_X86_ASM @@ -109,32 +108,32 @@ #endif //CAN_COMPILE_X86_ASM -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_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase1, int dststride1, unsigned char* dstbase2, int dststride2, unsigned char* dstbase3, int dststride3){ #ifdef RUNTIME_CPUDETECT #ifdef CAN_COMPILE_X86_ASM // ordered per speed fasterst first if(gCpuCaps.hasMMX2) - vo_draw_alpha_yv12_MMX2(w, h, src, srca, srcstride, dstbase, dststride); + vo_draw_alpha_yv12_MMX2(w, h, src, srca, srcstride, dstbase1, dststride1, dstbase2, dststride2, dstbase3, dststride3); else if(gCpuCaps.has3DNow) - vo_draw_alpha_yv12_3DNow(w, h, src, srca, srcstride, dstbase, dststride); + vo_draw_alpha_yv12_3DNow(w, h, src, srca, srcstride, dstbase1, dststride1, dstbase2, dststride2, dstbase3, dststride3); else if(gCpuCaps.hasMMX) - vo_draw_alpha_yv12_MMX(w, h, src, srca, srcstride, dstbase, dststride); + vo_draw_alpha_yv12_MMX(w, h, src, srca, srcstride, dstbase1, dststride1, dstbase2, dststride2, dstbase3, dststride3); else - vo_draw_alpha_yv12_X86(w, h, src, srca, srcstride, dstbase, dststride); + vo_draw_alpha_yv12_X86(w, h, src, srca, srcstride, dstbase1, dststride1, dstbase2, dststride2, dstbase3, dststride3); #else - vo_draw_alpha_yv12_C(w, h, src, srca, srcstride, dstbase, dststride); + vo_draw_alpha_yv12_C(w, h, src, srca, srcstride, dstbase1, dststride1, dstbase2, dststride2, dstbase3, dststride3); #endif #else //RUNTIME_CPUDETECT #ifdef HAVE_MMX2 - vo_draw_alpha_yv12_MMX2(w, h, src, srca, srcstride, dstbase, dststride); + vo_draw_alpha_yv12_MMX2(w, h, src, srca, srcstride, dstbase1, dststride1, dstbase2, dststride2, dstbase3, dststride3); #elif defined (HAVE_3DNOW) - vo_draw_alpha_yv12_3DNow(w, h, src, srca, srcstride, dstbase, dststride); + vo_draw_alpha_yv12_3DNow(w, h, src, srca, srcstride, dstbase1, dststride1, dstbase2, dststride2, dstbase3, dststride3); #elif defined (HAVE_MMX) - vo_draw_alpha_yv12_MMX(w, h, src, srca, srcstride, dstbase, dststride); + vo_draw_alpha_yv12_MMX(w, h, src, srca, srcstride, dstbase1, dststride1, dstbase2, dststride2, dstbase3, dststride3); #elif defined (ARCH_X86) - vo_draw_alpha_yv12_X86(w, h, src, srca, srcstride, dstbase, dststride); + vo_draw_alpha_yv12_X86(w, h, src, srca, srcstride, dstbase1, dststride1, dstbase2, dststride2, dstbase3, dststride3); #else - vo_draw_alpha_yv12_C(w, h, src, srca, srcstride, dstbase, dststride); + vo_draw_alpha_yv12_C(w, h, src, srca, srcstride, dstbase1, dststride1, dstbase2, dststride2, dstbase3, dststride3); #endif #endif //!RUNTIME_CPUDETECT } @@ -229,19 +228,7 @@ #endif //!RUNTIME_CPUDETECT } -#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 //FIXME the optimized stuff is a lie for 15/16bpp as they arent optimized yet if(verbose) { @@ -282,22 +269,13 @@ register int x; for(x=0;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; - r=(((r*srca[x])>>5)+src[x])>>3; - g=(((g*srca[x])>>5)+src[x])>>3; - b=(((b*srca[x])>>5)+src[x])>>3; + r=(((r*srca[x])>>5)+src[3*x])>>3; + g=(((g*srca[x])>>5)+src[3*x+1])>>3; + b=(((b*srca[x])>>5)+src[3*x+2])>>3; dst[x]=(b<<10)|(g<<5)|r; -#endif } } src+=srcstride; @@ -314,21 +292,13 @@ register int x; for(x=0;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; - r=(((r*srca[x])>>5)+src[x])>>3; - g=(((g*srca[x])>>6)+src[x])>>2; - b=(((b*srca[x])>>5)+src[x])>>3; + r=(((r*srca[x])>>5)+src[3*x])>>3; + g=(((g*srca[x])>>6)+src[3*x+1])>>2; + b=(((b*srca[x])>>5)+src[3*x+2])>>3; dst[x]=(b<<11)|(g<<5)|r; -#endif } } src+=srcstride; diff -ur --exclude-from dontdiff vanilla/main/libvo/osd.h main/libvo/osd.h --- vanilla/main/libvo/osd.h 2001-06-11 00:25:09.000000000 +0200 +++ main/libvo/osd.h 2002-11-05 18:53:42.000000000 +0100 @@ -7,7 +7,7 @@ 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_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride1,unsigned char* dstbase2, int dststride2, unsigned char* dstbase3, int dststride3); 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); extern void vo_draw_alpha_rgb32(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride); diff -ur --exclude-from dontdiff vanilla/main/libvo/osd_template.c main/libvo/osd_template.c --- vanilla/main/libvo/osd_template.c 2002-03-16 18:12:19.000000000 +0100 +++ main/libvo/osd_template.c 2002-11-05 18:53:42.000000000 +0100 @@ -27,11 +27,9 @@ #define EMMS "emms" #endif -static inline void RENAME(vo_draw_alpha_yv12)(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ +static inline void RENAME(vo_draw_alpha_yv12)(int w,int h, unsigned char* src, unsigned char *srca1, int srcstride, unsigned char* dstbase1,int dststride1, unsigned char* dstbase2, int dststride2, unsigned char* dstbase3, int dststride3){ int y; -#if defined(FAST_OSD) && !defined(HAVE_MMX) - w=w>>1; -#endif + unsigned char *srca = srca1; PROFILE_START(); for(y=0;y>8)+src[x]; -#endif + if(srca[x]) dstbase1[x]=((dstbase1[x]*srca[x])>>8)+src[x]; } #endif src+=srcstride; srca+=srcstride; - dstbase+=dststride; + dstbase1+=dststride1; + } + + srca = srca1; + for(y=0;y>1; -#endif + return; + PROFILE_START(); + for(y=0;y>8)+src[x]; - dstbase[2*x+1]=((((signed)dstbase[2*x+1]-128)*srca[x])>>8)+128; + dstbase[2*x]=((dstbase[2*x]*srca[x])>>8)+src[2*x]; + dstbase[2*x+1]=((((signed)dstbase[2*x+1]-128)*srca[x])>>8)+128+src[2*x+1]; } -#endif } #endif src+=srcstride; @@ -245,13 +258,9 @@ #else /*non x86 arch*/ for(x=0;x>8)+src[x]; - dst[1]=((dst[1]*srca[x])>>8)+src[x]; - dst[2]=((dst[2]*srca[x])>>8)+src[x]; -#endif + dst[0]=((dst[0]*srca[x])>>8)+src[3*x]; + dst[1]=((dst[1]*srca[x])>>8)+src[3*x+1]; + dst[2]=((dst[2]*srca[x])>>8)+src[3*x+2]; } dst+=3; // 24bpp } @@ -400,17 +409,13 @@ #else /*non x86 arch*/ for(x=0;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 + dstbase[4*x+0]=((dstbase[4*x+0]*srca[x])>>8)+src[3*x]; + dstbase[4*x+1]=((dstbase[4*x+1]*srca[x])>>8)+src[3*x+1]; + dstbase[4*x+2]=((dstbase[4*x+2]*srca[x])>>8)+src[3*x+2]; } } #endif /* arch_x86 */ - src+=srcstride; + src+=srcstride*3; srca+=srcstride; dstbase+=dststride; } diff -ur --exclude-from dontdiff vanilla/main/libvo/sub.c main/libvo/sub.c --- vanilla/main/libvo/sub.c 2002-10-06 23:04:28.000000000 +0200 +++ main/libvo/sub.c 2002-11-05 19:11:22.000000000 +0100 @@ -43,14 +43,31 @@ return h; } +static int xpal = 0; + +#define PALSIZE 9 +/* R,G,B */ +static int palette[PALSIZE][3] = { + {128, 128, 128}, + {128, 128, 255}, + {128, 255, 128}, + {128, 255, 255}, + {255, 128, 128}, + {255, 128, 255}, + {255, 255, 128}, + {255, 255, 255}, +}; + +int vo_convert_osd_format(mp_osd_obj_t* obj, uint32_t format); + // renders char to a big per-object buffer where alpha and bitmap are separated -static void draw_alpha_buf(mp_osd_obj_t* obj, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) +static void draw_alpha_buf(mp_osd_obj_t* obj, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride, unsigned char pal_idx) { int dststride = obj->stride; int dstskip = obj->stride-w; int srcskip = stride-w; int i, j; - unsigned char *b = obj->bitmap_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1); + unsigned char *b = obj->rgb_buffer + (y0-obj->bbox.y1)*dststride*3 + (x0-obj->bbox.x1)*3; unsigned char *a = obj->alpha_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1); unsigned char *bs = src; unsigned char *as = srca; @@ -63,17 +80,26 @@ } for (i = 0; i < h; i++) { - for (j = 0; j < w; j++, b++, a++, bs++, as++) { - if (*b < *bs) *b = *bs; + for (j = 0; j < w; j++, a++, b+=3, bs++, as++) { + if (*b < *bs) { + b[0] = *bs*palette[xpal][0] >> 8; + b[1] = *bs*palette[xpal][1] >> 8; + b[2] = *bs*palette[xpal][2] >> 8; + } if (*as) { - if (*a == 0 || *a > *as) *a = *as; + if (*a == 0 || *a > *as) { + *a = *as; + } } } - b+= dstskip; + b+= dstskip*3; a+= dstskip; bs+= srcskip; as+= srcskip; } + xpal++; + + if (xpal > 7) xpal = 0; } // allocates/enlarges the alpha/bitmap buffer @@ -82,17 +108,22 @@ int len; if (obj->bbox.x2 < obj->bbox.x1) obj->bbox.x2 = obj->bbox.x1; if (obj->bbox.y2 < obj->bbox.y1) obj->bbox.y2 = obj->bbox.y1; + if ((obj->bbox.y2-obj->bbox.y1) & 1) obj->bbox.y1--; obj->stride = ((obj->bbox.x2-obj->bbox.x1)+7)&(~7); len = obj->stride*(obj->bbox.y2-obj->bbox.y1); + fprintf(stderr, "alloc: %d %d\n", obj->stride, obj->bbox.y2-obj->bbox.y1); if (obj->allocatedallocated = len; - free(obj->bitmap_buffer); + free(obj->rgb_buffer); + free(obj->dest_buffer); free(obj->alpha_buffer); - obj->bitmap_buffer = (unsigned char *)memalign(16, len); obj->alpha_buffer = (unsigned char *)memalign(16, len); + obj->rgb_buffer = (unsigned char *)memalign(16, len*3); + obj->dest_buffer = (unsigned char *)memalign(16, len*4); } - memset(obj->bitmap_buffer, 0, len); memset(obj->alpha_buffer, 0, len); + memset(obj->rgb_buffer, 0, len*3); + memset(obj->dest_buffer, 0, len*4); } // renders the buffer @@ -101,13 +132,13 @@ draw_alpha(obj->bbox.x1,obj->bbox.y1, obj->bbox.x2-obj->bbox.x1, obj->bbox.y2-obj->bbox.y1, - obj->bitmap_buffer, + obj->dest_buffer, obj->alpha_buffer, obj->stride); } } -inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){ +inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys,uint32_t format){ unsigned char *cp=vo_osd_text; int x=20; int h=0; @@ -139,9 +170,12 @@ vo_font->pic_a[font]->h, vo_font->pic_b[font]->bmp+vo_font->start[c], vo_font->pic_a[font]->bmp+vo_font->start[c], - vo_font->pic_a[font]->w); + vo_font->pic_a[font]->w, + 1); x+=vo_font->width[c]+vo_font->charspace; } + + vo_convert_osd_format(obj, format); } int vo_osd_progbar_type=-1; @@ -155,7 +189,7 @@ // // the above schema is rescalled to n=elems bars -inline static void vo_update_text_progbar(mp_osd_obj_t* obj,int dxs,int dys){ +inline static void vo_update_text_progbar(mp_osd_obj_t* obj,int dxs,int dys,uint32_t format){ obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; @@ -230,7 +264,7 @@ vo_font->pic_a[font]->h, vo_font->pic_b[font]->bmp+vo_font->start[c], vo_font->pic_a[font]->bmp+vo_font->start[c], - vo_font->pic_a[font]->w); + vo_font->pic_a[font]->w, 1); } c=OSD_PB_START; @@ -240,7 +274,7 @@ vo_font->pic_a[font]->h, vo_font->pic_b[font]->bmp+vo_font->start[c], vo_font->pic_a[font]->bmp+vo_font->start[c], - vo_font->pic_a[font]->w); + vo_font->pic_a[font]->w, 1); x+=vo_font->width[c]+vo_font->charspace; c=OSD_PB_0; @@ -251,7 +285,7 @@ sa=vo_font->pic_a[font]->bmp+vo_font->start[c]; st=vo_font->pic_a[font]->w; if ((i=mark)) do { - draw_alpha_buf(obj,x,y,w,h,s,sa,st); + draw_alpha_buf(obj,x,y,w,h,s,sa,st,1); x+=charw; } while(--i); } @@ -264,7 +298,7 @@ sa=vo_font->pic_a[font]->bmp+vo_font->start[c]; st=vo_font->pic_a[font]->w; if ((i=elems-mark)) do { - draw_alpha_buf(obj,x,y,w,h,s,sa,st); + draw_alpha_buf(obj,x,y,w,h,s,sa,st,1); x+=charw; } while(--i); } @@ -276,19 +310,21 @@ vo_font->pic_a[font]->h, vo_font->pic_b[font]->bmp+vo_font->start[c], vo_font->pic_a[font]->bmp+vo_font->start[c], - vo_font->pic_a[font]->w); + vo_font->pic_a[font]->w, 1); // x+=vo_font->width[c]+vo_font->charspace; } // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF; + vo_convert_osd_format(obj, format); + } subtitle* vo_sub=NULL; // vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) -inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){ +inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys,uint32_t format){ unsigned char *t; int c,i,j,l,x,y,font,prevc; int len; @@ -421,17 +457,18 @@ vo_font->pic_a[font]->h+ydys ? vo_font->pic_a[font]->h : obj->dys-y, vo_font->pic_b[font]->bmp+vo_font->start[c], vo_font->pic_a[font]->bmp+vo_font->start[c], - vo_font->pic_a[font]->w); + vo_font->pic_a[font]->w, 1); x+=vo_font->width[c]+vo_font->charspace; prevc = c; } if (!--l) break; y+=vo_font->height; } - + + vo_convert_osd_format(obj, format); } -inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys) +inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys, uint32_t format) { unsigned int bbox[4]; int i; @@ -443,7 +480,7 @@ obj->flags |= OSDFLAG_BBOX; } -inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride)) +inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, unsigned char* srcp, int stride)) { spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha); } @@ -464,7 +501,8 @@ vo_osd_list=osd; osd->type=type; osd->alpha_buffer = NULL; - osd->bitmap_buffer = NULL; + osd->rgb_buffer = NULL; + osd->dest_buffer = NULL; osd->allocated = -1; return osd; } @@ -474,14 +512,51 @@ while(obj){ mp_osd_obj_t* next=obj->next; if (obj->alpha_buffer) free(obj->alpha_buffer); - if (obj->bitmap_buffer) free(obj->bitmap_buffer); + if (obj->rgb_buffer) free(obj->rgb_buffer); + if (obj->dest_buffer) free(obj->dest_buffer); free(obj); obj=next; } vo_osd_list=NULL; } -int vo_update_osd(int dxs,int dys){ +int vo_convert_osd_format(mp_osd_obj_t* obj, uint32_t format) +{ + switch (format) { + case IMGFMT_YV12: + case IMGFMT_I420: + case IMGFMT_IYUV: +// if (obj->dest_buffer) + fprintf(stderr, "rgb2yuv: %d %d\n", obj->stride, obj->bbox.y2-obj->bbox.y1); + if (obj->stride >= 8) + rgb24toyv12(obj->rgb_buffer, obj->dest_buffer, + obj->dest_buffer+obj->stride*(obj->bbox.y2-obj->bbox.y1), + obj->dest_buffer+obj->stride*(obj->bbox.y2-obj->bbox.y1)*5/4, + obj->stride, obj->bbox.y2-obj->bbox.y1, + obj->stride, obj->stride >> 1, obj->stride*3); + +// memset(obj->dest_buffer, 0, obj->stride*(obj->bbox.y2-obj->bbox.y1)*3/2); + + break; + case IMGFMT_YUY2: + case IMGFMT_YVYU: + case IMGFMT_UYVY: + break; + case IMGFMT_RGB15: + case IMGFMT_BGR15: + case IMGFMT_RGB16: + case IMGFMT_BGR16: + case IMGFMT_RGB24: + case IMGFMT_BGR24: + case IMGFMT_RGB32: + case IMGFMT_BGR32: + fprintf(stderr, "rgbcopy: %d %d\n", obj->stride, obj->bbox.y2-obj->bbox.y1); + memcpy(obj->dest_buffer, obj->rgb_buffer, obj->stride*(obj->bbox.y2-obj->bbox.y1)*3); + break; + } +} + +int vo_update_osd(int dxs, int dys, uint32_t format){ mp_osd_obj_t* obj=vo_osd_list; int chg=0; @@ -499,14 +574,14 @@ obj->flags&=~OSDFLAG_BBOX; switch(obj->type){ case OSDTYPE_SUBTITLE: - vo_update_text_sub(obj,dxs,dys); + vo_update_text_sub(obj,dxs,dys,format); break; case OSDTYPE_PROGBAR: - vo_update_text_progbar(obj,dxs,dys); + vo_update_text_progbar(obj,dxs,dys,format); break; case OSDTYPE_SPU: if(sub_visibility && vo_spudec && spudec_visible(vo_spudec)){ - vo_update_spudec_sub(obj, dxs, dys); + vo_update_spudec_sub(obj, dxs, dys,format); obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; } else @@ -514,7 +589,7 @@ break; case OSDTYPE_OSD: if(vo_font && vo_osd_text && vo_osd_text[0]){ - vo_update_text_osd(obj,dxs,dys); // update bbox + vo_update_text_osd(obj,dxs,dys,format); // update bbox obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; } else obj->flags&=~OSDFLAG_VISIBLE; @@ -572,9 +647,9 @@ int vo_osd_changed_flag=0; -void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){ +void vo_remove_text(int dxs,int dys,uint32_t format,void (*remove)(int x0,int y0, int w,int h)){ mp_osd_obj_t* obj=vo_osd_list; - vo_update_osd(dxs,dys); + vo_update_osd(dxs,dys,format); while(obj){ if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) && (obj->flags&OSDFLAG_OLD_BBOX)){ @@ -590,9 +665,9 @@ } } -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)){ +void vo_draw_text(int dxs,int dys,uint32_t format,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ mp_osd_obj_t* obj=vo_osd_list; - vo_update_osd(dxs,dys); + vo_update_osd(dxs,dys,format); while(obj){ if(obj->flags&OSDFLAG_VISIBLE){ vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack diff -ur --exclude-from dontdiff vanilla/main/libvo/sub.h main/libvo/sub.h --- vanilla/main/libvo/sub.h 2002-10-06 23:04:28.000000000 +0200 +++ main/libvo/sub.h 2002-11-05 18:53:42.000000000 +0100 @@ -1,7 +1,8 @@ - #ifndef __MPLAYER_SUB_H #define __MPLAYER_SUB_H +#include + typedef struct mp_osd_bbox_s { int x1,y1,x2,y2; } mp_osd_bbox_t; @@ -44,7 +45,8 @@ int allocated; unsigned char *alpha_buffer; - unsigned char *bitmap_buffer; + unsigned char *rgb_buffer; + unsigned char *dest_buffer; } mp_osd_obj_t; @@ -102,11 +104,11 @@ //extern void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); //extern void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); //extern void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); -extern 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)); -extern void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)); +extern void vo_draw_text(int dxs,int dys,uint32_t format,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); +extern void vo_remove_text(int dxs,int dys,uint32_t format,void (*remove)(int x0,int y0, int w,int h)); void vo_init_osd(); -int vo_update_osd(int dxs,int dys); +int vo_update_osd(int dxs,int dys,uint32_t format); int vo_osd_changed(int new_value); int vo_osd_check_range_update(int,int,int,int); diff -ur --exclude-from dontdiff vanilla/main/libvo/vesa_lvo.c main/libvo/vesa_lvo.c --- vanilla/main/libvo/vesa_lvo.c 2002-07-26 18:20:58.000000000 +0200 +++ main/libvo/vesa_lvo.c 2002-11-05 18:53:42.000000000 +0100 @@ -261,12 +261,18 @@ case IMGFMT_YV12: case IMGFMT_IYUV: case IMGFMT_I420: - vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch); + x0 &= ~1; + y0 &= ~1; + vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch, + lvo_mem+bespitch*y0/4+x0/2+mga_vid_config.src_width*mga_vid_config.src_height,bespitch, + lvo_mem+bespitch*y0/4+x0/2+mga_vid_config.src_width*mga_vid_config.src_height*5/4,bespitch); break; case IMGFMT_YUY2: + x0 &= ~1; vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0),bespitch); break; case IMGFMT_UYVY: + x0 &= ~1; vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0)+1,bespitch); break; default: diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_aa.c main/libvo/vo_aa.c --- vanilla/main/libvo/vo_aa.c 2002-10-06 23:04:28.000000000 +0200 +++ main/libvo/vo_aa.c 2002-11-05 18:53:42.000000000 +0100 @@ -569,8 +569,8 @@ vo_osd_text=NULL; vo_osd_progbar_type_save=vo_osd_progbar_type; vo_osd_progbar_type=-1; - vo_remove_text(aa_scrwidth(c), aa_scrheight(c),clear_alpha); - vo_draw_text(aa_scrwidth(c), aa_scrheight(c), draw_alpha); + vo_remove_text(aa_scrwidth(c), aa_scrheight(c),0,clear_alpha); + vo_draw_text(aa_scrwidth(c), aa_scrheight(c),0,draw_alpha); vo_osd_text=vo_osd_text_save; vo_osd_progbar_type=vo_osd_progbar_type_save; #endif diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_dga.c main/libvo/vo_dga.c --- vanilla/main/libvo/vo_dga.c 2002-11-03 17:50:25.000000000 +0100 +++ main/libvo/vo_dga.c 2002-11-05 18:53:42.000000000 +0100 @@ -408,7 +408,7 @@ #include "sub.h" static void draw_osd(void) -{ vo_draw_text(vo_dga_src_width,vo_dga_src_height,draw_alpha); } +{ vo_draw_text(vo_dga_src_width,vo_dga_src_height,vo_dga_src_format,draw_alpha); } static void switch_video_buffers(void) { diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_fbdev.c main/libvo/vo_fbdev.c --- vanilla/main/libvo/vo_fbdev.c 2002-10-30 21:39:27.000000000 +0100 +++ main/libvo/vo_fbdev.c 2002-11-05 18:53:42.000000000 +0100 @@ -1239,7 +1239,7 @@ static void draw_osd(void) { - vo_draw_text(in_width, in_height, draw_alpha); + vo_draw_text(in_width, in_height, pixel_format, draw_alpha); } static void flip_page(void) diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_gif89a.c main/libvo/vo_gif89a.c --- vanilla/main/libvo/vo_gif89a.c 2002-09-22 20:21:45.000000000 +0200 +++ main/libvo/vo_gif89a.c 2002-11-05 18:53:42.000000000 +0100 @@ -170,7 +170,7 @@ static void draw_osd(void) { #ifdef USE_OSD - vo_draw_text(image_width, image_height, draw_alpha); + vo_draw_text(image_width, image_height, IMGFMT_BGR24, draw_alpha); #endif } diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_gl2.c main/libvo/vo_gl2.c --- vanilla/main/libvo/vo_gl2.c 2002-10-29 23:20:10.000000000 +0100 +++ main/libvo/vo_gl2.c 2002-11-05 18:53:42.000000000 +0100 @@ -1040,7 +1040,7 @@ } static void draw_osd(void) -{ vo_draw_text(image_width,image_height,draw_alpha_fnc); } +{ vo_draw_text(image_width,image_height,image_format,draw_alpha_fnc); } static void flip_page(void) diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_jpeg.c main/libvo/vo_jpeg.c --- vanilla/main/libvo/vo_jpeg.c 2002-09-22 20:21:45.000000000 +0200 +++ main/libvo/vo_jpeg.c 2002-11-05 18:53:42.000000000 +0100 @@ -175,7 +175,7 @@ static void draw_osd(void) { - vo_draw_text(image_width, image_height, draw_alpha); + vo_draw_text(image_width, image_height, IMGFMT_BGR24, draw_alpha); } static void flip_page (void) diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_sdl.c main/libvo/vo_sdl.c --- vanilla/main/libvo/vo_sdl.c 2002-11-03 12:16:12.000000000 +0100 +++ main/libvo/vo_sdl.c 2002-11-05 18:53:42.000000000 +0100 @@ -348,14 +348,21 @@ case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_IYUV: - vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0]); + x0 &= ~1; + y0 &= ~1; + vo_draw_alpha_yv12(w,h,src,srca,stride, + priv->overlay->pixels[0]+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0], + priv->overlay->pixels[1]+priv->overlay->pitches[1]*(y0>>1)+x0/2,priv->overlay->pitches[1], + priv->overlay->pixels[2]+priv->overlay->pitches[2]*(y0>>1)+x0/2,priv->overlay->pitches[2]); break; case IMGFMT_YUY2: case IMGFMT_YVYU: + x0 &= ~1; x0 *= 2; vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0]); break; case IMGFMT_UYVY: + x0 &= ~1; x0 *= 2; vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0]); break; @@ -1455,12 +1462,12 @@ /* update osd/subtitles */ if(priv->mode == YUV) - vo_draw_text(priv->overlay->w, priv->overlay->h, draw_alpha); + vo_draw_text(priv->overlay->w, priv->overlay->h, priv->format, draw_alpha); else { if(priv->dblit) - vo_draw_text(priv->surface->w, priv->surface->h, draw_alpha); + vo_draw_text(priv->surface->w, priv->surface->h, priv->format, draw_alpha); else - vo_draw_text(priv->rgbsurface->w, priv->rgbsurface->h, draw_alpha); + vo_draw_text(priv->rgbsurface->w, priv->rgbsurface->h, priv->format, draw_alpha); } } diff -ur --exclude-from dontdiff vanilla/main/libvo/vosub_vidix.c main/libvo/vosub_vidix.c --- vanilla/main/libvo/vosub_vidix.c 2002-10-10 10:22:23.000000000 +0200 +++ main/libvo/vosub_vidix.c 2002-11-05 18:53:42.000000000 +0100 @@ -303,14 +303,20 @@ case IMGFMT_IF09: case IMGFMT_Y8: case IMGFMT_Y800: + x0 &= ~1; + y0 &= ~1; bespitch = (vidix_play.src.w + apitch) & (~apitch); - vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch); + vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch, + lvo_mem+bespitch*(y0/2)+x0/2+vidix_play.offset.v,bespitch/2, + lvo_mem+bespitch*(y0/2)+x0/2+vidix_play.offset.u,bespitch/2); break; case IMGFMT_YUY2: + x0 &= ~1; bespitch = (vidix_play.src.w*2 + apitch) & (~apitch); vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+bespitch*y0+2*x0,bespitch); break; case IMGFMT_UYVY: + x0 &= ~1; bespitch = (vidix_play.src.w*2 + apitch) & (~apitch); vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+bespitch*y0+2*x0+1,bespitch); break; @@ -343,7 +349,7 @@ { if(verbose > 1) printf("vosub_vidix: vidix_draw_osd() was called\n"); /* TODO: hw support */ - vo_draw_text(vidix_play.src.w,vidix_play.src.h,draw_alpha); + vo_draw_text(vidix_play.src.w,vidix_play.src.h,vidix_play.fourcc,draw_alpha); } uint32_t vidix_query_fourcc(uint32_t format) diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_vesa.c main/libvo/vo_vesa.c --- vanilla/main/libvo/vo_vesa.c 2002-10-10 10:22:23.000000000 +0200 +++ main/libvo/vo_vesa.c 2002-11-05 18:53:42.000000000 +0100 @@ -358,7 +358,7 @@ w = dstW; h = dstH; #endif - if(dga_buffer) vo_draw_text(w,h,draw_alpha_fnc); + if(dga_buffer) vo_draw_text(w,h,dstFourcc,draw_alpha_fnc); } } diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_x11.c main/libvo/vo_x11.c --- vanilla/main/libvo/vo_x11.c 2002-10-29 23:20:10.000000000 +0100 +++ main/libvo/vo_x11.c 2002-11-05 18:53:42.000000000 +0100 @@ -456,7 +456,7 @@ } static void draw_osd(void) -{ vo_draw_text(image_width,image_height,draw_alpha_fnc); } +{ vo_draw_text(image_width,image_height,out_format,draw_alpha_fnc); } static void flip_page( void ){ Display_Image( myximage,ImageData ); diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_xv.c main/libvo/vo_xv.c --- vanilla/main/libvo/vo_xv.c 2002-10-23 19:59:22.000000000 +0200 +++ main/libvo/vo_xv.c 2002-11-05 18:53:42.000000000 +0100 @@ -90,13 +90,24 @@ static void draw_alpha_yv12(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ x0+=(vo_panscan_x>>2); + + x0 &= ~1; + y0 &= ~1; + vo_draw_alpha_yv12(w,h,src,srca,stride, - xvimage[current_buf]->data+xvimage[current_buf]->offsets[0]+ - xvimage[current_buf]->pitches[0]*y0+x0,xvimage[current_buf]->pitches[0]); + xvimage[current_buf]->data+xvimage[current_buf]->offsets[0]+ + xvimage[current_buf]->pitches[0]*y0+x0,xvimage[current_buf]->pitches[0], + xvimage[current_buf]->data+xvimage[current_buf]->offsets[1]+ + xvimage[current_buf]->pitches[1]*(y0>>1)+(x0>>1),xvimage[current_buf]->pitches[1], + xvimage[current_buf]->data+xvimage[current_buf]->offsets[2]+ + xvimage[current_buf]->pitches[2]*(y0>>1)+(x0>>1),xvimage[current_buf]->pitches[2] + ); + } static void draw_alpha_yuy2(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ x0+=(vo_panscan_x>>2); + x0 &= ~1; vo_draw_alpha_yuy2(w,h,src,srca,stride, xvimage[current_buf]->data+xvimage[current_buf]->offsets[0]+ xvimage[current_buf]->pitches[0]*y0+2*x0,xvimage[current_buf]->pitches[0]); @@ -104,6 +115,7 @@ static void draw_alpha_uyvy(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ x0+=(vo_panscan_x>>2); + x0 &= ~1; vo_draw_alpha_yuy2(w,h,src,srca,stride, xvimage[current_buf]->data+xvimage[current_buf]->offsets[0]+ xvimage[current_buf]->pitches[0]*y0+2*x0+1,xvimage[current_buf]->pitches[0]); @@ -552,7 +564,7 @@ } static void draw_osd(void) -{ vo_draw_text(image_width-(vo_panscan_x>>1),image_height,draw_alpha_fnc);} +{ vo_draw_text(image_width-(vo_panscan_x>>1),image_height,image_format,draw_alpha_fnc);} static void flip_page(void) { diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_yuv4mpeg.c main/libvo/vo_yuv4mpeg.c --- vanilla/main/libvo/vo_yuv4mpeg.c 2002-10-10 10:22:23.000000000 +0200 +++ main/libvo/vo_yuv4mpeg.c 2002-11-05 18:53:42.000000000 +0100 @@ -163,7 +163,10 @@ { case IMGFMT_YV12: vo_draw_alpha_yv12(w, h, src, srca, stride, - image + y0 * image_width + x0, image_width); + image + (y0&~1) * image_width + (x0&~1), image_width, + image + y0 * image_width/4 + x0/2 + image_width*image_height, image_width/2, + image + y0 * image_width/4 + x0/2 + image_width*image_height*5/4, image_width/2 + ); break; case IMGFMT_BGR|24: @@ -186,7 +189,7 @@ static void draw_osd(void) { - vo_draw_text(image_width, image_height, draw_alpha); + vo_draw_text(image_width, image_height, using_format, draw_alpha); } static void deinterleave_fields(uint8_t *ptr, const int stride, Only in main: mpconf Only in main: Solyaris.CD1of2.srt diff -ur --exclude-from dontdiff vanilla/main/spudec.c main/spudec.c --- vanilla/main/spudec.c 2002-10-15 16:42:45.000000000 +0200 +++ main/spudec.c 2002-11-05 18:53:42.000000000 +0100 @@ -508,13 +508,13 @@ return ret; } -void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) +void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, unsigned char *srcp, int stride)) { spudec_handle_t *spu = (spudec_handle_t *)this; if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts && spu->image) { draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height, - spu->image, spu->aimage, spu->stride); + spu->image, spu->aimage, NULL, spu->stride); /* FIXME */ spu->spu_changed = 0; } } @@ -607,7 +607,7 @@ } #endif -void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) +void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, unsigned char *srcp, int stride)) { spudec_handle_t *spu = (spudec_handle_t *)me; scale_pixel *table_x; @@ -618,7 +618,7 @@ if (spu->image) { draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height, - spu->image, spu->aimage, spu->stride); + spu->image, spu->aimage, NULL, spu->stride); /* FIXME */ spu->spu_changed = 0; } } @@ -902,7 +902,7 @@ spu->scaled_start_row = dys - spu->scaled_height - 1; #endif draw_alpha(spu->scaled_start_col, spu->scaled_start_row, spu->scaled_width, spu->scaled_height, - spu->scaled_image, spu->scaled_aimage, spu->scaled_stride); + spu->scaled_image, spu->scaled_aimage, NULL, spu->scaled_stride); /* FIXME */ spu->spu_changed = 0; } } diff -ur --exclude-from dontdiff vanilla/main/spudec.h main/spudec.h --- vanilla/main/spudec.h 2002-08-15 18:52:52.000000000 +0200 +++ main/spudec.h 2002-11-05 18:53:42.000000000 +0100 @@ -3,8 +3,8 @@ void spudec_heartbeat(void *this, unsigned int pts100); void spudec_assemble(void *this, unsigned char *packet, unsigned int len, unsigned int pts100); -void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); -void spudec_draw_scaled(void *this, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); +void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, unsigned char *srcp, int stride)); +void spudec_draw_scaled(void *this, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, unsigned char *srcp, int stride)); void spudec_update_palette(void *this, unsigned int *palette); void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height); void *spudec_new_scaled_vobsub(unsigned int *palette, unsigned int *cuspal, unsigned int custom, unsigned int frame_width, unsigned int frame_height); @@ -16,6 +16,5 @@ void spudec_set_hw_spu(void *this, vo_functions_t *hw_spu); int spudec_changed(void *this); void spudec_calc_bbox(void *me, unsigned int dxs, unsigned int dys, unsigned int* bbox); -void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); #endif