[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Original]
Re: [MPlayer-users] color of subtitles
Arpi wrote:
hey, it don't know even if it would have teh height.
*FORGET* that U and V planes are beginning right after teh Y one...
it isn't always true, or even more valid: it's rare that true!
(yes it's true for Xv, and maybe for directfb, but false for sure in
mga/xmga, vidix, and some which uses stride!=width or planes needs to be
aligned)
so, you actually want the pointers to all 3 planes (from the caller!)
insted of the Y only. only teh caller func knows where the planes begin.
ok, got it :) i crufted few pieces of code so now I have hardcoded
yellow subtitles in YV12. Just to attract some flam^H^H^H^Hcomments,
here is a patch (rather a sketch of one). Packed formats should be easy
as they won't involve additional changes in the code outside of osd.
In addition to three source pointers & strides there are args specifying
x0 mod 2 & y0 mod 2 which I needed for proper chroma/luma alignment.
Regards,
--
Jindrich Makovicka
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-01 21:00:36.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,16 @@
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],
+ x0 & 0x01, y0 & 0x01);
break;
case IMGFMT_YUY2:
vo_draw_alpha_yuy2(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0]);
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-01 20:57:48.000000000 +0100
@@ -109,32 +109,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, int xmod,
int ymod){
#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, xmod, ymod);
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, xmod, ymod);
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, xmod, ymod);
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, xmod, ymod);
#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, xmod, ymod);
#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, xmod, ymod);
#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, xmod, ymod);
#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, xmod, ymod);
#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, xmod, ymod);
#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, xmod, ymod);
#endif
#endif //!RUNTIME_CPUDETECT
}
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-01 20:56:25.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, int xmod,
int ymod);
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-01 21:04:07.000000000 +0100
@@ -27,8 +27,19 @@
#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){
+#define THR 30
+static inline int check_alpha(unsigned char *srca, int srcstride)
+{
+// if ((srca[0] < THR && srca[0]) || (srca[1] < THR && srca[1])
+// || (srca[srcstride] < THR && srca[srcstride]) || (srca[srcstride+1] <
THR && srca[srcstride+1])) return 1;
+ if (srca[0] || srca[1] || srca[srcstride] || srca[srcstride+1]) return 1;
+ return 0;
+}
+
+static inline void RENAME(vo_draw_alpha_yv12)(int w,int h, unsigned char*
src1, unsigned char *srca1, int srcstride, unsigned char* dstbase1,int
dststride1, unsigned char* dstbase2, int dststride2, unsigned char* dstbase3,
int dststride3, int xmod, int ymod){
int y;
+ unsigned char *src = src1;
+ unsigned char *srca = srca1;
#if defined(FAST_OSD) && !defined(HAVE_MMX)
w=w>>1;
#endif
@@ -45,7 +56,7 @@
"movq %%mm5, %%mm4\n\t"
"psllw $8, %%mm5\n\t" //FF00FF00FF00
"psrlw $8, %%mm4\n\t" //00FF00FF00FF
- ::"m"(*dstbase),"m"(*srca),"m"(*src):"memory");
+ ::"m"(*dstbase1),"m"(*srca),"m"(*src):"memory");
for(x=0;x<w;x+=8){
asm volatile(
"movl %1, %%eax\n\t"
@@ -71,22 +82,44 @@
"paddb %2, %%mm0\n\t"
"movq %%mm0, %0\n\t"
"1:\n\t"
- :: "m" (dstbase[x]), "m" (srca[x]), "m" (src[x])
+ :: "m" (dstbase1[x]), "m" (srca[x]), "m" (src[x])
: "%eax");
}
#else
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];
+ if(srca[2*x+0]) dstbase1[2*x+0]=src[2*x+0];
+ if(srca[2*x+1]) dstbase1[2*x+1]=src[2*x+1];
#else
- if(srca[x]) dstbase[x]=((dstbase[x]*srca[x])>>8)+src[x];
+ if(srca[x]) dstbase1[x]=((dstbase1[x]*srca[x])>>8)+src[x];
#endif
}
#endif
src+=srcstride;
srca+=srcstride;
- dstbase+=dststride;
+ dstbase1+=dststride1;
+ }
+ src = src1-srcstride*ymod-xmod;
+ dstbase2+=dststride2;
+ src+=srcstride*2;
+ for(y=1;y<h/2-1;y++){
+ register int x;
+ for(x=1;x<w/2-1;x++){
+ if (check_alpha(src+2*x,srcstride)) dstbase2[x]=128;
+ }
+ dstbase2+=dststride2;
+ src+=srcstride*2;
+ }
+ src = src1-srcstride*ymod-xmod;
+ dstbase3+=dststride3;
+ src+=srcstride*2;
+ for(y=1;y<h/2-1;y++){
+ register int x;
+ for(x=1;x<w/2-1;x++){
+ if (check_alpha(src+2*x,srcstride)) dstbase3[x]=0;
+ }
+ dstbase3+=dststride3;
+ src+=srcstride*2;
}
#ifdef HAVE_MMX
asm volatile(EMMS:::"memory");
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-01 20:59:41.000000000 +0100
@@ -261,7 +261,10 @@
case IMGFMT_YV12:
case IMGFMT_IYUV:
case IMGFMT_I420:
-
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/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,
+ x0 & 0x01, y0 & 0x01);
break;
case IMGFMT_YUY2:
vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0),bespitch);
diff -ur --exclude-from dontdiff vanilla/main/libvo/vo_sdl.c main/libvo/vo_sdl.c
--- vanilla/main/libvo/vo_sdl.c 2002-10-10 10:22:23.000000000 +0200
+++ main/libvo/vo_sdl.c 2002-11-01 21:00:05.000000000 +0100
@@ -348,7 +348,11 @@
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]);
+ vo_draw_alpha_yv12(w,h,src,srca,stride,
+ ((uint8_t *)
*(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0],
+ ((uint8_t *)
*(priv->overlay->pixels))+priv->overlay->pitches[1]*y0+x0/2,priv->overlay->pitches[1],
+ ((uint8_t *)
*(priv->overlay->pixels))+priv->overlay->pitches[2]*y0+x0/2,priv->overlay->pitches[2],
+ x0 & 0x01, y0 & 0x01);
break;
case IMGFMT_YUY2:
case IMGFMT_YVYU:
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-01 20:59:15.000000000 +0100
@@ -90,9 +90,17 @@
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);
+
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],
+ x0 & 0x01, y0 & 0x01
+ );
+
}
static void draw_alpha_yuy2(int x0,int y0, int w,int h, unsigned char* src,
unsigned char *srca, int stride){
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-01 20:58:55.000000000 +0100
@@ -163,7 +163,11 @@
{
case IMGFMT_YV12:
vo_draw_alpha_yv12(w, h, src, srca, stride,
- image + y0 * image_width + x0,
image_width);
+ image + y0 * image_width + x0, 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,
+ x0 & 0x01, y0 & 0x01
+ );
break;
case IMGFMT_BGR|24:
- [MPlayer-users] color of subtitles, Jakub Turski, 2002/11/01
- Re: [MPlayer-users] color of subtitles, Dominik Szczerba, 2002/11/01
- Re: [MPlayer-users] color of subtitles, Jindrich Makovicka, 2002/11/01
- Re: [MPlayer-users] color of subtitles, Jindrich Makovicka, 2002/11/01
- Re: [MPlayer-users] color of subtitles, Arpi, 2002/11/01
- Re: [MPlayer-users] color of subtitles, Jindrich Makovicka, 2002/11/01
- Re: [MPlayer-users] color of subtitles, Arpi, 2002/11/01
- Re: [MPlayer-users] color of subtitles,
Jindrich Makovicka <=
- Re: [MPlayer-users] color of subtitles, 陆然, 2002/11/02
- Re: [MPlayer-users] color of subtitles, Jindrich Makovicka, 2002/11/02
- Re: [MPlayer-users] color of subtitles, Arpi, 2002/11/02
- Re: [MPlayer-users] color of subtitles, Jakub Turski, 2002/11/02