From d686517ad113e72b9e434b35598a4a8480d79307 Mon Sep 17 00:00:00 2001 From: Clément Bœsch Date: Thu, 16 May 2013 00:44:37 +0200 Subject: lavfi/mp: remove mp=ow wrapper. Filter ported natively as owdenoise. --- libavfilter/libmpcodecs/vf_ow.c | 322 ---------------------------------------- 1 file changed, 322 deletions(-) delete mode 100644 libavfilter/libmpcodecs/vf_ow.c (limited to 'libavfilter/libmpcodecs') diff --git a/libavfilter/libmpcodecs/vf_ow.c b/libavfilter/libmpcodecs/vf_ow.c deleted file mode 100644 index 69b07efa46..0000000000 --- a/libavfilter/libmpcodecs/vf_ow.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (C) 2007 Michael Niedermayer - * - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * @todo try to change to int - * @todo try lifting based implementation - * @todo optimize optimize optimize - * @todo hard tresholding - * @todo use QP to decide filter strength - * @todo wavelet normalization / least squares optimal signal vs. noise thresholds - */ - -#include -#include -#include -#include - -#include "mp_msg.h" -#include "img_format.h" -#include "mp_image.h" -#include "vf.h" - -//===========================================================================// -static const uint8_t __attribute__((aligned(8))) dither[8][8]={ -{ 0, 48, 12, 60, 3, 51, 15, 63, }, -{ 32, 16, 44, 28, 35, 19, 47, 31, }, -{ 8, 56, 4, 52, 11, 59, 7, 55, }, -{ 40, 24, 36, 20, 43, 27, 39, 23, }, -{ 2, 50, 14, 62, 1, 49, 13, 61, }, -{ 34, 18, 46, 30, 33, 17, 45, 29, }, -{ 10, 58, 6, 54, 9, 57, 5, 53, }, -{ 42, 26, 38, 22, 41, 25, 37, 21, }, -}; -//FIXME the above is duplicated in many filters - -struct vf_priv_s { - float strength[2]; - float delta; - int mode; - int depth; - float *plane[16][4]; - int stride; -}; - -#define S 1.41421356237 //sqrt(2) - -static const double coeff[2][5]={ - { - 0.6029490182363579 *S, - 0.2668641184428723 *S, - -0.07822326652898785 *S, - -0.01686411844287495 *S, - 0.02674875741080976 *S - },{ - 1.115087052456994 /S, - -0.5912717631142470 /S, - -0.05754352622849957 /S, - 0.09127176311424948 /S - } -}; - -static const double icoeff[2][5]={ - { - 1.115087052456994 /S, - 0.5912717631142470 /S, - -0.05754352622849957 /S, - -0.09127176311424948 /S - },{ - 0.6029490182363579 *S, - -0.2668641184428723 *S, - -0.07822326652898785 *S, - 0.01686411844287495 *S, - 0.02674875741080976 *S - } -}; -#undef S - -static inline int mirror(int x, int w){ - while((unsigned)x > (unsigned)w){ - x=-x; - if(x<0) x+= 2*w; - } - return x; -} - -static inline void decompose(float *dstL, float *dstH, float *src, int stride, int w){ - int x, i; - for(x=0; xstrength[!is_luma]; - int depth= p->depth; - - while(1< width || 1< height) - depth--; - - for(y=0; yplane[0][0][x + y*p->stride]= src[x + y*src_stride]; - - for(i=0; iplane[i+1], p->plane[i][0], p->plane[0]+1,p->stride, 1<plane[i+1][j][x + y*p->stride]; - if (v> s) v-=s; - else if(v<-s) v+=s; - else v =0; - p->plane[i+1][j][x + y*p->stride]= v; - } - } - } - } - for(i=depth-1; i>=0; i--){ - compose2D2(p->plane[i][0], p->plane[i+1], p->plane[0]+1, p->stride, 1<plane[0][0][x + y*p->stride] + dither[x&7][y&7]*(1.0/64) + 1.0/128; //yes the rounding is insane but optimal :) -// double e= i - src[x + y*src_stride]; -// sum += e*e; - if((unsigned)i > 255U) i= ~(i>>31); - dst[x + y*dst_stride]= i; - } - -// printf("%f\n", sum/height/width); -} - -static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ - int h= (height+15)&(~15); - int i,j; - - vf->priv->stride= (width+15)&(~15); - for(j=0; j<4; j++){ - for(i=0; i<=vf->priv->depth; i++) - vf->priv->plane[i][j]= malloc(vf->priv->stride*h*sizeof(vf->priv->plane[0][0][0])); - } - - return ff_vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); -} - -static void get_image(struct vf_instance *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=ff_vf_get_image(vf->next,mpi->imgfmt, - mpi->type, mpi->flags | MP_IMGFLAG_READABLE, mpi->width, mpi->height); - 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 *vf, mp_image_t *mpi, double pts){ - mp_image_t *dmpi; - - if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ - // no DR, so get a new image! hope we'll get DR buffer: - dmpi=ff_vf_get_image(vf->next,mpi->imgfmt, - MP_IMGTYPE_TEMP, - MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, - mpi->width,mpi->height); - ff_vf_clone_mpi_attributes(dmpi, mpi); - }else{ - dmpi=vf->dmpi; - } - - filter(vf->priv, dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, 1); - filter(vf->priv, dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, 0); - filter(vf->priv, dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, 0); - - return ff_vf_next_put_image(vf,dmpi, pts); -} - -static void uninit(struct vf_instance *vf){ - int i,j; - if(!vf->priv) return; - - for(j=0; j<4; j++){ - for(i=0; i<16; i++){ - free(vf->priv->plane[i][j]); - vf->priv->plane[i][j]= NULL; - } - } - - free(vf->priv); - vf->priv=NULL; -} - -//===========================================================================// -static int query_format(struct vf_instance *vf, unsigned int fmt){ - switch(fmt){ - case IMGFMT_YVU9: - case IMGFMT_IF09: - case IMGFMT_YV12: - case IMGFMT_I420: - case IMGFMT_IYUV: - case IMGFMT_CLPL: - case IMGFMT_Y800: - case IMGFMT_Y8: - case IMGFMT_444P: - case IMGFMT_422P: - case IMGFMT_411P: - return ff_vf_next_query_format(vf,fmt); - } - return 0; -} - - -static int vf_open(vf_instance_t *vf, char *args){ - vf->config=config; - vf->put_image=put_image; - vf->get_image=get_image; - vf->query_format=query_format; - vf->uninit=uninit; - vf->priv=malloc(sizeof(struct vf_priv_s)); - memset(vf->priv, 0, sizeof(struct vf_priv_s)); - - vf->priv->depth= 8; - vf->priv->strength[0]= 1.0; - vf->priv->strength[1]= 1.0; - vf->priv->delta= 1.0; - - if (args) sscanf(args, "%d:%f:%f:%d:%f", &vf->priv->depth, - &vf->priv->strength[0], - &vf->priv->strength[1], - &vf->priv->mode, - &vf->priv->delta); - - return 1; -} - -const vf_info_t ff_vf_info_ow = { - "overcomplete wavelet denoiser", - "ow", - "Michael Niedermayer", - "", - vf_open, - NULL -}; -- cgit v1.2.3