[FFmpeg-cvslog] lavfi/delogo: use weighted interpolation

Michael Niedermayer michaelni at gmx.at
Tue Jul 9 11:55:54 CEST 2013


On Mon, Jul 01, 2013 at 09:37:51AM +0200, Jean Delvare wrote:
> ffmpeg | branch: master | Jean Delvare <khali at linux-fr.org> | Wed Jun 26 14:50:37 2013 +0200| [16fd75ceec1d3915b565469d796ac4a273813bfe] | committer: Stefano Sabatini
> 
> lavfi/delogo: use weighted interpolation
> 
> The original delogo algorithm interpolates both horizontally and
> vertically and uses the average to compute the resulting sample. This
> works reasonably well when the logo area is almost square. However
> when the logo area is significantly larger than high or higher than
> large, the result is largely suboptimal.
> 
> The issue can be clearly seen by testing the delogo filter with a fake
> logo area that is 200 pixels large and 2 pixels high. Vertical
> interpolation gives a very good result in that case, horizontal
> interpolation gives a very bad result, and the overall result is poor,
> because both are given the same weight.
> 
> Even when the logo is roughly square, the current algorithm gives poor
> results on the borders of the logo area, because it always gives
> horizontal and vertical interpolations an equal weight, and this is
> suboptimal on borders. For example, in the middle of the left hand
> side border of the logo, you want to trust the left known point much
> more than the right known point (which the current algorithm already
> does) but also much more than the top and bottom known points (which
> the current algorithm doesn't do.)
> 
> By properly weighting each known point when computing the value of
> each interpolated pixel, the visual result is much better, especially
> on borders and/or for high or large logo areas.
> 
> The algorithm I implemented guarantees that the weight of each of the
> 4 known points directly depends on its distance to the interpolated
> point. It is largely inspired from the original algorithm, the key
> difference being that it computes the relative weights globally
> instead of separating the vertical and horizontal interpolations and
> combining them afterward.
> 
> Signed-off-by: Jean Delvare <khali at linux-fr.org>
> Signed-off-by: Stefano Sabatini <stefasab at gmail.com>
> 
> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=16fd75ceec1d3915b565469d796ac4a273813bfe
> ---
> 
>  libavfilter/vf_delogo.c      |   25 +++--
>  tests/ref/fate/filter-delogo |  218 +++++++++++++++++++++---------------------
>  2 files changed, 126 insertions(+), 117 deletions(-)
> 
> diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
> index 926a8a1..858595a 100644
> --- a/libavfilter/vf_delogo.c
> +++ b/libavfilter/vf_delogo.c
> @@ -1,6 +1,7 @@
>  /*
>   * Copyright (c) 2002 Jindrich Makovicka <makovick at gmail.com>
>   * Copyright (c) 2011 Stefano Sabatini
> + * Copyright (c) 2013 Jean Delvare <khali at linux-fr.org>
>   *
>   * This file is part of FFmpeg.
>   *
> @@ -22,7 +23,8 @@
>  /**
>   * @file
>   * A very simple tv station logo remover
> - * Ported from MPlayer libmpcodecs/vf_delogo.c.
> + * Originally imported from MPlayer libmpcodecs/vf_delogo.c,
> + * the algorithm was later improved.
>   */
>  
>  #include "libavutil/common.h"
> @@ -58,8 +60,8 @@ static void apply_delogo(uint8_t *dst, int dst_linesize,
>                           int logo_x, int logo_y, int logo_w, int logo_h,
>                           int band, int show, int direct)
>  {
> -    int x, y;
> -    int interp, dist;
> +    int x, y, dist;
> +    uint64_t interp, weightl, weightr, weightt, weightb;
>      uint8_t *xdst, *xsrc;

it seems coverity found a minor issue with this (CID1046439)
not sure how real it is ...

PS: ill give you access to the coverity stuff as soon as coverty
is fixed and accepts emails with a '-' in the domain or whatever the
reason why it doesnt accept it.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-cvslog/attachments/20130709/f4008713/attachment.asc>


More information about the ffmpeg-cvslog mailing list