[MPlayer-dev-eng] [PATCH] (not for CVS submission) opaque subtitles
Pierre Lombard
p_l at gmx.fr
Tue Jan 28 10:14:15 CET 2003
Hi,
Here are 2 dirty hacks to have opaque gray subtitles when watching sthg
with vo xv and encoding (in YV12 color space) with subtitles.
They set the U+V channels to 128 if the alpha channel is below a
threshold.
Of course it's not meant at all to be submitted for CVS (sorry I don't
have time to properly clean it right now).
There are probably some bugs (off by 1 or nastier ones etc) but it seems
to work.
--
Best regards,
pl
-------------- next part --------------
Index: libmpcodecs/vf_expand.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_expand.c,v
retrieving revision 1.18
diff -u -r1.18 vf_expand.c
--- libmpcodecs/vf_expand.c 10 Jan 2003 10:43:01 -0000 1.18
+++ libmpcodecs/vf_expand.c 28 Jan 2003 09:08:27 -0000
@@ -115,6 +116,46 @@
case IMGFMT_IF09:
case IMGFMT_Y800:
case IMGFMT_Y8:
+#define OPAQUE_ALPHA 1
+#warning "*** OPAQUE_ALPHA YV12 ENABLED ***"
+#if OPAQUE_ALPHA
+ if (vf->priv->dmpi->imgfmt == IMGFMT_YV12) {
+ int x, y;
+ unsigned char *u = vf->priv->dmpi->planes[1];
+ unsigned char *v = vf->priv->dmpi->planes[2];
+ int uv_w = vf->priv->dmpi->chroma_width;
+ int uv_h = vf->priv->dmpi->chroma_height;
+ int stride_u = vf->priv->dmpi->stride[1];
+ int stride_v = vf->priv->dmpi->stride[2];
+ int stride = vf->priv->dmpi->stride[0];
+
+ unsigned char *alpha_line, *u_line, *v_line;
+
+
+
+ for (y = (y0 & 0xFFFFFFFE);
+ y < ((y0+h) & 0xFFFFFFFE);
+ y += 2) {
+ alpha_line = srca + (y - (y0 & 0xFFFFFFFE)) * stride;
+ u_line = u + stride_u * y / 2;
+ v_line = v + stride_v * y / 2;
+
+ for (x = x0 & 0xFFFFFFFE;
+ x < (x0 & 0xFFFFFFFE) + w;
+ x += 2) {
+ if (alpha_line[(x& 0xFFFFFFFE)-x0] && alpha_line[(x& 0xFFFFFFFE)-x0] < 128 ) {
+ u_line[x / 2] = 128;
+ v_line[x / 2] = 128;
+ }
+ }
+ }
+
+// printf("\nlibmpcodecs/vf_expand.c::draw_func()->IMGFMT_YV12\n"
+// "vf->priv->dmpi->num_planes=%d\n"
+// "uv_w=%d,uv_h=%d",vf->priv->dmpi->num_planes, uv_w,uv_h);
+
+ }
+#endif
vo_draw_alpha_yv12(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0]);
break;
case IMGFMT_YUY2:
Index: libvo/vo_xv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xv.c,v
retrieving revision 1.134
diff -u -r1.134 vo_xv.c
--- libvo/vo_xv.c 19 Jan 2003 16:52:00 -0000 1.134
+++ libvo/vo_xv.c 28 Jan 2003 09:08:29 -0000
@@ -1,3 +1,5 @@
+#define OPAQUE_ALPHA 1
+
/* vo_xv.c, X11 Xv interface */
// Number of buffers _FOR_DOUBLEBUFFERING_MODE_
@@ -90,6 +92,34 @@
static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride);
static void draw_alpha_yv12(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
+#if OPAQUE_ALPHA
+#warning "*** OPAQUE_ALPHA enabled *** "
+ do {
+ int x,y;
+ unsigned char *u = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1];
+ int u_stride = xvimage[current_buf]->pitches[1];
+ unsigned char *v = xvimage[current_buf]->data + xvimage[current_buf]->offsets[2];
+ int v_stride = xvimage[current_buf]->pitches[2];
+ unsigned char *alpha_line, *u_line, *v_line;
+
+ for (y = (y0 & 0xFFFFFFFE);
+ y < ((y0+h) & 0xFFFFFFFE);
+ y += 2) {
+ alpha_line = srca + (y - (y0 & 0xFFFFFFFE)) * stride;
+ u_line = u + u_stride * y / 2;
+ v_line = v + v_stride * y / 2;
+
+ for (x = x0 & 0xFFFFFFFE;
+ x < (x0 & 0xFFFFFFFE) + w;
+ x += 2) {
+ if (alpha_line[(x& 0xFFFFFFFE)-x0] && alpha_line[(x& 0xFFFFFFFE)-x0] < 128 ) {
+ u_line[x / 2] = 128;
+ v_line[x / 2] = 128;
+ }
+ }
+ }
+ } while (0);
+#endif
x0+=image_width*(vo_panscan_x>>1)/(vo_dwidth+vo_panscan_x);
vo_draw_alpha_yv12(w,h,src,srca,stride,
xvimage[current_buf]->data+xvimage[current_buf]->offsets[0]+
More information about the MPlayer-dev-eng
mailing list