Commit fa28853d authored by michael's avatar michael

faster and slightly less accurate nearest neighbor resampler


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@3789 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent c9e65ee5
...@@ -193,22 +193,20 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int ...@@ -193,22 +193,20 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
int dst_incr_frac= c->dst_incr % c->src_incr; int dst_incr_frac= c->dst_incr % c->src_incr;
int dst_incr= c->dst_incr / c->src_incr; int dst_incr= c->dst_incr / c->src_incr;
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;
int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr);
for(dst_index=0; dst_index < dst_size; dst_index++){ for(dst_index=0; dst_index < dst_size; dst_index++){
if(index < src_size) dst[dst_index] = src[index2>>32];
dst[dst_index] = src[index]; index2 += incr;
else
break;
frac += dst_incr_frac;
index += dst_incr;
if(frac >= c->src_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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment