DGDenoise

These CUDA filters are packaged into DGDecodeNV, which is part of DGDecNV.
User avatar
admin
Site Admin
Posts: 4410
Joined: Thu Sep 09, 2010 3:08 pm

Re: About DGDenoise

Post by admin » Sat Aug 20, 2016 12:38 pm

Hybrid must be moving things to dynamic on the fly. Can we get it working without hybrid first? The DGDenoise DLL is definitely being executed from dynamic and I query that, not the location of the viewer. I don't know how hybrid works to tell you what it is doing. It sounds like it copies the DLL to dynamic and runs it from there (makes sense given the name 'dynamic'). If so, it would also have to copy the other files. Maybe you can put all the files there yourself.

For example, I run my scripts in VirtualDub and its executable location is irrelevant, the location of the executed DGDenoise.dll is used. Maybe you can try with VirtualDub and after that we try to figure out hybrid and Vapoursynth.

Thank you for your debugging assistance, Selur! :bravo:

Selur
Moose Approved
Posts: 114
Joined: Mon Nov 05, 2012 4:49 pm

Re: About DGDenoise

Post by Selur » Sat Aug 20, 2016 12:57 pm

*gig* got it :D normally Hybrid changes the working directory of the environment to restrict malicious programs. :)
Running the script inside a normal command prompt works.
-> seems like a problem with Hybrid calling the tools (just removing the work directory adjustments I normally to, doesn't help, but I'll figure out a workaround)

User avatar
admin
Site Admin
Posts: 4410
Joined: Thu Sep 09, 2010 3:08 pm

Re: About DGDenoise

Post by admin » Sat Aug 20, 2016 1:07 pm

Sweet! Che figata.

You should be able to get hybrid and Vapoursynth working with appropriate engineering. Please advise what you find necessary so I can advise other users. Also, feedback on the actual filtering would be helpful (e.g., versus KNLMeansCL). There are a lot of cool things I can do with this framework, not just denoising. So I'm really grateful for you taking the time to make sure I am shipping what is needed to allow things to work on users' systems. This is my first foray into OpenGL/CUDA runtime stuff (DGIndexNV uses very basic CUDA driver API calls without textures or picture buffer objects). The server framework can allow other filters/applications to invoke the functionality as well. I would have to publish the interface of course. It's pretty simple: start the server, open some shared memory and events, and away you go! I'll release source code at some point. Right now I am focused on surpassing KNLMeansCL for denoising. If that is not possible, why bother? ;)

Technically, I implemented the nVidia imageDenoising sample code (with my tweaks) and enhanced it with Sobel edge protection. It appears to be qualitatively similar to KNLMeansCL (with appropriate parameter settings), but it runs much faster. If I can fully eliminate branching in my kernel, I may be able to squeeze out another 10% in performance, but it's already very fast. To be honest, KNLMeansCL source code is opaque to me. Some better commenting in the code might be helpful.

No need to add, my executables are never malicious. I have ony the users' best interests at heart. You know it. :wow:

Thank you again for your testing and may your projects achieve brilliant success!

Selur
Moose Approved
Posts: 114
Joined: Mon Nov 05, 2012 4:49 pm

Re: About DGDenoise

Post by Selur » Sat Aug 20, 2016 1:37 pm

btw. there is still something 'fishy' with your code.

using:

Code: Select all

LoadCPlugin("G:\Hybrid\AVISYN~1\ffms2.dll")
LoadPlugin("G:\Hybrid\AVISYN~1\DGDENO~1.DLL")
# loading source: F:\TestClips&Co\test.avi
FFVideoSource("F:\TESTCL~1\test.avi",cachefile="H:\Temp\avi_0197468a3716844ade54f3f30f60eeda_4827_1_0.ffindex",fpsnum=25)
# denoising using DGDenoise
ConvertToRGB32(interlaced=false)
DGDenoise()
gives me

Code: Select all

Avisynth open failure:
DGDenoise: could not start the denoise server C:\Program Files (x86)\VirtualDub\DenoiseServer.exe, error 2!
(H:\Temp\test.avs, line 7)
not using 8.3 filenames:

Code: Select all

LoadCPlugin("G:\Hybrid\avisynthPlugins\ffms2.dll")
LoadPlugin("G:\Hybrid\avisynthPlugins\DGDenoise.dll")
# loading source: F:\TestClips&Co\test.avi
FFVideoSource("F:\TestClips&Co\test.avi",cachefile="H:\Temp\avi_0197468a3716844ade54f3f30f60eeda_4827_1_0.ffindex",fpsnum=25)
# denoising using DGDenoise
ConvertToRGB32(interlaced=false)
DGDenoise()
the preview works,...
-> seems like your filter can't handle 8.3 file names :)

User avatar
admin
Site Admin
Posts: 4410
Joined: Thu Sep 09, 2010 3:08 pm

