diff options
author | Jean Delvare <jdelvare@suse.de> | 2015-12-09 12:07:47 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-12-09 12:23:00 +0100 |
commit | e74f1a121e94587d0df8a7f5a12f2d48a974695c (patch) | |
tree | 48a3a865c69137e7a47f8f1af55b788e56e8fae6 /libavfilter | |
parent | c8905e0d67f54b3228ea0aec57b7087925c0508b (diff) | |
download | ffmpeg-e74f1a121e94587d0df8a7f5a12f2d48a974695c.tar.gz |
avfilter/vf_delogo: round to the closest value
When the interpolated value is divided by the sum of weights, no
rounding is done, which means the value is truncated. This results in
a slight bias towards dark green in the interpolated area. Rounding
properly removes the bias.
I measured this change to reduce the interpolation error by 1 to 2 %
on average on a number of sample input and logo area combinations.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_delogo.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index c7fb6e3f38..1b8e408210 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -61,7 +61,7 @@ static void apply_delogo(uint8_t *dst, int dst_linesize, unsigned int band, int show, int direct) { int x, y; - uint64_t interp, weightl, weightr, weightt, weightb; + uint64_t interp, weightl, weightr, weightt, weightb, weight; uint8_t *xdst, *xsrc; uint8_t *topleft, *botleft, *topright; @@ -125,7 +125,8 @@ static void apply_delogo(uint8_t *dst, int dst_linesize, (botleft[x-logo_x1] + botleft[x-logo_x1-1] + botleft[x-logo_x1+1]) * weightb; - interp /= (weightl + weightr + weightt + weightb) * 3U; + weight = (weightl + weightr + weightt + weightb) * 3U; + interp = ROUNDED_DIV(interp, weight); if (y >= logo_y+band && y < logo_y+logo_h-band && x >= logo_x+band && x < logo_x+logo_w-band) { |