Log in

View Full Version : KNLMeansCL: OpenCL NLMeans de-noising algorithm [2018-01-29]


Pages : [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

Khanattila
13th November 2014, 15:39
--> pinterf's fork (https://github.com/pinterf/KNLMeansCL/release)

--> https://github.com/Khanattila/KNLMeansCL/releases/tag/v1.1.1

KNLMeansCL v1.1.1
* Added more check of rclip.
* Fixed build programm error in some circumstances.
* Fixed Avisynth YUV444P10 video format.
* Fixed Vapoursynth RGB30 video format.
* Fixed clip processing with higher resolution than 4K.


KNLMeansCL is an optimized OpenCL implementation of the Non-local means de-noising algorithm. The NLMeans filter, originally proposed by Buades et al., is a very popular filter for the removal of white Gaussian noise, due to its simplicity and excellent performance. The strength of this algorithm is to exploit the repetitive character of the image in order to de-noise the image unlike conventional de-noising algorithms, which typically operate in a local neighbourhood.

For end user KNLMeansCL is a plugin for AviSynth, AviSynth+ and for VapourSynth. Windows, OS X and Linux are supported. Read more on the Wiki (https://github.com/Khanattila/KNLMeansCL/wiki).

KNLMeansCL is available under the GNU GPL v3 license.

FAQ
Q) I can't make DGNV and KNLmeansCL work together in avs script.
A) Post #664 (http://forum.doom9.org/showpost.php?p=1766150&postcount=664).

Groucho2004
13th November 2014, 16:19
Works right out of the box (well, apart from the obligatory MS*120.dlls) unlike the original NLMeansCL which I never got to work properly. Seems very fast as well, even on my lowly GT240 card.

Awesome!

Groucho2004
13th November 2014, 16:31
NLMeansCL(clip src, int A, int Ay, int S, int Sy, int B, int By, float aa, float h, bool sse, string device_type, int y, int u, int v, bool info)
That should read "NLMeansCL2".

Khanattila
13th November 2014, 16:34
That should read "NLMeansCL2".
thanks

Khanattila
15th November 2014, 22:52
Edit.

Reel.Deel
15th November 2014, 23:12
Thanks Khanattila, very nice indeed. Briefly tested it on my GTX780 and it's pretty fast. What source filter did you use for the benchmark? Also, any interest in showing some love to Y8?

Mounir
15th November 2014, 23:14
Still no support of YUY2 ? What about temporal denoising ??

Reel.Deel
15th November 2014, 23:17
Still no support of YUY2?

Use the planar equivalent YV16 instead.

TheFluff
15th November 2014, 23:56
why would you ever want yuy2 support

Khanattila
16th November 2014, 00:20
Thanks Khanattila, very nice indeed. Briefly tested it on my GTX780 and it's pretty fast. What source filter did you use for the benchmark? Also, any interest in showing some love to Y8?

Y8 support? It's easy, I will add in the next release.
For benchmark... I use AVSMeter.
To get a clean result, you should subtract the time of ffms2 & co.

Example:
ffms2 + Dither_convert_8_to_16() -> 326.4 FPS -> 3.0637 ms for frame.
ffms2 + Dither + NLMeansCL2() -> 60.46 FPS -> 16.5399 ms for frame

So NLMeansCL2() take 13.4762 ms for frame -> 74.2 FPS

feisty2
16th November 2014, 03:10
gorgeous
add temporal mode maybe?

Bloax
16th November 2014, 06:03
Testing on an ancient 9800 GT I didn't expect much, but it turns out that it still works! (https://dl.dropboxusercontent.com/u/63152810/Screenies/dumb/DefaultsYV24.png)
Unless you set U=3,V=3 (https://dl.dropboxusercontent.com/u/63152810/Screenies/dumb/DefaultsYV24%2BU3%2BV3.png) or the input isn't YV24 (https://dl.dropboxusercontent.com/u/63152810/Screenies/dumb/DefaultsYV12%2BU3%2BV3.png). (although it works fine with YV12 if the UV channels aren't set to be processed) :v
or if you set the A value too high (a >= 10)

Khanattila
16th November 2014, 12:42
Edit.

Bloax
16th November 2014, 15:19
I can confirm that A >= 10 (output isn't buggy garbage even at a=21) works now, as does chroma processing.

Keiyakusha
16th November 2014, 16:27
Wow, one of my favorite filters reborn without these annoying dependencies! Haven't tried it but still nice!

As for temporal, I remember Malcolm gave up on it cause it didn't produced decent results and his recommendation was something like "Just use MVTools". That's why temporal thingy in his plugin is buggy, was never completed and v0.4 branch abandoned.

feisty2
16th November 2014, 16:51
az works nicely on tritical's original version, is it very hard to port it from cpp to opencl? sorry, i got little programming knowledge, dunno much about it

Khanattila
16th November 2014, 17:01
Still no support of YUY2 ?

YUY2 is packed.
NLMeansCL2() with YUY2 support have the same performance of YUY2Clip.ConvertToYV16().NLMeansCL2()

Reel.Deel
16th November 2014, 17:09
Y8 support? It's easy, I will add in the next release.

Y8 support would be great :)

YUY2 is packed.
NLMeansCL2() with YUY2 support have the same performance of ConvertToYUY2().NLMeansCL2()

Shouldn't it be ConvertToYV16().NLMeansCL2()?

Edit:
Might be worth mentioning that NLMeansCL2 already supports YV16/YV24.

Khanattila
16th November 2014, 18:36
Y8 support would be great :)



