[SCM] libav/experimental: cubic filter instead of truncated sinc looks much better for upscaling & scaling where src and dst size are quite similar

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 15:40:36 UTC 2013


The following commit has been merged in the experimental branch:
commit fdce4f3132f52f5ea550637694f70e037e8a8c3d
Author: Michael Niedermayer <michaelni at gmx.at>
Date:   Sun Jun 6 13:46:50 2004 +0000

    cubic filter instead of truncated sinc
    looks much better for upscaling & scaling where src and dst size are quite similar
    
    Originally committed as revision 3201 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/imgresample.c b/libavcodec/imgresample.c
index 14fdb10..dc5ccf9 100644
--- a/libavcodec/imgresample.c
+++ b/libavcodec/imgresample.c
@@ -554,12 +554,18 @@ static void build_filter(int16_t *filter, float factor)
     for(ph=0;ph<NB_PHASES;ph++) {
         norm = 0;
         for(i=0;i<NB_TAPS;i++) {
-            
+#if 1
+            const float d= -0.5; //first order derivative = -0.5
+            x = fabs(((float)(i - FCENTER) - (float)ph / NB_PHASES) * factor);
+            if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*(            -x*x + x*x*x);
+            else      y=                       d*(-4 + 8*x - 5*x*x + x*x*x);
+#else
             x = M_PI * ((float)(i - FCENTER) - (float)ph / NB_PHASES) * factor;
             if (x == 0)
                 y = 1.0;
             else
                 y = sin(x) / x;
+#endif
             tab[i] = y;
             norm += y;
         }

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list