comparison resample2.c @ 2403:6d53608cf2cf libavcodec

special case for filter_length==1
author michael
date Fri, 31 Dec 2004 12:58:46 +0000
parents 424e6b29de74
children 21c5ef8a4ff7
comparison
equal deleted inserted replaced
2402:f9d4e1eddbc5 2403:6d53608cf2cf
139 139
140 c->phase_shift= phase_shift; 140 c->phase_shift= phase_shift;
141 c->phase_mask= phase_count-1; 141 c->phase_mask= phase_count-1;
142 c->linear= linear; 142 c->linear= linear;
143 143
144 c->filter_length= ceil(filter_size/factor); 144 c->filter_length= FFMAX(ceil(filter_size/factor), 1);
145 c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM)); 145 c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM));
146 av_build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, 1); 146 av_build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, 1);
147 memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM)); 147 memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM));
148 c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1]; 148 c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1];
149 149
192 int frac= c->frac; 192 int frac= c->frac;
193 int dst_incr_frac= c->dst_incr % c->src_incr; 193 int dst_incr_frac= c->dst_incr % c->src_incr;
194 int dst_incr= c->dst_incr / c->src_incr; 194 int dst_incr= c->dst_incr / c->src_incr;
195 int compensation_distance= c->compensation_distance; 195 int compensation_distance= c->compensation_distance;
196 196
197 if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){
198 assert(index >= 0);
199 for(dst_index=0; dst_index < dst_size; dst_index++){
200 if(index < src_size)
201 dst[dst_index] = src[index];
202 else
203 break;
204
205 frac += dst_incr_frac;
206 index += dst_incr;
207 if(frac >= c->src_incr){
208 frac -= c->src_incr;
209 index++;
210 }
211 }
212 }else{
197 for(dst_index=0; dst_index < dst_size; dst_index++){ 213 for(dst_index=0; dst_index < dst_size; dst_index++){
198 FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); 214 FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);
199 int sample_index= index >> c->phase_shift; 215 int sample_index= index >> c->phase_shift;
200 FELEM2 val=0; 216 FELEM2 val=0;
201 217
232 compensation_distance= 0; 248 compensation_distance= 0;
233 dst_incr_frac= c->ideal_dst_incr % c->src_incr; 249 dst_incr_frac= c->ideal_dst_incr % c->src_incr;
234 dst_incr= c->ideal_dst_incr / c->src_incr; 250 dst_incr= c->ideal_dst_incr / c->src_incr;
235 } 251 }
236 } 252 }
253 }
237 *consumed= FFMAX(index, 0) >> c->phase_shift; 254 *consumed= FFMAX(index, 0) >> c->phase_shift;
238 if(index>=0) index &= c->phase_mask; 255 if(index>=0) index &= c->phase_mask;
239 256
240 if(compensation_distance){ 257 if(compensation_distance){
241 compensation_distance -= dst_index; 258 compensation_distance -= dst_index;