Shouldn't it be ConvertToYV16().NLMeansCL2()?

Edit:
Might be worth mentioning that NLMeansCL2 already supports YV16/YV24.
yes in both cases

Khanattila
16th November 2014, 21:20
Edit.

Asmodian
17th November 2014, 02:58
>>>> NLMeans2_v0.3.0.zip <<<< (http://www.mediafire.com/download/1dpyf1ueusm575h/NLMeansCL2_v0.3.0.zip)

ChangeLog

v0.3.0 (2014-11-16)
* Works with Y8.
* Prevent possible memory leak.
* More selective resource load.


Hate these weekends without football!

It turns out we like them. ;)

:thanks:

Khanattila
19th November 2014, 17:47
Edit.

yup
20th November 2014, 15:03
Khanattila!
:thanks:
for update.
I test Your plugin on different PC.
It is work fine for Windows XP 32 with NVIDIA GeForce 8800 GTS 512 and Windows 7 64 with Intel HD, but have problem with Windows 7 64 with GTX 560
Script
AVISource("chapter13.avi")
AssumeTFF()
ConvertToYV12(interlaced=true)
SeparateFields()
NLMeansCL2(device_type="GPU")
Weave()
I get error
Avisynth open failure:
NLMeansCL2: Houston, we've had a problem!
[clCreateContext (CL_INVALID_DEVICE)]
(C:\Video\Source\stenyaev\tesnlmcl.avs, line 5)

Data for GPU
OpenCL 1.1 CUDA 6.5.12 FULL_PROFILE
1: GeForce GTX 560
If change device type to CPU, I get error
Avisynth open failure:
NLMeansCL2: Houston, we've had a problem!
[create_image2d (CL_GENERIC_ERROR)]
(C:\Video\Source\stenyaev\tesnlmcl.avs, line 5)
Malcolm version work without problem, also work cl version nnedi3 written by SEt. MSVC 2013 installed.
Also when I try on other computer with avisynth+ and open avs in Virtualdub I get error about insert disk for installation, after cancel avs opened. When I replace to Avisynth 2.6 MT all became fine.
yup.

Khanattila
20th November 2014, 18:52
Ok, let me explain.
This plugin use the default OpenCL context of your system because I have not yet implemented a system scan.
If for example the system uses NVIDIA CUDA as default OpenCL context is not possible to set device_type = "CPU".
Because NVIDIA CUDA do not support any CPU.

It is possible that the system default is wrong.

yup
20th November 2014, 19:28
Khanattila!
I am also try device_type="GPU" and get error.
May be try change Nvidia driver?
And why work previous Malcolm version?
Tomorrow I try some recreation my system and report.
yup.

Khanattila
20th November 2014, 20:43
Khanattila!
I am also try device_type="GPU" and get error.
May be try change Nvidia driver?
And why work previous Malcolm version?
Tomorrow I try some recreation my system and report.
yup.

Please, use GPU Caps Viewer :)
(validation link)

yup
21st November 2014, 09:27
Khanattila!
Report from GPU Caps Viewer
===================================[ OpenCL Capabilities ]
- Num OpenCL platforms: 2
- CL_PLATFORM_NAME: Intel(R) OpenCL
- CL_PLATFORM_VENDOR: Intel(R) Corporation
- CL_PLATFORM_VERSION: OpenCL 1.1
- CL_PLATFORM_PROFILE: FULL_PROFILE
- Num devices: 1

