comparison resample2.c @ 2083:76cdbe832239 libavcodec

avoid useless normalization and 10l fix
author michael
date Thu, 17 Jun 2004 16:34:46 +0000
parents 3dc9bbe1b152
children 84637c6ca74e
comparison
equal deleted inserted replaced
2082:3dc9bbe1b152 2083:76cdbe832239
91 w = 2.0*x / (factor*tap_count) + M_PI; 91 w = 2.0*x / (factor*tap_count) + M_PI;
92 y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w); 92 y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w);
93 break; 93 break;
94 case 2: 94 case 2:
95 w = 2.0*x / (factor*tap_count*M_PI); 95 w = 2.0*x / (factor*tap_count*M_PI);
96 y *= bessel(16*sqrt(FFMAX(1-w*w, 0))) / bessel(16); 96 y *= bessel(16*sqrt(FFMAX(1-w*w, 0)));
97 break; 97 break;
98 } 98 }
99 99
100 tab[i] = y; 100 tab[i] = y;
101 norm += y; 101 norm += y;
137 av_freep(&c->filter_bank); 137 av_freep(&c->filter_bank);
138 av_freep(&c); 138 av_freep(&c);
139 } 139 }
140 140
141 void av_resample_compensate(AVResampleContext *c, int sample_delta, int compensation_distance){ 141 void av_resample_compensate(AVResampleContext *c, int sample_delta, int compensation_distance){
142 assert(!c->compensation_distance); //FIXME 142 // sample_delta += (c->ideal_dst_incr - c->dst_incr)*(int64_t)c->compensation_distance / c->ideal_dst_incr;
143
144 c->compensation_distance= compensation_distance; 143 c->compensation_distance= compensation_distance;
145 c->dst_incr-= c->ideal_dst_incr * sample_delta / compensation_distance; 144 c->dst_incr = c->ideal_dst_incr - c->ideal_dst_incr * (int64_t)sample_delta / compensation_distance;
146 } 145 }
147 146
148 /** 147 /**
149 * resamples. 148 * resamples.
150 * @param src an array of unconsumed samples 149 * @param src an array of unconsumed samples
200 index++; 199 index++;
201 } 200 }
202 } 201 }
203 if(update_ctx){ 202 if(update_ctx){
204 if(c->compensation_distance){ 203 if(c->compensation_distance){
205 c->compensation_distance -= index; 204 c->compensation_distance -= dst_index;
206 if(!c->compensation_distance) 205 if(!c->compensation_distance)
207 c->dst_incr= c->ideal_dst_incr; 206 c->dst_incr= c->ideal_dst_incr;
208 } 207 }
209 c->frac= frac; 208 c->frac= frac;
210 c->index=0; 209 c->index=0;
211 } 210 }
212 *consumed= index >> PHASE_SHIFT; 211 *consumed= index >> PHASE_SHIFT;
212 #if 0
213 if(update_ctx && !c->compensation_distance){
214 #undef rand
215 av_resample_compensate(c, rand() % (8000*2) - 8000, 8000*2);
216 av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", c->dst_incr, c->ideal_dst_incr, c->compensation_distance);
217 }
218 #endif
219
213 return dst_index; 220 return dst_index;
214 } 221 }