faster and slightly less accurate nearest neighbor resampler

Originally committed as revision 3789 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2004-12-31 17:37:23 +00:00
parent 17bfbd70ab
commit 53f0090dcc
1 changed files with 12 additions and 14 deletions

View File

@ -195,20 +195,18 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
int compensation_distance= c->compensation_distance; int compensation_distance= c->compensation_distance;
if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){ if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){
assert(index >= 0); int64_t index2= ((int64_t)index)<<32;
for(dst_index=0; dst_index < dst_size; dst_index++){ int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
if(index < src_size) dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr);
dst[dst_index] = src[index];
else
break;
frac += dst_incr_frac; for(dst_index=0; dst_index < dst_size; dst_index++){
index += dst_incr; dst[dst_index] = src[index2>>32];
if(frac >= c->src_incr){ index2 += incr;
frac -= c->src_incr;
index++;
}
} }
frac += dst_index * dst_incr_frac;
index += dst_index * dst_incr;
index += frac / c->src_incr;
frac %= c->src_incr;
}else{ }else{
for(dst_index=0; dst_index < dst_size; dst_index++){ for(dst_index=0; dst_index < dst_size; dst_index++){
FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);