- CL_DEVICE_NAME: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
- CL_DEVICE_VENDOR: Intel(R) Corporation
- CL_DRIVER_VERSION: 1.1
- CL_DEVICE_PROFILE: FULL_PROFILE
- CL_DEVICE_VERSION: OpenCL 1.1 (Build 31360.31441)
- CL_DEVICE_TYPE: CPU
- CL_DEVICE_VENDOR_ID: 0x8086
- CL_DEVICE_MAX_COMPUTE_UNITS: 8
- CL_DEVICE_MAX_CLOCK_FREQUENCY: 3400MHz
- CL_DEVICE_ADDRESS_BITS: 32
- CL_DEVICE_MAX_MEM_ALLOC_SIZE: 524256KB
- CL_DEVICE_GLOBAL_MEM_SIZE: 2047MB
- CL_DEVICE_MAX_PARAMETER_SIZE: 3840
- CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: 64 Bytes
- CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: 256KB
- CL_DEVICE_ERROR_CORRECTION_SUPPORT: NO
- CL_DEVICE_LOCAL_MEM_TYPE: Global
- CL_DEVICE_LOCAL_MEM_SIZE: 32KB
- CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 128KB
- CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3
- CL_DEVICE_MAX_WORK_ITEM_SIZES: [1024 ; 1024 ; 1024]
- CL_DEVICE_MAX_WORK_GROUP_SIZE: 1024
- CL_EXEC_NATIVE_KERNEL: 14404036
- CL_DEVICE_IMAGE_SUPPORT: YES
- CL_DEVICE_MAX_READ_IMAGE_ARGS: 480
- CL_DEVICE_MAX_WRITE_IMAGE_ARGS: 480
- CL_DEVICE_IMAGE2D_MAX_WIDTH: 8192
- CL_DEVICE_IMAGE2D_MAX_HEIGHT: 8192
- CL_DEVICE_IMAGE3D_MAX_WIDTH: 2048
- CL_DEVICE_IMAGE3D_MAX_HEIGHT: 2048
- CL_DEVICE_IMAGE3D_MAX_DEPTH: 2048
- CL_DEVICE_MAX_SAMPLERS: 480
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR: 16
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT: 8
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT: 4
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG: 2
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: 4
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: 2
- CL_DEVICE_EXTENSIONS: 11
- Extensions:
- cl_khr_fp64
- cl_khr_icd
- cl_khr_global_int32_base_atomics
- cl_khr_global_int32_extended_atomics
- cl_khr_local_int32_base_atomics
- cl_khr_local_int32_extended_atomics
- cl_khr_byte_addressable_store
- cl_intel_printf
- cl_ext_device_fission
- cl_intel_exec_by_local_thread
- cl_khr_gl_sharing
- CL_PLATFORM_NAME: NVIDIA CUDA
- CL_PLATFORM_VENDOR: NVIDIA Corporation
- CL_PLATFORM_VERSION: OpenCL 1.1 CUDA 6.5.12
- CL_PLATFORM_PROFILE: FULL_PROFILE
- Num devices: 1

