diff options
author | kmkaplan <kmkaplan@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-07-27 11:40:15 +0000 |
---|---|---|
committer | kmkaplan <kmkaplan@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-07-27 11:40:15 +0000 |
commit | 82d7ad5c0fcfd9de7bf47fd19af13c12272f48c5 (patch) | |
tree | f9f244428cfcb0530b5ba2d839d22cb9b77acc1f | |
parent | fbc9c8e7a2f2bc8906b7060b629f214715c663ea (diff) |
New plugin to test crop parameters. Arguments are the same as for the
crop plugin.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6821 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libmpcodecs/Makefile | 2 | ||||
-rw-r--r-- | libmpcodecs/vf.c | 2 | ||||
-rw-r--r-- | libmpcodecs/vf_rectangle.c | 97 |
3 files changed, 100 insertions, 1 deletions
diff --git a/libmpcodecs/Makefile b/libmpcodecs/Makefile index 8e3d8fdfc8..65dbbf9c2e 100644 --- a/libmpcodecs/Makefile +++ b/libmpcodecs/Makefile @@ -6,7 +6,7 @@ LIBNAME2 = libmpencoders.a AUDIO_SRCS=dec_audio.c ad.c ad_a52.c ad_acm.c ad_alaw.c ad_dk3adpcm.c ad_dshow.c ad_dvdpcm.c ad_ffmpeg.c ad_hwac3.c ad_imaadpcm.c ad_mp3.c ad_msadpcm.c ad_pcm.c ad_roqaudio.c ad_msgsm.c ad_faad.c ad_vorbis.c ad_libmad.c ad_real.c VIDEO_SRCS=dec_video.c vd.c vd_null.c vd_real.c vd_cinepak.c vd_qtrpza.c vd_ffmpeg.c vd_dshow.c vd_vfw.c vd_odivx.c vd_divx4.c vd_raw.c vd_xanim.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_nuv.c vd_libmpeg2.c vd_msrle.c vd_huffyuv.c vd_zlib.c vd_mpegpes.c vd_svq1.c vd_xvid.c -VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_pp.c vf_scale.c vf_format.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 +VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_pp.c vf_scale.c vf_format.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 ENCODER_SRCS=ve.c ve_divx4.c ve_lavc.c ve_vfw.c ve_rawrgb.c ve_libdv.c NATIVE_SRCS=native/RTjpegN.c native/cinepak.c native/cyuv.c native/fli.c native/minilzo.c native/msvidc.c native/nuppelvideo.c native/qtrle.c native/qtrpza.c native/qtsmc.c native/roqav.c native/xa_gsm.c native/svq1.c diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index 4641456e77..1f6f3d5895 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -14,6 +14,7 @@ #include "vf.h" extern vf_info_t vf_info_vo; +extern vf_info_t vf_info_rectangle; extern vf_info_t vf_info_crop; extern vf_info_t vf_info_expand; extern vf_info_t vf_info_pp; @@ -39,6 +40,7 @@ char** vo_plugin_args=(char**) NULL; // list of available filters: static vf_info_t* filter_list[]={ + &vf_info_rectangle, &vf_info_crop, &vf_info_expand, &vf_info_pp, diff --git a/libmpcodecs/vf_rectangle.c b/libmpcodecs/vf_rectangle.c new file mode 100644 index 0000000000..b55b2e7cf2 --- /dev/null +++ b/libmpcodecs/vf_rectangle.c @@ -0,0 +1,97 @@ +#include <stdio.h> +#include <stdlib.h> +#include "mp_image.h" +#include "vf.h" + +struct vf_priv_s { + int x, y, w, h; +}; + +static void +put_image(struct vf_instance_s* vf, mp_image_t* mpi){ + mp_image_t* dmpi; + int x, y, w, h; + unsigned int bpp, count; + unsigned char *p1, *p2; + dmpi = vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_TEMP, 0, mpi->w, mpi->h); + bpp = dmpi->bpp / 8; + memcpy(dmpi->planes[0], mpi->planes[0], dmpi->stride[0] * bpp * mpi->height); + memcpy(dmpi->planes[1], mpi->planes[1], dmpi->stride[1] * mpi->chroma_height); + memcpy(dmpi->planes[2], mpi->planes[2], dmpi->stride[2] * mpi->chroma_height); + + /* Draw the rectangle */ + x = vf->priv->x; + if (x < 0) + x = 0; + y = vf->priv->y; + if (y < 0) + y = 0; + w = vf->priv->w; + if (w < 0) + w = dmpi->w - x; + h = vf->priv->h; + if (h < 0) + h = dmpi->h - y; + count = w * bpp; + p1 = dmpi->planes[0] + y * dmpi->stride[0] + x * bpp; + if (h == 1) + while (count--) { + *p1 = 0xff - *p1; + ++p1; + } + else { + p2 = p1 + (h - 1) * dmpi->stride[0]; + while (count--) { + *p1 = 0xff - *p1; + ++p1; + *p2 = 0xff - *p2; + ++p2; + } + } + count = h; + p1 = dmpi->planes[0] + y * dmpi->stride[0] + x * bpp; + if (w == 1) + while (count--) { + int i = bpp; + while (i--) + p1[i] ^= 0xff; + p1 += dmpi->stride[0]; + } + else { + p2 = p1 + (w - 1) * bpp; + while (count--) { + int i = bpp; + while (i--) { + p1[i] = 0xff - p1[i]; + p2[i] = 0xff - p2[i]; + } + p1 += dmpi->stride[0]; + p2 += dmpi->stride[0]; + } + } + vf_next_put_image(vf, dmpi); +} + +static int +open(vf_instance_t* vf, char* args) { + 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; + if (args) + sscanf(args, "%d:%d:%d:%d", + &vf->priv->w, &vf->priv->h, &vf->priv->x, &vf->priv->y); + printf("Crop: %d x %d, %d ; %d\n", + vf->priv->w, vf->priv->h, vf->priv->x, vf->priv->y); + return 1; +} + +vf_info_t vf_info_rectangle = { + "draw rectangle", + "rectangle", + "Kim Minh Kaplan", + "", + open +}; |