Re: About DGDenoise

Post by admin » Sat Aug 20, 2016 1:43 pm

Oh, I hate making fishy stuff. :roll:

I've been drinking too much Scotch to look into that right now (hey, it's Saturday, give me a break), but I will. Enlighten me, why do you need 8.3 file names?

Any feedback on results versus KNLMeansCL? That's what I'm really interested in.

Ciao, my good friend Selur.

Selur
Moose Approved
Posts: 114
Joined: Mon Nov 05, 2012 4:49 pm

Re: About DGDenoise

Post by Selur » Sat Aug 20, 2016 1:57 pm

I need 8.3 file names because a bunch of Avisynth filters (especially source and subtitle filters) have problems handling for example Chinese, Russian, Korean, Greek,.. characters inside file or folder names.
(btw. DGDecNV and DGindex both can't handle such files, but have no problem with 8.3 file names; mplayer, mencoder and a lot of other older tools have that problem too ;))

-> no hurry, for you to look into it, just wanted to note that there is something not quite right

User avatar
admin
Site Admin
Posts: 4410
Joined: Thu Sep 09, 2010 3:08 pm

Re: About DGDenoise

Post by admin » Sat Aug 20, 2016 2:02 pm

No problem, Selur, I'll take care of it for you [it's probably a wart on ShellExecute()]. Rock on and thanks for the great thread!

Selur
Moose Approved
Posts: 114
Joined: Mon Nov 05, 2012 4:49 pm

Re: About DGDenoise

Post by Selur » Sat Aug 20, 2016 2:09 pm

Thanks! Will do some testing with the filter in comparison to KNLMeansCL tomorrow. :) (9pm here on Saturday -> family&friends time ;))

Cu Selur

User avatar
admin
Site Admin
Posts: 4410
Joined: Thu Sep 09, 2010 3:08 pm

Re: About DGDenoise

Post by admin » Sat Aug 20, 2016 2:50 pm

Family and friends time, what a blessing.

Don't ignore kernel=1 if you like things to be as fast as possible. I don't see big image quality gains with NLM over KNN. Most video is well-localized. Prove me wrong. :twisted:

Selur
Moose Approved
Posts: 114
Joined: Mon Nov 05, 2012 4:49 pm

Re: About DGDenoise

Post by Selur » Sun Aug 21, 2016 4:43 am

Playing around with the filter atm. and the first real downer is that it requires to turn off the MT support.

Code: Select all

SetMemoryMax(768)
SetMTMode(5,8) # change MT mode
LoadPlugin("G:\Hybrid\avisynthPlugins\LSMASHSource.dll")
LoadPlugin("G:\Hybrid\avisynthPlugins\DGDenoise.dll")
LWLibavVideoSource("F:\TestClips&Co\Transformers - 1080p Sample.mkv",cache=false)
SetMTMode(6) # change MT mode
ConvertToRGB32(interlaced=false)
DGDenoise()
return last
simply is stuck and

Code: Select all

LoadPlugin("G:\Hybrid\avisynthPlugins\LSMASHSource.dll")
LoadPlugin("G:\Hybrid\avisynthPlugins\DGDenoise.dll")
LWLibavVideoSource("F:\TestClips&Co\Transformers - 1080p Sample.mkv",cache=false)
ConvertToRGB32(interlaced=false)
DGDenoise()
return last
works fine.
On the other hand:

Code: Select all

SetMTMode(5,8) # change MT mode
LoadPlugin("G:\Hybrid\avisynthPlugins\LSMASHSource.dll")
LoadPlugin("G:\Hybrid\avisynthPlugins\KNLMeansCL.dll")
LWLibavVideoSource("F:\TestClips&Co\Transformers - 1080p Sample.mkv",cache=false)
SetMTMode(5) # change MT mode
KNLMeansCL(device_type = "GPU", device_id = 1)
return last
works fine, sure as long as one only uses DGDenoise or KNLMeansCL it doesn't really matter since instead of using MT with mode 5 it's faster to disable MT, but when using a script with multiple filters, MT compatibility would be nice.

----
using:

Code: Select all

LoadPlugin("G:\Hybrid\avisynthPlugins\LSMASHSource.dll")
LoadPlugin("G:\Hybrid\avisynthPlugins\KNLMeansCL.dll")
LoadPlugin("G:\Hybrid\avisynthPlugins\DGDenoise.dll")
src = LWLibavVideoSource("F:\TestClips&Co\Transformers - 1080p Sample.mkv",cache=false)
src = src.Crop(0,140,0,-140)
knl = src.KNLMeansCL(device_type="GPU")
knl = knl.ConvertToRGB32(interlaced=false)
src = src.ConvertToRGB32(interlaced=false)
dg = src.DGDenoise()
StackVertical(StackHorizontal(knl, dg), StackHorizontal(src, src))
return last
to compare the effect at the default values of DGDenoise and KNLMeansCL one clearly sees that using the default values DGDenoise is WAY more aggressive.
Settings strength=0.2 seems to produce more similar effects.

