--- DOCS/man/en/mplayer.1 4 May 2004 14:18:40 -0000 1.586 +++ DOCS/man/en/mplayer.1 5 May 2004 14:59:14 -0000 @@ -3539,6 +3539,21 @@ .RE .PD 1 .TP +.TP +.B lumbox[=w:h:x:y:l] +Set a constant luminance on a box of the requested width and height at +the specified coordinates. +Can be used for removing text on a dark color background. +.PD 0 +.RSs +.IPs w,h +width and height (default: -1, maximum possible width) +.IPs x,y +top left corner position (default: -1, uppermost leftmost) +.IPs l +luminance (0-255, default: 0) +.RE +.PD 1 .B zrmjpeg[=options] Software YV12 to MJPEG encoder for use with the zr2 video output device. Index: libmpcodecs/Makefile --- libmpcodecs/Makefile 29 Apr 2004 22:21:54 -0000 1.130 +++ libmpcodecs/Makefile 5 May 2004 14:59:14 -0000 @@ -14,7 +14,7 @@ VIDEO_SRCS_OPT=vd_realvid.c vd_ffmpeg.c vd_dshow.c vd_dmo.c vd_vfw.c vd_vfwex.c vd_odivx.c vd_divx4.c vd_zrmjpeg.c vd_xanim.c vd_xvid.c vd_xvid4.c vd_libdv.c vd_qtvideo.c vd_theora.c VIDEO_SRCS=dec_video.c vd.c $(VIDEO_SRCS_NAT) $(VIDEO_SRCS_LIB) $(VIDEO_SRCS_OPT) -VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_scale.c vf_format.c vf_noformat.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c vf_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.c vf_dsize.c vf_decimate.c vf_softpulldown.c vf_tinterlace.c vf_pullup.c pullup.c vf_framestep.c vf_tile.c vf_delogo.c vf_fil.c vf_hue.c vf_spp.c vf_yuvcsp.c vf_filmdint.c vf_kerndeint.c vf_rgbtest.c vf_qp.c vf_phase.c vf_divtc.c vf_harddup.c vf_softskip.c +VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_scale.c vf_format.c vf_noformat.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c vf_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.c vf_dsize.c vf_decimate.c vf_softpulldown.c vf_tinterlace.c vf_pullup.c pullup.c vf_framestep.c vf_tile.c vf_delogo.c vf_fil.c vf_hue.c vf_spp.c vf_yuvcsp.c vf_filmdint.c vf_kerndeint.c vf_rgbtest.c vf_qp.c vf_phase.c vf_divtc.c vf_harddup.c vf_softskip.c vf_lumbox.c ifeq ($(HAVE_FFPOSTPROCESS),yes) VFILTER_SRCS += vf_pp.c endif Index: libmpcodecs/vf.c --- libmpcodecs/vf.c 28 Apr 2004 04:29:17 -0000 1.107 +++ libmpcodecs/vf.c 5 May 2004 14:59:15 -0000 @@ -21,6 +21,7 @@ extern vf_info_t vf_info_vo; extern vf_info_t vf_info_rectangle; +extern vf_info_t vf_info_lumbox; #ifndef HAVE_NO_POSIX_SELECT extern vf_info_t vf_info_bmovl; #endif @@ -95,6 +96,7 @@ // list of available filters: static vf_info_t* filter_list[]={ &vf_info_rectangle, + &vf_info_lumbox, #ifndef HAVE_NO_POSIX_SELECT &vf_info_bmovl, #endif --- /dev/null 1970-01-01 01:00:00.000000000 +0100 +++ libmpcodecs/vf_lumbox.c 2004-05-05 16:50:40.000000000 +0200 @@ -0,0 +1,165 @@ +#include +#include +#include +#include "mp_image.h" +#include "../mp_msg.h" +#include "vf.h" + +#include "../libvo/fastmemcpy.h" + +/* code originally from the rectangle filter written by Kim Minh Kaplan */ + +struct vf_priv_s { + int x, y, w, h, lum; +}; + +static int +config(struct vf_instance_s* vf, + int width, int height, int d_width, int d_height, + unsigned int flags, unsigned int outfmt) +{ + if (vf->priv->lum < 0) + vf->priv->lum = 0; + else if (vf->priv->lum > 0xff) + vf->priv->lum = 0xff; + if (vf->priv->w < 0 || width < vf->priv->w) + vf->priv->w = width; + if (vf->priv->h < 0 || height < vf->priv->h) + vf->priv->h = height; + if (vf->priv->x < 0) + vf->priv->x = (width - vf->priv->w) / 2; + if (vf->priv->y < 0) + vf->priv->y = (height - vf->priv->h) / 2; + if (vf->priv->w + vf->priv->x > width + || vf->priv->h + vf->priv->y > height) { + mp_msg(MSGT_VFILTER,MSGL_WARN,"lumbox: bad position/width/height - rectangle area is out of the original!\n"); + return 0; + + } + return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt); +} + +static int +control(struct vf_instance_s* vf, int request, void *data) +{ + const int *const tmp = data; + switch(request){ + case VFCTRL_CHANGE_RECTANGLE: + switch (tmp[0]){ + case 0: + vf->priv->w += tmp[1]; + return 1; + break; + case 1: + vf->priv->h += tmp[1]; + return 1; + break; + case 2: + vf->priv->x += tmp[1]; + return 1; + break; + case 3: + vf->priv->y += tmp[1]; + return 1; + break; + case 4: + vf->priv->lum += tmp[1]; + return 1; + break; + default: + mp_msg(MSGT_VFILTER,MSGL_FATAL,"Unknown param %d \n", tmp[0]); + return 0; + } + } + return vf_next_control(vf, request, data); + return 0; +} +static int +put_image(struct vf_instance_s* vf, mp_image_t* mpi){ + mp_image_t* dmpi; + unsigned int bpp = mpi->bpp / 8; + unsigned int x, y, w, h; + dmpi = vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_TEMP, + MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE, + mpi->w, mpi->h); + + memcpy_pic(dmpi->planes[0],mpi->planes[0],mpi->w*bpp, mpi->h, + dmpi->stride[0],mpi->stride[0]); + if(mpi->flags&MP_IMGFLAG_PLANAR && mpi->flags&MP_IMGFLAG_YUV){ + memcpy_pic(dmpi->planes[1],mpi->planes[1], + mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, + dmpi->stride[1],mpi->stride[1]); + memcpy_pic(dmpi->planes[2],mpi->planes[2], + mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, + dmpi->stride[2],mpi->stride[2]); + } + + /* Change luminance on the box */ + + mp_msg(MSGT_VFILTER,MSGL_INFO, "lumbox: -vf lumbox=%d:%d:%d:%d:%d \n", vf->priv->w, vf->priv->h, vf->priv->x, vf->priv->y, vf->priv->lum); + + if (vf->priv->x < 0) + x = 0; + else if (dmpi->width < vf->priv->x) + x = dmpi->width; + else + x = vf->priv->x; + if (vf->priv->x + vf->priv->w - 1 < 0) + w = vf->priv->x + vf->priv->w - 1 - x; + else if (dmpi->width < vf->priv->x + vf->priv->w - 1) + w = dmpi->width - x; + else + w = vf->priv->x + vf->priv->w - 1 - x; + if (vf->priv->y < 0) + y = 0; + else if (dmpi->height < vf->priv->y) + y = dmpi->height; + else + y = vf->priv->y; + if (vf->priv->y + vf->priv->h - 1 < 0) + h = vf->priv->y + vf->priv->h - 1 - y; + else if (dmpi->height < vf->priv->y + vf->priv->h - 1) + h = dmpi->height - y; + else + h = vf->priv->y + vf->priv->h - 1 - y; + + if (0 <= vf->priv->y && vf->priv->y <= dmpi->height && 0 <= vf->priv->x && vf->priv->x <= dmpi->width) { + unsigned int ycount = h; + unsigned int xcount; + unsigned char *p; + while(ycount--) { + p = dmpi->planes[0] + (y + ycount) * dmpi->stride[0] + x * bpp; + xcount = w * bpp; + while (xcount--) + p[xcount] = vf->priv->lum; + } + } + + return vf_next_put_image(vf, dmpi); +} + +static int +open(vf_instance_t* vf, char* args) { + vf->config = config; + vf->control = control; + vf->put_image = put_image; + vf->priv = malloc(sizeof(struct vf_priv_s)); + vf->priv->x = -1; + vf->priv->y = -1; + vf->priv->w = -1; + vf->priv->h = -1; + vf->priv->lum = -1; + if (args) + sscanf(args, "%d:%d:%d:%d:%d", + &vf->priv->w, &vf->priv->h, &vf->priv->x, &vf->priv->y, &vf->priv->lum); + return 1; +} + +vf_info_t vf_info_lumbox = { + "set constant luminance on a box", + "lumbox", + "Erik Waling", + "", + open, + NULL +};