rigaya / NVEnc

NVENCによる高速エンコードの性能実験
https://rigaya34589.blog.fc2.com/blog-category-17.html
Other
1.03k stars 108 forks source link

--vpp-nlmeans explanation #592

Closed dan64 closed 2 weeks ago

dan64 commented 2 weeks ago

NLMeans is a very useful denoise filter. Thanks for having included it in NVEnc.

This filter was already available in ffmpeg and Handbrake.

There is an interesting explanation of this filter here: NLMeans denoise filter

The problem is that I'm unable to reconcile the parameters described in the above post, with the parameters defined in NVEnc.

The NLMeans parameters described in the above posts are:

Could you provide the mapping between the 2 implementations ?

Thanks, Dan

rigaya commented 2 weeks ago

Unfortunately, I know nothing about handbrake implementation of nlmeans, so I can say nothing about it.

The implementation seems to be different, and it makes not meaningful to compare parameters of two implementations.

If you force to try match the parameters, it will be like below, but the value range seems to differ a lot. I will not go further in to the value range.

Strength→sigma, h Origin Weight→none Patch Size→patch Range →search Frames → none Prefilter Mode→none

“none” means feature or option is not available.

dan64 commented 2 weeks ago

Looking to the ffmpeg implementation, the main parameters are:

So it seems that a possible mapping could be:

s -> sigma (default=0.005, 0.0 -), h (default=0.05, 0.0 <) p -> patch (default=5, 3 - 21) r -> search (default=11, 3 - 21)

The values for "p" and "r" are compatible with the values used in NVEnc. It is not clear the range (0.0 -) for sigma what represent, the same for h, is not clear what represent the range (0.0 <).

By looking to the function vf_nlmeans.c

h is calculated as: h = s->sigma * 10.0;

but as you said the problem for "sigma" and "h" is that the range of values is different.

While even in NVEnc the ratio h/sigma is equal to 10, the default value for "s" in ffmpeg is 1.0 while in NVEnc is 0.005

Maybe the strength in ffmpeg is expressed in bit, so that 0.005*255 is about 1.

Dan

dan64 commented 2 weeks ago

Doing some tests on NLMeans the sensitivity to Sigma is very high.

See a comparison: NLMeans

PMD is able to retain better the details

See a comparison: PMD

PMD=4 provides the same bit rate and denoise of NLMeans with Sigma = 0.002 but is able to retain better the details, see: PMD vs NLMeans

I think that the default S=0.005 is too high because is removing too many details and should be lowered to S=0.002.

Dan

rigaya commented 2 weeks ago

vpp-nlmeans is not implemted to be equivalent to other implementations.

I disagree to change the default parameter, please set the sigma parameter to lower the strength of it, as that is why the parameter can be changed by command line option.