# HG changeset patch # User arpi # Date 1044795119 0 # Node ID 6fc781450b2215585d17d5d4c5d5270b531f0951 # Parent 33f43b0f24f76f6d677161039e62cdd0ece1fa8c cleanup & more optimize diff -r 33f43b0f24f7 -r 6fc781450b22 libmpcodecs/vf_denoise3d.c --- a/libmpcodecs/vf_denoise3d.c Sun Feb 09 12:26:11 2003 +0000 +++ b/libmpcodecs/vf_denoise3d.c Sun Feb 09 12:51:59 2003 +0000 @@ -68,20 +68,7 @@ free(vf->priv->Line); } -//#define LowPass(Prev, Curr, Coef) (((Prev)*Coef[Prev - Curr] + (Curr)*(65536-(Coef[Prev - Curr]))) / 65536) -//#define LowPass(Prev, Curr, Coef) (( Prev*Coef[Prev-Curr] + Curr*(65536-(Coef[Prev-Curr])) )/65536) -//#define LowPass(Prev, Curr, Coef) (( Prev*Coef[Prev-Curr] + Curr*65536 - Curr*Coef[Prev-Curr] )/65536) -//#define LowPass(Prev, Curr, Coef) (((int)(Curr)) + (( (int)Prev*Coef[Prev-Curr] - (int)Curr*Coef[Prev-Curr] )>>16) ) -//#define LowPass(Prev, Curr, Coef) (Curr + (( Prev*Coef[Prev-Curr] - Curr*Coef[Prev-Curr] )>>16) ) -//#define LowPass(Prev, Curr, Coef) (Curr + (( (Prev-Curr)*(Coef[Prev-Curr]) )>>16) ) - -//#define LowPass(Prev, Curr, Coef) (Curr + (((Prev - Curr)*Coef[Prev - Curr]) / 65536)) -#define LowPass(Prev, Curr, Coef) (Curr + ((((unsigned int)(Prev - Curr))*Coef[Prev - Curr]) / 65536)) -//#define LowPass(Prev, Curr, Coef) (Curr + ((((unsigned int)(Prev - Curr))*Coef[((unsigned int)(Prev - Curr))]) / 65536)) -//#define LowPass(Prev, Curr, Coef) (Curr + ((((unsigned char)(Prev - Curr))*Coef[Prev - Curr]) / 65536)) -//#define LowPass(Prev, Curr, Coef) (Curr + (( ((((int)(Prev))-((int)(Curr)))) *Coef[Prev - Curr]) / 65536)) -//#define LowPass(Prev, Curr, Coef) (Curr + (((unsigned int)((Prev - Curr)*Coef[Prev - Curr])) / 65536)) -//#define LowPass(Prev, Curr, Coef) (Curr + (((Prev - Curr)*Coef[Prev - Curr]) >> 16)) +#define LowPass(Prev, Curr, Coef) (Curr + Coef[Prev - Curr]) static void deNoise(unsigned char *Frame, // mpi->planes[x] unsigned char *FramePrev, // pmpi->planes[x] @@ -185,14 +172,16 @@ static void PrecalcCoefs(int *Ct, double Dist25) { int i; - double Gamma, Simil; + double Gamma, Simil, C; Gamma = log(0.25) / log(1.0 - Dist25/255.0); for (i = -256; i <= 255; i++) { Simil = 1.0 - ABS(i) / 255.0; - Ct[256+i] = pow(Simil, Gamma) * 65536; +// Ct[256+i] = lround(pow(Simil, Gamma) * (double)i); + C = pow(Simil, Gamma) * (double)i; + Ct[256+i] = (C<0) ? (C-0.5) : (C+0.5); } }