Browse code

avfilter/delogo: Fix show option when band is small

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 <jdelvare@suse.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Jean Delvare authored on 2015/09/28 17:18:06
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * Copyright (c) 2002 Jindrich Makovicka <makovick@gmail.com>
3 3
  * Copyright (c) 2011 Stefano Sabatini
4
- * Copyright (c) 2013 Jean Delvare <jdelvare@suse.com>
4
+ * Copyright (c) 2013, 2015 Jean Delvare <jdelvare@suse.com>
5 5
  *
6 6
  * This file is part of FFmpeg.
7 7
  *
... ...
@@ -101,6 +101,12 @@ static void apply_delogo(uint8_t *dst, int dst_linesize,
101 101
              xdst = dst+logo_x1+1,
102 102
              xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) {
103 103
 
104
+            if (show && (y == logo_y+1 || y == logo_y+logo_h-2 ||
105
+                         x == logo_x+1 || x == logo_x+logo_w-2)) {
106
+                *xdst = 0;
107
+                continue;
108
+            }
109
+
104 110
             /* Weighted interpolation based on relative distances, taking SAR into account */
105 111
             weightl = (uint64_t)              (logo_x2-1-x) * (y-logo_y1) * (logo_y2-1-y) * sar.den;
106 112
             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, int dst_linesize,
138 138
                     dist = FFMAX(dist, y-(logo_y+logo_h-1-band));
139 139
 
140 140
                 *xdst = (*xsrc*dist + interp*(band-dist))/band;
141
-                if (show && (dist == band-1))
142
-                    *xdst = 0;
143 141
             }
144 142
         }
145 143