The code assumed that the outermost interpolated pixels were always in
the fuzzy area defined by the band option. However if the band value
is small, there may be no fuzzy area on a given plane. In that case,
option show did not work, no rectangle was drawn (or only on the luma
plane, depending on the band value and chroma plane subsampling
factors.)

Fix the problem by not making any assumption on where the outermost
interpolated pixels will be.

The new code was verified to produce the same result as the original
code when the band value is not small.

Signed-off-by: Jean Delvare <[email protected]>
---
 libavfilter/vf_delogo.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--- ffmpeg.orig/libavfilter/vf_delogo.c 2015-09-28 08:31:19.151967866 +0200
+++ ffmpeg/libavfilter/vf_delogo.c      2015-09-28 10:03:32.733287345 +0200
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2002 Jindrich Makovicka <[email protected]>
  * Copyright (c) 2011 Stefano Sabatini
- * Copyright (c) 2013 Jean Delvare <[email protected]>
+ * Copyright (c) 2013, 2015 Jean Delvare <[email protected]>
  *
  * This file is part of FFmpeg.
  *
@@ -101,6 +101,12 @@ static void apply_delogo(uint8_t *dst, i
              xdst = dst+logo_x1+1,
              xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) {
 
+            if (show && (y == logo_y+1 || y == logo_y+logo_h-2 ||
+                         x == logo_x+1 || x == logo_x+logo_w-2)) {
+                *xdst = 0;
+                continue;
+            }
+
             /* Weighted interpolation based on relative distances, taking SAR 
into account */
             weightl = (uint64_t)              (logo_x2-1-x) * (y-logo_y1) * 
(logo_y2-1-y) * sar.den;
             weightr = (uint64_t)(x-logo_x1)                 * (y-logo_y1) * 
(logo_y2-1-y) * sar.den;
@@ -138,8 +144,6 @@ static void apply_delogo(uint8_t *dst, i
                     dist = FFMAX(dist, y-(logo_y+logo_h-1-band));
 
                 *xdst = (*xsrc*dist + interp*(band-dist))/band;
-                if (show && (dist == band-1))
-                    *xdst = 0;
             }
         }
 

-- 
Jean Delvare
SUSE L3 Support
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to