[FFmpeg-cvslog] avfilter/vf_boxblur: factor rounder offset out

Michael Niedermayer git at videolan.org
Sun Dec 21 01:13:51 CET 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Dec 21 00:54:36 2014 +0100| [7cdce8cb55e7af25b88b45b6338402baad1e9ec9] | committer: Michael Niedermayer

avfilter/vf_boxblur: factor rounder offset out

3322 -> 3204 cycles

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7cdce8cb55e7af25b88b45b6338402baad1e9ec9
---

 libavfilter/vf_boxblur.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c
index 1fa5135..a908b6d 100644
--- a/libavfilter/vf_boxblur.c
+++ b/libavfilter/vf_boxblur.c
@@ -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;
     }
 }
 



More information about the ffmpeg-cvslog mailing list