[FFmpeg-devel] [PATCH V2] lavfi/vf_nlmeans: Improve the performance for nlmeans

mypopy at gmail.com mypopy at gmail.com
Fri Feb 1 10:57:37 EET 2019


On Fri, Feb 1, 2019 at 4:29 PM Clément Bœsch <u at pkh.me> wrote:
>
> On Fri, Feb 01, 2019 at 10:45:24AM +0800, Jun Zhao wrote:
> > Remove the pdiff_lut_scale in nlmeans and increase weight_lut table size
> > from 2^9 to 800000, this change will avoid using pdiff_lut_scale in
> > nlmeans_slice() for weight_lut table search, it's will improve the
> > performance about 12%. (in 1080P size picture case).
> >
> > Use the profiling command like:
> >
> > perf stat -a -d -r 5 ./ffmpeg -i input -an -vf nlmeans=s=30 -vframes 10 \
> > -f null /dev/null
> >
> > without this change:
> > when s=1.0(default value) 63s
> >      s=30.0               72s
> >
> > after this change:
> >      s=1.0(default value) 56s
> >      s=30.0               63s
>
> Nice.
>
> I assume this is tested on x86_64?
Yes
>
> >
> > Reviewed-by: Carl Eugen Hoyos <ceffmpeg at gmail.com>
> > Signed-off-by: Jun Zhao <mypopydev at gmail.com>
> > ---
> >  libavfilter/vf_nlmeans.c |   12 ++++--------
> >  1 files changed, 4 insertions(+), 8 deletions(-)
> >
> > diff --git a/libavfilter/vf_nlmeans.c b/libavfilter/vf_nlmeans.c
> > index 82e779c..72eb819 100644
> > --- a/libavfilter/vf_nlmeans.c
> > +++ b/libavfilter/vf_nlmeans.c
> > @@ -43,8 +43,7 @@ struct weighted_avg {
> >      float sum;
> >  };
> >
> > -#define WEIGHT_LUT_NBITS 9
> > -#define WEIGHT_LUT_SIZE  (1<<WEIGHT_LUT_NBITS)
> > +#define WEIGHT_LUT_SIZE  (800000) // need to >  300 * 300 * log(255)
>
> So the LUT is now 3.2MB?
>
> Why 300? 300*300*log(255) is closer to 500 000 than 800 000
I just seleted a value > 300*300*log(255) (500 000 more precise) for
this case at liberty in fact , the other option is use a dynamic
allocation memory for weight_lut table size base on the
max_meaningful_diff :), but maybe seems pretty obvious, I think 3M is
not a big burden for nlmeans


More information about the ffmpeg-devel mailing list