Mercurial > libavcodec.hg
comparison resample2.c @ 4695:8155dd60b50b libavcodec
code for testing the accuracy of the resampler
author | michael |
---|---|
date | Wed, 21 Mar 2007 22:37:05 +0000 |
parents | f5fa13dfd3c8 |
children | cb715346074a |
comparison
equal
deleted
inserted
replaced
4694:f5fa13dfd3c8 | 4695:8155dd60b50b |
---|---|
122 for(i=0;i<tap_count;i++) { | 122 for(i=0;i<tap_count;i++) { |
123 v = av_clip(lrintf(tab[i] * scale / norm), FELEM_MIN, FELEM_MAX); | 123 v = av_clip(lrintf(tab[i] * scale / norm), FELEM_MIN, FELEM_MAX); |
124 filter[ph * tap_count + i] = v; | 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 /** |
130 * initalizes a audio resampler. | 166 * initalizes a audio resampler. |
131 * note, if either rate is not a integer then simply scale both rates up so they are | 167 * note, if either rate is not a integer then simply scale both rates up so they are |