[FFmpeg-devel] [PATCH 2/3] delogo: Use weighted interpolation

Jean Delvare khali at linux-fr.org
Mon Jun 24 11:26:57 CEST 2013

Hi Stefano,

On Sun, 23 Jun 2013 12:06:33 +0200, Stefano Sabatini wrote:
> On date Wednesday 2013-06-19 16:18:06 +0200, Jean Delvare encoded:
> > 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. This makes the
> > algorithm slightly slower but I'd say it is completely worth it.
> How much slower (-benchmark or use libavutil/time.h macros to test the
> processing loop)?

I used -benchmark to measure the difference but couldn't really, it has
the same order of magnitude than the measurement noise. I collected
numbers over multiple runs to cancel the noise as much as possible, and
to my surprise the results suggest the new algorithm is slightly faster
(by 8%, nothing spectacular).

Originally I suspected my algorithm would be slower because it does a
lot more multiplications and uses uint64_t, but looking a bit closer,
the inner loop now has only 1 division instead of 5, and divisions are
much more expensive than all other operations. This could explain the
performance gain.

BTW, if performance is an issue, I noticed that the original code is
not optimized at all and I have several ideas how it could be made
faster. I planned to work on that next.

> What if you add a flag for setting the enhanced quality?

Given the results above, I'd rather avoid it, it would add complexity
for no good reason.

> > 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>
> > ---
> > I am using unsigned long long here because the computations would
> > otherwise possibly overflow when the logo area is big.
> > 
> >  libavfilter/vf_delogo.c      |   25 +++-
> >  tests/ref/fate/filter-delogo |  218 +++++++++++++++++++++----------------------
> >  2 files changed, 126 insertions(+), 117 deletions(-)
> [...]
> The change itself looks reasonable.

Thanks for the review :)

Jean Delvare

More information about the ffmpeg-devel mailing list