Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2013-07-02 15:50:02 +0400
committerMichael Niedermayer <michaelni@gmx.at>2013-07-04 01:10:57 +0400
commitf0bcb13aedcff8b4a454347c634ac41aefab9e86 (patch)
treea4c733a6b3c27fd314ca359688e908ff2b9ce6de /libavfilter/vf_delogo.c
parent99f1d7493349640a1489b6b42dec20a9b1326f9b (diff)
lavfi/delogo: avoid propagation of rounding errors in chroma planes
When operating on subsampled chroma planes, some rounding is taking place. The left and top borders are rounded down while the width and height are rounded up, so all rounding is done outward to guarantee the logo area is fully covered. The problem is that the width and height are counted from the unrounded left and top borders, respectively. So if the left or top border position has indeed been rounded down, and the width or height needs no rounding (up), the position of the the right or bottom border will be effectively rounded down, i.e. inward. The issue can easily be seen with a yuv240p input and -vf delogo=45:45:60:40:show=1 -vframes 1 delogo-bug.png (or virtually any logo area with odd x and y and even width and height.) The right and bottom chroma borders (in green) are clearly off. In order to fix this, the width and height must be adjusted to include the bits lost in the rounding of the left and top border positions, respectively, prior to being themselves rounded up. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_delogo.c')
-rw-r--r--libavfilter/vf_delogo.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index ba35cf5c8d..e882dd523a 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -246,8 +246,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
FF_CEIL_RSHIFT(inlink->w, hsub),
FF_CEIL_RSHIFT(inlink->h, vsub),
sar, s->x>>hsub, s->y>>vsub,
- FF_CEIL_RSHIFT(s->w, hsub),
- FF_CEIL_RSHIFT(s->h, vsub),
+ /* Up and left borders were rounded down, inject lost bits
+ * into width and height to avoid error accumulation */
+ FF_CEIL_RSHIFT(s->w + (s->x & ((1<<hsub)-1)), hsub),
+ FF_CEIL_RSHIFT(s->h + (s->y & ((1<<vsub)-1)), vsub),
s->band>>FFMIN(hsub, vsub),
s->show, direct);
}