changeset 2405:21c5ef8a4ff7 libavcodec

faster and slightly less accurate nearest neighbor resampler
author michael
date Fri, 31 Dec 2004 17:37:23 +0000
parents 2e90350ff8bc
children 25a24139f296
files resample2.c
diffstat 1 files changed, 11 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/resample2.c	Fri Dec 31 14:02:35 2004 +0000
+++ b/resample2.c	Fri Dec 31 17:37:23 2004 +0000
@@ -193,22 +193,20 @@
     int dst_incr_frac= c->dst_incr % c->src_incr;
     int dst_incr=      c->dst_incr / c->src_incr;
     int compensation_distance= c->compensation_distance;
-    
+
   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++){
-            if(index < src_size)
-                dst[dst_index] = src[index];
-            else
-                break;
-
-            frac += dst_incr_frac;
-            index += dst_incr;
-            if(frac >= c->src_incr){
-                frac -= c->src_incr;
-                index++;
-            }
+            dst[dst_index] = src[index2>>32];
+            index2 += incr;
         }
+        frac += dst_index * dst_incr_frac;
+        index += dst_index * dst_incr;
+        index += frac / c->src_incr;
+        frac %= c->src_incr;
   }else{
     for(dst_index=0; dst_index < dst_size; dst_index++){
         FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);