Mercurial > mplayer.hg
changeset 6820:a99c7700e4f1
New plugin to test crop parameters. Arguments are the same as for the
crop plugin.
author | kmkaplan |
---|---|
date | Sat, 27 Jul 2002 11:40:15 +0000 |
parents | 8c97eacc383c |
children | 414ea538b99e |
files | libmpcodecs/Makefile libmpcodecs/vf.c libmpcodecs/vf_rectangle.c |
diffstat | 3 files changed, 100 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/Makefile Sat Jul 27 01:12:53 2002 +0000 +++ b/libmpcodecs/Makefile Sat Jul 27 11:40:15 2002 +0000 @@ -6,7 +6,7 @@ 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
--- a/libmpcodecs/vf.c Sat Jul 27 01:12:53 2002 +0000 +++ b/libmpcodecs/vf.c Sat Jul 27 11:40:15 2002 +0000 @@ -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 @@ // list of available filters: static vf_info_t* filter_list[]={ + &vf_info_rectangle, &vf_info_crop, &vf_info_expand, &vf_info_pp,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libmpcodecs/vf_rectangle.c Sat Jul 27 11:40:15 2002 +0000 @@ -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 +};