[FFmpeg-cvslog] lavfi/delogo: remember left and right samples when interpolating

Jean Delvare git at videolan.org
Fri Jul 5 14:02:20 CEST 2013


ffmpeg | branch: master | Jean Delvare <khali at linux-fr.org> | Fri Jul  5 10:32:57 2013 +0200| [4e8d6b315c8d046498642c0d155488be326133a3] | committer: Michael Niedermayer

lavfi/delogo: remember left and right samples when interpolating

The left and right samples are the same for the whole line, so store
their values and don't recompute them for every iteration of "y".

This simple optimization results in a speed improvement between 15%
and 20% in my tests (depending on the logo geometry.)

Result is obviously the same.

Signed-off-by: Jean Delvare <khali at linux-fr.org>
Reviewed-by: Stefano Sabatini <stefasab at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavfilter/vf_delogo.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 3a9bdd4..462613d 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -65,6 +65,7 @@ static void apply_delogo(uint8_t *dst, int dst_linesize,
     uint8_t *xdst, *xsrc;
 
     uint8_t *topleft, *botleft, *topright;
+    unsigned int left_sample, right_sample;
     int xclipl, xclipr, yclipt, yclipb;
     int logo_x1, logo_x2, logo_y1, logo_y2;
 
@@ -89,6 +90,13 @@ static void apply_delogo(uint8_t *dst, int dst_linesize,
     src += (logo_y1 + 1) * src_linesize;
 
     for (y = logo_y1+1; y < logo_y2-1; y++) {
+        left_sample = topleft[src_linesize*(y-logo_y1)]   +
+                      topleft[src_linesize*(y-logo_y1-1)] +
+                      topleft[src_linesize*(y-logo_y1+1)];
+        right_sample = topright[src_linesize*(y-logo_y1)]   +
+                       topright[src_linesize*(y-logo_y1-1)] +
+                       topright[src_linesize*(y-logo_y1+1)];
+
         for (x = logo_x1+1,
              xdst = dst+logo_x1+1,
              xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) {
@@ -100,13 +108,9 @@ static void apply_delogo(uint8_t *dst, int dst_linesize,
             weightb = (uint64_t)(x-logo_x1) * (logo_x2-1-x) * (y-logo_y1)                 * sar.num;
 
             interp =
-                (topleft[src_linesize*(y-logo_y1)]    +
-                 topleft[src_linesize*(y-logo_y1-1)]  +
-                 topleft[src_linesize*(y-logo_y1+1)]) * weightl
+                left_sample * weightl
                 +
-                (topright[src_linesize*(y-logo_y1)]    +
-                 topright[src_linesize*(y-logo_y1-1)]  +
-                 topright[src_linesize*(y-logo_y1+1)]) * weightr
+                right_sample * weightr
                 +
                 (topleft[x-logo_x1]    +
                  topleft[x-logo_x1-1]  +



More information about the ffmpeg-cvslog mailing list