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

Clément Bœsch u at pkh.me
Fri Feb 1 10:29:09 EET 2019


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?

> 
> 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

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190201/dfac2678/attachment.sig>


More information about the ffmpeg-devel mailing list