- CL_DEVICE_NAME: GeForce GTX 560
- CL_DEVICE_VENDOR: NVIDIA Corporation
- CL_DRIVER_VERSION: 340.52
- CL_DEVICE_PROFILE: FULL_PROFILE
- CL_DEVICE_VERSION: OpenCL 1.1 CUDA
- CL_DEVICE_TYPE: GPU
- CL_DEVICE_VENDOR_ID: 0x10DE
- CL_DEVICE_MAX_COMPUTE_UNITS: 7
- CL_DEVICE_MAX_CLOCK_FREQUENCY: 1620MHz
- CL_NV_DEVICE_COMPUTE_CAPABILITY_MAJOR: 2
- CL_NV_DEVICE_COMPUTE_CAPABILITY_MINOR: 1
- CL_NV_DEVICE_REGISTERS_PER_BLOCK: 32768
- CL_NV_DEVICE_WARP_SIZE: 32
- CL_NV_DEVICE_GPU_OVERLAP: 1
- CL_NV_DEVICE_KERNEL_EXEC_TIMEOUT: 1
- CL_NV_DEVICE_INTEGRATED_MEMORY: 0
- CL_DEVICE_ADDRESS_BITS: 32
- CL_DEVICE_MAX_MEM_ALLOC_SIZE: 262144KB
- CL_DEVICE_GLOBAL_MEM_SIZE: 1024MB
- CL_DEVICE_MAX_PARAMETER_SIZE: 4352
- CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: 128 Bytes
- CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: 112KB
- CL_DEVICE_ERROR_CORRECTION_SUPPORT: NO
- CL_DEVICE_LOCAL_MEM_TYPE: Local (scratchpad)
- CL_DEVICE_LOCAL_MEM_SIZE: 47KB
- CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 64KB
- CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3
- CL_DEVICE_MAX_WORK_ITEM_SIZES: [1024 ; 1024 ; 64]
- CL_DEVICE_MAX_WORK_GROUP_SIZE: 1024
- CL_EXEC_NATIVE_KERNEL: 14404032
- CL_DEVICE_IMAGE_SUPPORT: YES
- CL_DEVICE_MAX_READ_IMAGE_ARGS: 128
- CL_DEVICE_MAX_WRITE_IMAGE_ARGS: 8
- CL_DEVICE_IMAGE2D_MAX_WIDTH: 32768
- CL_DEVICE_IMAGE2D_MAX_HEIGHT: 32768
- CL_DEVICE_IMAGE3D_MAX_WIDTH: 2048
- CL_DEVICE_IMAGE3D_MAX_HEIGHT: 2048
- CL_DEVICE_IMAGE3D_MAX_DEPTH: 2048
- CL_DEVICE_MAX_SAMPLERS: 16
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR: 1
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT: 1
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT: 1
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG: 1
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: 1
- CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: 1
- CL_DEVICE_EXTENSIONS: 15
- Extensions:
- cl_khr_byte_addressable_store
- cl_khr_icd
- cl_khr_gl_sharing
- cl_nv_d3d9_sharing
- cl_nv_d3d10_sharing
- cl_khr_d3d10_sharing
- cl_nv_d3d11_sharing
- cl_nv_compiler_options
- cl_nv_device_attribute_query
- cl_nv_pragma_unroll
- cl_khr_global_int32_base_atomics
- cl_khr_global_int32_extended_atomics
- cl_khr_local_int32_base_atomics
- cl_khr_local_int32_extended_atomics
- cl_khr_fp64

I have last driver availible from Nvidia.
yup.

Khanattila
21st November 2014, 09:43
That's what I tried to explain.

- Num OpenCL platforms: 2
- CL_PLATFORM_NAME: Intel(R) OpenCL
- CL_PLATFORM_VENDOR: Intel(R) Corporation
- CL_PLATFORM_VERSION: OpenCL 1.1
- CL_PLATFORM_PROFILE: FULL_PROFILE

You have two OpenCL platforms, and default is Intel.
Because NLMeansCL2 is still in development, it use only the default context.
If you remove the intel OpenCL driver it should work.

yup
21st November 2014, 12:32
Khanattila!
I remove Intel OpenCL SDK and now all work.
yup.

Khanattila
21st November 2014, 12:58
Khanattila!
I remove Intel OpenCL SDK and now all work.
yup.

Glad you managed to solve it.

HOB
22nd November 2014, 03:25
Hello
I wonder if this plugin will work in MeGUI? I was able to get NLMeansCL to work in MeGUI the minor problems I encountered I was able to overcome. I downloaded this plugin and copied it to the standard MeGUI folder for this kind of plugin but MeGUI doesn't seem to recognize it properly...OR...perhaps I didn't install it correctly? Will it work or shall I just continue to check in here to see if you've made it compatible with MeGUI?
Thanks

Reel.Deel
22nd November 2014, 03:33
I downloaded this plugin and copied it to the standard MeGUI folder for this kind of plugin but MeGUI doesn't seem to recognize it properly...

Do you have the appropriate requirements?