Running a small benchmark using AVSMeter:

Code: Select all

LoadPlugin("G:\Hybrid\avisynthPlugins\LSMASHSource.dll")
LoadPlugin("G:\Hybrid\avisynthPlugins\DGDenoise.dll")
LWLibavVideoSource("F:\TestClips&Co\Transformers - 1080p Sample.mkv",cache=false)
ConvertToRGB32(interlaced=true)
DGDenoise(strength=0.2)
return last
gives:

Code: Select all

AviSynth 2.60, build:Feb 20 2015 [03:16:45] (2.6.0.5)

Number of frames:                 1081
Length (hh:mm:ss.ms):     00:00:45.087
Frame width:                      1920
Frame height:                     1080
Framerate:                      23.976 (24000/1001)
Colorspace:                      RGB32
Active MT Mode:                      0

Frames processed:               1081 (0 - 1080)
FPS (min | max | average):      46.97 | 66.71 | 65.38
Memory usage (phys | virt):     333 | 327 MiB
Thread count:                   18
CPU usage (average):            22%

GPU core clock / memory clock:  1025 / 1652
GPU usage (average):            24%
VPU usage (average):            0%
GPU memory usage:               1536 MiB

Time (elapsed):                 00:00:16.535
with kernel=2 (same strength) I get:

Code: Select all

AviSynth 2.60, build:Feb 20 2015 [03:16:45] (2.6.0.5)

Number of frames:                 1081
Length (hh:mm:ss.ms):     00:00:45.087
Frame width:                      1920
Frame height:                     1080
Framerate:                      23.976 (24000/1001)
Colorspace:                      RGB32
Active MT Mode:                      0

Frames processed:               1081 (0 - 1080)
FPS (min | max | average):      8.363 | 16.19 | 15.87
Memory usage (phys | virt):     333 | 328 MiB
Thread count:                   15
CPU usage (average):            5%

GPU core clock / memory clock:  1215 / 1753
GPU usage (average):            82%
VPU usage (average):            0%
GPU memory usage:               1536 MiB

Time (elapsed):                 00:01:08.105
and with kernel = 1 (same strength) I get:

Code: Select all

AviSynth 2.60, build:Feb 20 2015 [03:16:45] (2.6.0.5)

Number of frames:                 1081
Length (hh:mm:ss.ms):     00:00:45.087
Frame width:                      1920
Frame height:                     1080
Framerate:                      23.976 (24000/1001)
Colorspace:                      RGB32
Active MT Mode:                      0

Frames processed:               1081 (0 - 1080)
FPS (min | max | average):      49.52 | 73.35 | 70.73
Memory usage (phys | virt):     333 | 327 MiB
Thread count:                   18
CPU usage (average):            23%

GPU core clock / memory clock:  1025 / 1652
GPU usage (average):            19%
VPU usage (average):            0%
GPU memory usage:               1536 MiB

Time (elapsed):                 00:00:15.284
For KNLMeansCL on the other hand:

Code: Select all

LoadPlugin("G:\Hybrid\avisynthPlugins\LSMASHSource.dll")
LoadPlugin("G:\Hybrid\avisynthPlugins\KNLMeansCL.dll")
LWLibavVideoSource("F:\TestClips&Co\Transformers - 1080p Sample.mkv",cache=false)
KNLMeansCL(device_type = "GPU", device_id = 1)
return last
produces:

Code: Select all

AviSynth 2.60, build:Feb 20 2015 [03:16:45] (2.6.0.5)

Number of frames:                 1081
Length (hh:mm:ss.ms):     00:00:45.087
Frame width:                      1920
Frame height:                     1080
Framerate:                      23.976 (24000/1001)
Colorspace:                       i420
Active MT Mode:                      0

Frames processed:               1081 (0 - 1080)
FPS (min | max | average):      13.57 | 38.80 | 37.10
Memory usage (phys | virt):     366 | 392 MiB
Thread count:                   25
CPU usage (average):            19%

GPU core clock / memory clock:  1215 / 1652
GPU usage (average):            88%
VPU usage (average):            0%
GPU memory usage:               1558 MiB

Time (elapsed):                 00:00:29.135
so unless kernel=2 is used DGDenoise seems to be faster. From a few samples I looked at so far there wasn't much of a difference between kernel=3 and kernel=1.
(btw. using an i7-4770k with an Intel® HD Graphics 4600 and a GeForce GTX 980 Ti on a HP Z27q 5k display under Windows 10 64bit)

Looking for some nice noisy source to do some more testing.

Cu Selur

Post Reply