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 <jdelvare@suse.de>2015-12-09 14:07:47 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2015-12-09 14:23:00 +0300
commite74f1a121e94587d0df8a7f5a12f2d48a974695c (patch)
tree48a3a865c69137e7a47f8f1af55b788e56e8fae6 /libavfilter/vf_delogo.c
parentc8905e0d67f54b3228ea0aec57b7087925c0508b (diff)
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/vf_delogo.c')
-rw-r--r--libavfilter/vf_delogo.c5
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) {