Browse code

code for testing the accuracy of the resampler

Originally committed as revision 8468 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2007/03/22 07:37:05
Showing 1 changed files
... ...
@@ -124,6 +124,42 @@ void av_build_filter(FELEM *filter, double factor, int tap_count, int phase_coun
124 124
             filter[ph * tap_count + i] = v;
125 125
         }
126 126
     }
127
+#if 0
128
+    {
129
+#define LEN 1024
130
+        int j,k;
131
+        double sine[LEN + tap_count];
132
+        double filtered[LEN];
133
+        double maxff=-2, minff=2, maxsf=-2, minsf=2;
134
+        for(i=0; i<LEN; i++){
135
+            double ss=0, sf=0, ff=0;
136
+            for(j=0; j<LEN+tap_count; j++)
137
+                sine[j]= cos(i*j*M_PI/LEN);
138
+            for(j=0; j<LEN; j++){
139
+                double sum=0;
140
+                ph=0;
141
+                for(k=0; k<tap_count; k++)
142
+                    sum += filter[ph * tap_count + k] * sine[k+j];
143
+                filtered[j]= sum / (1<<FILTER_SHIFT);
144
+                ss+= sine[j + center] * sine[j + center];
145
+                ff+= filtered[j] * filtered[j];
146
+                sf+= sine[j + center] * filtered[j];
147
+            }
148
+            ss= sqrt(2*ss/LEN);
149
+            ff= sqrt(2*ff/LEN);
150
+            sf= 2*sf/LEN;
151
+            maxff= FFMAX(maxff, ff);
152
+            minff= FFMIN(minff, ff);
153
+            maxsf= FFMAX(maxsf, sf);
154
+            minsf= FFMIN(minsf, sf);
155
+            if(i%11==0){
156
+                av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%f-%f sf:%f-%f\n", i, ss, maxff, minff, maxsf, minsf);
157
+                minff=minsf= 2;
158
+                maxff=maxsf= -2;
159
+            }
160
+        }
161
+    }
162
+#endif
127 163
 }
128 164
 
129 165
 /**