avfilter/vf_boxblur: factor rounder offset out
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 20 Dec 2014 23:54:36 +0000 (00:54 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 20 Dec 2014 23:58:56 +0000 (00:58 +0100)
3322 -> 3204 cycles

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavfilter/vf_boxblur.c

index 1fa5135..a908b6d 100644 (file)
@@ -227,19 +227,21 @@ static inline void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_
         sum += src[x*src_step]<<1;
     sum += src[radius*src_step];
 
+    sum = sum*inv + (1<<15);
+
     for (x = 0; x <= radius; x++) {
-        sum += src[(radius+x)*src_step] - src[(radius-x)*src_step];
-        dst[x*dst_step] = (sum*inv + (1<<15))>>16;
+        sum += (src[(radius+x)*src_step] - src[(radius-x)*src_step])*inv;
+        dst[x*dst_step] = sum>>16;
     }
 
     for (; x < len-radius; x++) {
-        sum += src[(radius+x)*src_step] - src[(x-radius-1)*src_step];
-        dst[x*dst_step] = (sum*inv + (1<<15))>>16;
+        sum += (src[(radius+x)*src_step] - src[(x-radius-1)*src_step])*inv;
+        dst[x*dst_step] = sum >>16;
     }
 
     for (; x < len; x++) {
-        sum += src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step];
-        dst[x*dst_step] = (sum*inv + (1<<15))>>16;
+        sum += (src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step])*inv;
+        dst[x*dst_step] = sum>>16;
     }
 }