diff svq1.c @ 4750:14a0a003804b libavcodec

move some stuff out of an inner loop. 12% faster svq1 encoding.
author lorenm
date Fri, 30 Mar 2007 19:16:41 +0000
parents 7011f597e473
children f99e40a7155b
line wrap: on
line diff
--- a/svq1.c	Fri Mar 30 19:15:31 2007 +0000
+++ b/svq1.c	Fri Mar 30 19:16:41 2007 +0000
@@ -992,17 +992,16 @@
 
             for(i=0; i<16; i++){
                 int sum= codebook_sum[stage*16 + i];
-                int sqr, diff, mean, score;
+                int sqr, diff, score;
 
                 vector = codebook + stage*size*16 + i*size;
                 sqr = s->dsp.ssd_int8_vs_int16(vector, block[stage], size);
                 diff= block_sum[stage] - sum;
-                mean= (diff + (size>>1)) >> (level+3);
-                assert(mean >-300 && mean<300);
-                if(intra) mean= av_clip(mean, 0, 255);
-                else      mean= av_clip(mean, -256, 255);
                 score= sqr - ((diff*(int64_t)diff)>>(level+3)); //FIXME 64bit slooow
                 if(score < best_vector_score){
+                    int mean= (diff + (size>>1)) >> (level+3);
+                    assert(mean >-300 && mean<300);
+                    mean= av_clip(mean, intra?0:-256, 255);
                     best_vector_score= score;
                     best_vector[stage]= i;
                     best_vector_sum= sum;