aboutsummaryrefslogtreecommitdiffstats
path: root/libswresample/resample_template.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-06-18 23:02:44 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-06-19 03:09:24 +0200
commit80e857c967ff063def0ffc2499d1c78b8d6d130b (patch)
treedce2b0d760775259b45634fefb8a3815340e2bb0 /libswresample/resample_template.c
parentc90e8054af849759d3c06b31dba3fa592fcdc3e6 (diff)
downloadffmpeg-80e857c967ff063def0ffc2499d1c78b8d6d130b.tar.gz
swr/resample: optimize C code for the most common case
15% speedup Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample/resample_template.c')
-rw-r--r--libswresample/resample_template.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c
index 0523add3aa..4060c66a43 100644
--- a/libswresample/resample_template.c
+++ b/libswresample/resample_template.c
@@ -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);