AviSynth 2.6 Alpha 5
Visual C++ Redistributable Package for Visual Studio 2013 (x86) (http://www.microsoft.com/en-us/download/details.aspx?id=40784)

I don't use MeGUI so I can't check.

StainlessS
22nd November 2014, 04:06
RD, can I ask then, what do you use for h264, just curious.

Reel.Deel
22nd November 2014, 04:17
x264.exe (I use tMod), I sometimes load the .avs directly, or use Avs2YUV to pipe to x264 (mainly for 10-bit video). Anyways this it OT so I'll stop.

----

@Khanattila
When this filter becomes stable do you mind if I add to the AviSynth wiki?

HOB
22nd November 2014, 04:37
Hello Reel.Deel
Yes I do have AviSynth 2.6 Alpha 5 installed.

Reel.Deel
22nd November 2014, 04:48
@HOB
How about the 2013 runtime? Also, any error message?

HOB
22nd November 2014, 05:53
Reel.Deel
Yes and here is the message:

http://i62.tinypic.com/2dbplqo.jpg

Khanattila
22nd November 2014, 10:59
Hello
I wonder if this plugin will work in MeGUI? I was able to get NLMeansCL to work in MeGUI the minor problems I encountered I was able to overcome. I downloaded this plugin and copied it to the standard MeGUI folder for this kind of plugin but MeGUI doesn't seem to recognize it properly...OR...perhaps I didn't install it correctly? Will it work or shall I just continue to check in here to see if you've made it compatible with MeGUI?
Thanks
A safe way is to install AviSynth and do not use the included AviSynth.
Just copy the plugin in "C:\Program Files (x86)\AviSynth 2.5\plugins" (example).
MeGui can call all of them.

HOB
22nd November 2014, 18:58
Khanattila
Sorry to be a dunce but I'm not having any luck and I don't want to waste anymore or your time, I'll just tune into this site every once in a while to see if any one has gotten this plugin working with MeGUI and hope they post instructions on HOW EXACTLY they managed it.
Thanks

Reel.Deel
22nd November 2014, 19:03
@HOB

error=0x7e? Hmm doesn't this error mean that a component is missing? Are you sure you have the 32-bit (x86) 2013 Redistributable Package?

Edit: try loading NLMeansCL2.dll with Dependency Walker (http://www.dependencywalker.com/) to be sure that nothing is missing.

HOB
22nd November 2014, 20:39
Reel.Deel
I think you may be on to something, I may be missing a component for THIS plugin. I have quite a large number of third party plugins installed in MeGUI and I've not come across this problem with any of them. I'll double check to make sure I have the package you refer to installed and if not I'll get it installed...

Thanks for the suggestions....I'll be back.

Khanattila
23rd November 2014, 01:36
Khanattila
Sorry to be a dunce but I'm not having any luck and I don't want to waste anymore or your time, I'll just tune into this site every once in a while to see if any one has gotten this plugin working with MeGUI and hope they post instructions on HOW EXACTLY they managed it.
Thanks

It's probably my fault but MeGUI is just a gui for AviSynth, x264 and other software.

AviSynth have two ways to load plugin. Using this code in a script
LoadPlugin ("filename" [, ...])
or copy plugin in this folder.
D:\Program Files (x86)\AviSynth 2.5\plugins
The plugins from 'plugins' folder are auto-loaded at AviSynth startup, and this is the safest way. So just copy "NLMeansCL2.dll" in "plugins" and all will go in the right way :)

http://s2.postimg.org/3ypdeb1ft/Me_GUI.jpg

HOB
23rd November 2014, 18:05
Hello Khanattila and Reel.Deel
I think Reel.Deel has the solution I AM missing a component...I copied the NLMeansCL2.dll to the indicated directory and got the following error message:

http://i58.tinypic.com/dqrigy.jpg

Any suggestions as to which component I need to download and install?
Thanks

Sparktank
23rd November 2014, 18:20
http://i58.tinypic.com/dqrigy.jpg

Visual C++ Redistributable Package for Visual Studio 2013 (x86) (http://www.microsoft.com/en-us/download/details.aspx?id=40784)

Did you at all install that?
Install it anway. If you did, re-install it.
If you don't know, install it.

HOB
23rd November 2014, 20:09
Of course Isaac was right about that standing on the shoulders of giants business…with your help it WORKED.

Thanks Khanattila, Reel.Deel and Sparktank.

Khanattila
28th November 2014, 13:01
Edit.

dbart
5th December 2014, 10:49
one technical HW question:

i dont play games, im happy with passive GT430 for video decoding and fft3dgpu filtering. Now playing with this filter i start thinking about GTX 750.

Is it better to have 2 GB memory version of this card, or 1 GB model is enough for using NLMeansCL2 ?

Groucho2004
5th December 2014, 11:18
one technical HW question:

i dont play games, im happy with passive GT430 for video decoding and fft3dgpu filtering. Now playing with this filter i start thinking about GTX 750.

Is it better to have 2 GB memory version of this card, or 1 GB model is enough for using NLMeansCL2 ?
The maximum graphics memory I have seen it use is about 160MB with 1080p, checked with GPU-Z. I run it on a GT240 with 512MB.

If you don't play games I think 1 GB would be plenty. However, you'll have to consider that other filters may be using the graphics memory (now or in the future). If the price difference is not too big, go for 2 GB.

Khanattila
5th December 2014, 22:40
In video memory are loaded the source and the target frame.
Each frame weighs 8-bit / 16-bit for pixel.
So in the worst case: 1920x1080, YV24, y=3, u=3, v=3, 16-bits.

1920*1080*16*2*3 = 190 MB.

Khanattila
3rd January 2015, 23:49
Edit.