changeset 4707:441cded6920c libavcodec

optimize linear filter coeff interpolation code, this also makes the code less prone to overflows
author michael
date Thu, 22 Mar 2007 11:10:30 +0000
parents 1d8b06947276
children 0ebf322d148e
files resample2.c
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/resample2.c	Thu Mar 22 05:39:20 2007 +0000
+++ b/resample2.c	Thu Mar 22 11:10:30 2007 +0000
@@ -268,13 +268,12 @@
         }else if(sample_index + c->filter_length > src_size){
             break;
         }else if(c->linear){
-            int64_t v=0;
-            int sub_phase= (frac<<8) / c->src_incr;
+            FELEM2 v2=0;
             for(i=0; i<c->filter_length; i++){
-                FELEML coeff= filter[i]*(256 - sub_phase) + filter[i + c->filter_length]*sub_phase;
-                v += src[sample_index + i] * coeff;
+                val += src[sample_index + i] * (FELEM2)filter[i];
+                v2  += src[sample_index + i] * (FELEM2)filter[i + c->filter_length];
             }
-            val= v>>8;
+            val+=(v2-val)*(FELEML)frac / c->src_incr;
         }else{
             for(i=0; i<c->filter_length; i++){
                 val += src[sample_index + i] * (FELEM2)filter[i];