diff options
author | michael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-02-05 15:56:05 +0000 |
---|---|---|
committer | michael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-02-05 15:56:05 +0000 |
commit | 9094281ecf4ce6471a722cd1f580e2f5392ecaf2 (patch) | |
tree | cb594bf0ed92a1b3b0ba84fa3b8392c95adb9946 /libmpcodecs | |
parent | a0c452f355f73c5f40c92eb1ef2d4876421bf716 (diff) | |
download | mpv-9094281ecf4ce6471a722cd1f580e2f5392ecaf2.tar.bz2 mpv-9094281ecf4ce6471a722cd1f580e2f5392ecaf2.tar.xz |
qp change filter
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11922 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/Makefile | 2 | ||||
-rw-r--r-- | libmpcodecs/vf.c | 2 | ||||
-rw-r--r-- | libmpcodecs/vf_qp.c | 190 |
3 files changed, 193 insertions, 1 deletions
diff --git a/libmpcodecs/Makefile b/libmpcodecs/Makefile index 00f67de5b6..d0b850c5bc 100644 --- a/libmpcodecs/Makefile +++ b/libmpcodecs/Makefile @@ -14,7 +14,7 @@ VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_raw.c vd_hmblck.c vd_fli.c vd_qtrle.c v 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_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 +VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.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 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 ifeq ($(HAVE_FFPOSTPROCESS),yes) VFILTER_SRCS += vf_pp.c endif diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index 5dc02ecc0b..a593e8b844 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -85,6 +85,7 @@ extern vf_info_t vf_info_spp; extern vf_info_t vf_info_yuvcsp; extern vf_info_t vf_info_kerndeint; extern vf_info_t vf_info_rgbtest; +extern vf_info_t vf_info_qp; // list of available filters: static vf_info_t* filter_list[]={ @@ -161,6 +162,7 @@ static vf_info_t* filter_list[]={ &vf_info_yuvcsp, &vf_info_kerndeint, &vf_info_rgbtest, + &vf_info_qp, NULL }; diff --git a/libmpcodecs/vf_qp.c b/libmpcodecs/vf_qp.c new file mode 100644 index 0000000000..2e717e6c31 --- /dev/null +++ b/libmpcodecs/vf_qp.c @@ -0,0 +1,190 @@ +/* + Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <inttypes.h> + +#include "../config.h" + +#ifdef USE_LIBAVCODEC + +#include "../mp_msg.h" +#include "../cpudetect.h" + +#if 1 +double ff_eval(char *s, double *const_value, const char **const_name, + double (**func1)(void *, double), const char **func1_name, + double (**func2)(void *, double, double), char **func2_name, + void *opaque); +#else +#ifdef USE_LIBAVCODEC_SO +#include <ffmpeg/avcodec.h> +#include <ffmpeg/mpegvideo.h> +#else +#include "../libavcodec/avcodec.h" +#include "../libavcodec/mpegvideo.h" +#endif +#endif + +#ifdef HAVE_MALLOC_H +#include <malloc.h> +#endif + +#include "img_format.h" +#include "mp_image.h" +#include "vf.h" +#include "../libvo/fastmemcpy.h" + + +struct vf_priv_s { + char eq[200]; + int8_t *qp; + int8_t lut[257]; + int qp_stride; +}; + +static int config(struct vf_instance_s* vf, + int width, int height, int d_width, int d_height, + unsigned int flags, unsigned int outfmt){ + int h= (height+15)>>4; + int i; + + vf->priv->qp_stride= (width+15)>>4; + vf->priv->qp= malloc(vf->priv->qp_stride*h*sizeof(int8_t)); + + for(i=-129; i<128; i++){ + double const_values[]={ + M_PI, + M_E, + i != -129, + i, + 0 + }; + static const char *const_names[]={ + "PI", + "E", + "known", + "qp", + NULL + }; + + vf->priv->lut[i+129]= lrintf(ff_eval(vf->priv->eq, const_values, const_names, NULL, NULL, NULL, NULL, NULL)); + } + + return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); +} + +static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ + if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change + // ok, we can do pp in-place (or pp disabled): + vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, + mpi->type, mpi->flags, mpi->w, mpi->h); + mpi->planes[0]=vf->dmpi->planes[0]; + mpi->stride[0]=vf->dmpi->stride[0]; + mpi->width=vf->dmpi->width; + if(mpi->flags&MP_IMGFLAG_PLANAR){ + mpi->planes[1]=vf->dmpi->planes[1]; + mpi->planes[2]=vf->dmpi->planes[2]; + mpi->stride[1]=vf->dmpi->stride[1]; + mpi->stride[2]=vf->dmpi->stride[2]; + } + mpi->flags|=MP_IMGFLAG_DIRECT; +} + +static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ + mp_image_t *dmpi; + int x,y; + + if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ + // no DR, so get a new image! hope we'll get DR buffer: + vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, + MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, + mpi->w,mpi->h); + } + + dmpi= vf->dmpi; + + if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ + memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]); + if(mpi->flags&MP_IMGFLAG_PLANAR){ + 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]); + } + } + vf_clone_mpi_attributes(dmpi, mpi); + + dmpi->qscale = vf->priv->qp; + dmpi->qstride= vf->priv->qp_stride; + if(mpi->qscale){ + for(y=0; y<((dmpi->h+15)>>4); y++){ + for(x=0; x<vf->priv->qp_stride; x++){ + dmpi->qscale[x + dmpi->qstride*y]= + vf->priv->lut[ 129 + ((int8_t)mpi->qscale[x + mpi->qstride*y]) ]; + } + } + }else{ + int qp= vf->priv->lut[0]; + for(y=0; y<((dmpi->h+15)>>4); y++){ + for(x=0; x<vf->priv->qp_stride; x++){ + dmpi->qscale[x + dmpi->qstride*y]= qp; + } + } + } + + return vf_next_put_image(vf,dmpi); +} + +static void uninit(struct vf_instance_s* vf){ + if(!vf->priv) return; + + if(vf->priv->qp) free(vf->priv->qp); + vf->priv->qp= NULL; + + free(vf->priv); + vf->priv=NULL; +} + +//===========================================================================// +static int open(vf_instance_t *vf, char* args){ + vf->config=config; + vf->put_image=put_image; + vf->get_image=get_image; + vf->uninit=uninit; + vf->priv=malloc(sizeof(struct vf_priv_s)); + memset(vf->priv, 0, sizeof(struct vf_priv_s)); + +// avcodec_init(); + + if (args) strncpy(vf->priv->eq, args, 199); + + return 1; +} + +vf_info_t vf_info_qp = { + "QP changer", + "qp", + "Michael Niedermayer", + "", + open, + NULL +}; + +#endif //USE_LIBAVCODEC |