Commit 80e857c9 authored by Michael Niedermayer's avatar Michael Niedermayer

swr/resample: optimize C code for the most common case

15% speedup
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent c90e8054
......@@ -48,6 +48,28 @@ int RENAME(swri_resample)(ResampleContext *c, DELEM *dst, const DELEM *src, int
index += dst_index * dst_incr;
index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr;
frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr;
}else if(compensation_distance == 0 && !c->linear && index >= 0){
for(dst_index=0; dst_index < dst_size; dst_index++){
FELEM *filter= ((FELEM*)c->filter_bank) + c->filter_length*(index & c->phase_mask);
int sample_index= index >> c->phase_shift;
if(sample_index + c->filter_length > src_size){
break;
}else{
FELEM2 val=0;
for(i=0; i<c->filter_length; i++){
val += src[sample_index + i] * (FELEM2)filter[i];
}
OUT(dst[dst_index], val);
}
frac += dst_incr_frac;
index += dst_incr;
if(frac >= c->src_incr){
frac -= c->src_incr;
index++;
}
}
}else{
for(dst_index=0; dst_index < dst_size; dst_index++){
FELEM *filter= ((FELEM*)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