CUDASynth

These CUDA filters are packaged into DGDecodeNV, which is part of DGDecNV.
Post Reply
DAE avatar
Guest 2
Posts: 903
Joined: Mon Sep 20, 2010 2:18 pm

Re: CUDASynth

Post by Guest 2 »

admin wrote:
Wed Aug 07, 2019 12:27 pm
Lack of relevant explanation and details will guarantee that you are ignored. Tough love!
Sorry, I was a bit in a hurry.

I am talking about this part of SMDegrain.avsi:

Code: Select all

# SMDegrain prefilters
 
function SMDegrain_prefilters (clip input, int "prefilter", bool "chroma", int "Chr", int "Chr2", int "bug_wa", bool "lsb", bool "lsb_in", bool "Interlaced", val "if5", int "pel", String "device_type", int "device_id", int "d", int "a", bool "slices", bool "planar", clip "inputP", clip "input8", clip "input8y", clip "inputY", val "input8h", float "h", String "knlm_params", String "cplace")
{
Interlaced   = Default( Interlaced  ,false)
slices       = default(slices, true)
if5          = Default( if5  ,interlaced ? (GetParity(input)                            ? true : false) : nop())
lsb_in       = Default( lsb_in  ,false)
lsb          = Default( lsb     ,lsb_in)
pel          = default( pel, (input.width () > 1099 ||  input.height() > (lsb_in ? 1199 : 599)) ? 1 : 2 )
sisphbd      = AvsPlusVersionNumber > 2294
chroma       = default( chroma, true)
planar       = Default( planar , input.isyuy2())
prefilter    = Default( prefilter, 3)
cplace    = Default( cplace, "mpeg2")
 
Chr          = Default(Chr,     chroma ? 3 : 1)
Chr2         = Default(Chr2,    chroma ? 3 : (prefilter==3 ? 2 : 1))
avs26        = !(VersionNumber() < 2.60)
 
Assert(!(!defined(inputP) && prefilter==-1), "prefilter must be between 0~4: "+string(prefilter))
lsb_native = sisphbd ? !(Input.BitsPerComponent() > 8 && (lsb)) : true
sisphbd ? Assert(lsb_native, "lsb hack is not Compatible with native high bit depth" ) : nop()
 
# Input preparation for: LSB_IN, Interlacing, Planar and MSuper optimization when pel=2
 
inputY  = defined(inputY )                    ? inputY  : planar      ? (lsb_in   ? Dither_YUY2toPlanar16(input)         : Interleaved2planar(input))                           : input
 
inputP  = defined(inputP )                    ? inputP  : !interlaced ? (pel == 2 ? inputY.AssumeFrameBased()            : inputY)                                             : \
                                                                        (if5      ? inputY.AssumeTFF().SeparateFields()  : inputY.AssumeBFF().SeparateFields())
 
input8h = defined(input8h) && isclip(input8h) ? input8h : lsb_in      ?             inputP. Ditherpost(mode=6, slice=slices)                                                    : nop()
input8y = defined(input8y)                    ? input8y : planar      ? (lsb_in   ? input8h.Dither_YUY2toInterleaved()   :  inputP)                                             : inputP
input8  = defined(input8 )                    ? input8  : lsb_in      ? (planar   ? input8y.Interleaved2planar()         : input8h)                                             : input8y
 
inputd  = (prefilter == 3 || prefilter == 4)  ? Interlaced ? if5 ? input.AssumeTFF().SeparateFields() : \
                                                                   input.AssumeBFF().SeparateFields() : \
                                                             input : nop()
 
bug_wa    = defined(bug_wa) ? bug_wa : interlaced && planar && chroma && !avs26 ? 2 : Chr # bug: crash prevention workaround
 
# The mt_merge() line for prefilter=3 should be swapped with a high bitdepth variant (Dither_merge16_8() ?) due to a 1 point limited range
# in both range ends, but then it won't work with planar sources. This isn't as critical since we are only trying to find motion vectors.
                     (prefilter==-1) ?  inputP                                                                                                                                      : \
                     (prefilter==0)  ?  input8.MinBlur(0,Chr,planar)                                               : \
                     (prefilter==1)  ?  input8.MinBlur(1,Chr,planar)                                               : \
                     (prefilter==2)  ?  input8.MinBlur(2,Chr,planar)                                               : \
                     (prefilter==3)  ?  (!planar && lsb ? Dither_merge16_8( inputd.Dfttest(sstring="0.0:4.0 0.2:9.0 1.0:15.0",tbsize=1,u=chroma,v=chroma,lsb=true,lsb_in=lsb_in,quiet=true), lsb_in?inputP:inputP.Dither_convert_8_to_16(),                                \
                                                                   lsb_in?inputP.Dither_lut16("x 4096 < 65535 x 19200 > 0 65535 x 4096 - 4.338916843220339 * - ? ?",u=1,v=1).Ditherpost(mode=6, slice=slices, u=Chr,   v=Chr)                                           \
                                                                         :inputd.mt_lut(      "x 16 < 255 x 75 > 0 255 x 16 - 255 75 16 - / * - ? ?",u=1,v=1), luma=chroma,                       u=Chr2,  v=Chr2)                                                       : \
                                 avs26 && planar && lsb ? Dither_merge16_8( inputd.Dfttest(sstring="0.0:4.0 0.2:9.0 1.0:15.0",tbsize=1,u=chroma,v=chroma,lsb=true,lsb_in=lsb_in,quiet=true).ConvertToYV16(), lsb_in?inputP:inputd.ConvertToYV16().Dither_convert_8_to_16(),                                \
                                                                   lsb_in?inputP.Dither_lut16("x 4096 < 65535 x 19200 > 0 65535 x 4096 - 4.338916843220339 * - ? ?",u=1,v=1).Ditherpost(mode=6, slice=slices, u=Chr,   v=Chr)                                           \
                                                                         :inputd.ConvertToYV16().mt_lut(      "x 16 < 255 x 75 > 0 255 x 16 - 255 75 16 - / * - ? ?",u=1,v=1), luma=chroma,                       u=Chr2,  v=Chr2).ConvertToYUY2().Interleaved2planar(!chroma)                                                       : \
                                           avs26 && planar ? mt_merge     (        Dfttest(!lsb_in?inputd:input8y,sstring="0.0:4.0 0.2:9.0 1.0:15.0",tbsize=1,u=chroma,v=chroma,dither=1).ConvertToYV16(),!lsb_in?input8y.Planar2Interleaved(!chroma).ConvertToYV16():input8y.ConvertToYV16(),                                                   \
                                                                          input8.Planar2Interleaved(!chroma).ConvertToYV16().mt_lut(      "x 16 < 255 x 75 > 0 255 x 16 - 4.322033898305085 * - ? ?",u=1,v=1), luma=planar?false:chroma,          u=bug_wa,v=bug_wa).ConvertToYUY2().Interleaved2planar(!chroma)                                                    : \
                                                     avs26 ? mt_merge     (Dfttest(inputd,sstring="0.0:4.0 0.2:9.0 1.0:15.0",tbsize=1,u=chroma,v=chroma,dither=1),input8,   \
                                                                          input8.mt_lut("x 16 scalef < range_max x 75 scalef > 0 range_max x 16 scalef - range_max 75 scalef 16 scalef - / * - ? ?",use_expr=2,u=1,v=1), luma=chroma, cplace=cplace, u=chr,v=chr)                                                   : \
                                                             mt_merge     (planar ? Dfttest(!lsb_in?inputd:input8y,sstring="0.0:4.0 0.2:9.0 1.0:15.0",tbsize=1,u=chroma,v=chroma,dither=1).Interleaved2planar(!chroma)                          : \
                                                                                    Dfttest(!lsb_in?inputd:input8 ,sstring="0.0:4.0 0.2:9.0 1.0:15.0",tbsize=1,u=chroma,v=chroma,dither=1),input8,   \
                                                                          input8.mt_lut(      "x 16 < 255 x 75 > 0 255 x 16 - 4.322033898305085 * - ? ?",u=1,v=1), luma=chroma,          u=bug_wa,v=bug_wa))                                                   : \
                     (prefilter==4)  ?  planar ? inputd.SMDegrain_KNLMeansCL(lsb=lsb, lsb_in=lsb_in, device_type=device_type, device_id=device_id, chroma=chroma, h=h, d=d, a=a, knlm_params=knlm_params).Interleaved2planar(!chroma) : \
                                                 inputd.SMDegrain_KNLMeansCL(lsb=lsb, lsb_in=lsb_in, device_type=device_type, device_id=device_id, chroma=chroma, h=h, d=d, a=a, knlm_params=knlm_params) : \
                                         Assert(false,    "prefilter must be between -1~4: "+string(prefilter))
}
And this above all:

Code: Select all

# SMDegrain_KNLMeansCL
 
function SMDegrain_KNLMeansCL (clip input, String "device_type", int "device_id", bool "chroma", bool "lsb", bool "lsb_in", float "h", int "d", int "a", String "knlm_params")
{
d            = Default( d ,0)
a            = Default( a ,1)
h            = Default( h ,7.0)
deviceid     = Default( device_id ,0)
knlm_params  = default(knlm_params, "")
chroma       = Default( chroma  ,true)
lsb_in       = Default( lsb_in  ,false)
lsb          = Default( lsb     ,lsb_in)
 
                                              sisphbd = AvsPlusVersionNumber > 2294
                                              fullchr = sisphbd ? input.is444() : input.isyv24()
                                              chr420  = sisphbd ? input.is420() : input.isyv12()
                                              nochr   = sisphbd ?   input.isy() : input.isy8()
                                              chrlsb  = chroma && !fullchr && !nochr
                                              NL_in   = lsb && !lsb_in ? input.Dither_convert_8_to_16() : input
                                              cnl     = chrlsb ? "Y" : input.isrgb() ? "auto" : chroma ? "YUV" : "Y"
 
NL_in = !chrlsb && input.isyuy2() ? NL_in.converttoyv16() : NL_in
 
                               chrlsb ? eval("""
                                             # In a more lucid state I could probably have laid out this block much better... or not...
 
                                             NL_W    = width(NL_in)
                                             Uclip   = sisphbd ? ExtractU(NL_in) : UToY8(NL_in)
                                             Vclip   = sisphbd ? ExtractV(NL_in) : VToY8(NL_in)
                                             NL_lsb  = (chr420 ? StackVertical(  lsb ? StackVertical(Dither_get_msb(uclip),Dither_get_msb(vclip)) : uclip,\
                                                                                 lsb ? StackVertical(Dither_get_lsb(uclip),Dither_get_lsb(vclip)) : vclip) : \
                                                                 StackHorizontal(uclip,vclip))
 
                                             nlc     = StackHorizontal(sisphbd ? ConvertToY(NL_in) : ConvertToY8(NL_in),NL_lsb)
 
                                             nlc     = Eval("nlc.KNLMeansCL(D=d, A=a, h=h,stacked=lsb_in || lsb,device_type=device_type,device_id=deviceid,channels=cnl" + knlm_params + ")")
 
                                             uvh = lsb_in || lsb ? uclip.height()/2 : uclip.height()
                                             uvw = uclip.width()
 
                                             nly = nlc.crop(0,0,chr420 ? -uvw : -(uvw+uvw),0)
 
                                             nlu = chr420 ? lsb_in || lsb ? StackVertical(Dither_get_msb(nlc).crop(NL_W,0,0,-uvh),Dither_get_lsb(nlc).crop(NL_W,0,0,-uvh)) : nlc.crop(NL_W,0,0,-uvh)                : \
                                                             nlc.crop(NL_W    ,0,-uvw,0)
                                             nlv = chr420 ? lsb_in || lsb ? StackVertical(Dither_get_msb(nlc).crop(NL_W,uvh, 0,0),Dither_get_lsb(nlc).crop(NL_W,uvh, 0,0)) : nlc.crop(NL_W,uvh, 0,0)                : \
                                                             nlc.crop(NL_W+uvw,0,   0,0)
                                             YToUV(nlu, nlv, nly)
                                            """) :   Eval("NL_in.KNLMeansCL(D=d, A=a, h=h,stacked=lsb_in || lsb,device_type=device_type,device_id=deviceid,channels=cnl" + knlm_params + ")")
 
!lsb && lsb_in ? Ditherpost(mode=6,slice=false) : last
input.isyuy2() ? converttoyuy2() : last
}
I am a script noob and totally helpless to recreate such procedures to adopt DGDenoise :|
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: CUDASynth

Post by admin »

OK, got it. I'll try to find some time to see what is feasible here.
DAE avatar
fidodkk
Posts: 4
Joined: Fri Jul 20, 2018 10:30 am

Re: CUDASynth

Post by fidodkk »

Oh a build for accessible.

I will love to play with it, when the weather gets colder here in north europe.
User avatar
hydra3333
Posts: 393
Joined: Wed Oct 06, 2010 3:34 am
Contact:

Re: CUDASynth

Post by hydra3333 »

admin wrote:
Wed Aug 07, 2019 8:29 am
CUDASynth 0.3:

http://rationalqm.us/misc/CUDASynth_0.3.rar

Make your DGI files with DGIndexNV 2053.0.0.179.
Hello. There's been new releases since DGIndexNV 2053.0.0.179 and I wonder whether 0.3 is compatible ?

And ... perhaps even maybe a CUDASynth v1.0 release say in 2020 ?

edit: I unfortunately muddied the waters over at https://forum.videohelp.com/threads/393 ... ost2565866 ... if you wished to stick your oar in to correct me, that's up to you.
PS great work all round, mate.
I really do like it here.
User avatar
Rocky
Posts: 3525
Joined: Fri Sep 06, 2019 12:57 pm

Re: CUDASynth

Post by Rocky »

0.3 should work with the current DGIndexNV. If there is a problem please advise.

Thanks for the kind words. I'll pop in over there and see what's cooking.
User avatar
Natasha
Posts: 150
Joined: Wed Nov 20, 2019 11:11 am

Re: CUDASynth

Post by Natasha »

hydra3333, you are real man for me. Would love to know you better. Send PM we make music together. Intimate theme. I'm hot, no?

your wish my command,
Natasha
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: CUDASynth

Post by admin »

Natasha, please find a dating site.
User avatar
Natasha
Posts: 150
Joined: Wed Nov 20, 2019 11:11 am

Re: CUDASynth

Post by Natasha »

Forum Mr. Big! Big boy, which site you hang at? We can hang out.
User avatar
hydra3333
Posts: 393
Joined: Wed Oct 06, 2010 3:34 am
Contact:

Re: CUDASynth

Post by hydra3333 »

I'd love to liaise with young Natty, however my liaising days have been over for about 40 years :)
Natasha is welcome to dream though !
I really do like it here.
User avatar
hydra3333
Posts: 393
Joined: Wed Oct 06, 2010 3:34 am
Contact:

Re: CUDASynth

Post by hydra3333 »

And, wishing you a Happy Christmas !!
I really do like it here.
DAE avatar
Guest

Re: CUDASynth

Post by Guest »

Merry Christmas
User avatar
Boris
Posts: 92
Joined: Sun Nov 10, 2019 2:55 pm

Re: CUDASynth

Post by Boris »

Tashie is recovering in hospital after small accident. She will be disappointed to hear your reply, hydra3333. She was thirsting for you. I send you all best Happy Christmas greetings from Tashie and myself, and I promise you an EPIC 2020. Moose and squirrel will finally meet their match. Bwahahahaha!
User avatar
Mr. Peabody
Posts: 45
Joined: Tue Dec 24, 2019 9:20 am

Re: CUDASynth

Post by Mr. Peabody »

New member here. I'm a Nobel Prize-winning scientist, a world-renowned explorer, and an Olympic gold medalist in the long jump and decathlon. I received my degree from Cambridge University. Valedogtorian, of course.

I will perform the valuable service of fact-checking and historical analysis for this esteemed forum.
User avatar
Rocky
Posts: 3525
Joined: Fri Sep 06, 2019 12:57 pm

Re: CUDASynth

Post by Rocky »

Welcome to the forum, Mr. Peabody!
User avatar
hydra3333
Posts: 393
Joined: Wed Oct 06, 2010 3:34 am
Contact:

Re: CUDASynth

Post by hydra3333 »

Boris wrote:
Tue Dec 24, 2019 8:26 am
Tashie is recovering in hospital after small accident.
Eek, sending wishes for an easy recovery through the Christmas ether ... and may Father Christmas give it a little kiss to make it better.
I really do like it here.
User avatar
Boris
Posts: 92
Joined: Sun Nov 10, 2019 2:55 pm

Re: CUDASynth

Post by Boris »

Thank you, hydra3333. IV blood drip working wonders. You should visit bedside. Moose will pay for this.
User avatar
JoyBell
Posts: 16
Joined: Mon Feb 17, 2020 11:50 pm

Re: CUDASynth

Post by JoyBell »

Very interested in your CUDASynth.

I made a zoomed in crop of CUDA Synth Denoise and Sharpen vs my encoder favorite SMDegrain and LimitedSharpenFasterMod.

Comparison Pics
https://slow.pics/c/UmJUKAkF

Source:
Image

Good stuff.
DGDenoise vs SMDegrain(tr = 2, thSAD = 500)
Image
DGDenoise- much more smoothing, like it's a stronger setting than my SMDegrain Medium preset.
Image
SMDegrain- does a good job on the grain and keeps and enhances details.

DGSharpen vs LSFmod(strength = 400)
Image
DGSharpen- The grain pops and the image looks a bit more in focus.
Image
LSFmod- My LSF pic looks like I didn't apply the filter. I really might of made the mistake. :(


DGDenoise + DGSharpen vs SMDegrain and LimitedSharpenFasterMod.
Image
DGDenoise + DGSharpen- Well cleaned of grain, and picture has some sharpening but lost of hair and textile textures.
Image
SMDegrain + LSFmod- Well cleaned of grain without loss of textiles and hair, picture looks clearly sharper as if in better focus.

Very good work here by Mr. DG!
I would rate these better than KNLMeansCL and WarpSharp. That being said, SMDegrain and LSF remain the tools to beat from what I can see.
User avatar
JoyBell
Posts: 16
Joined: Mon Feb 17, 2020 11:50 pm

Re: CUDASynth

Post by JoyBell »

These cropped screens are from full CRF 22 1080p encodes of the clip.

70 Midway.2019.1080 1m46s DGHDRtoSDR
Image
70 Midway.2019.1080 1m39s DGHDRtoSDR DGDegrain DGSharp
Image
70 Midway.2019.1080 1s47m DGHDRtoSDR SMDegrain LSF
Image
User avatar
JoyBell
Posts: 16
Joined: Mon Feb 17, 2020 11:50 pm

Re: CUDASynth

Post by JoyBell »

I tried actually using the DGSharp and unfortunately it just seemed to bring out the dither more than anything else. I think most sharpens have a function to ignore grain and dither as sharping those is sub-optimal in most cases.
User avatar
hydra3333
Posts: 393
Joined: Wed Oct 06, 2010 3:34 am
Contact:

CUDASynth

Post by hydra3333 »

Just wondering ... is cudasynth still a thing, or more like an experiment that has run it's course ?

Cheers
User avatar
Rocky
Posts: 3525
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

Until the video community starts writing CUDA filters in significant numbers, there is no space for CUDASynth. CUDASynth is just a technology to link CUDA filters without requiring PCI transfers. We hope for increased traction for CUDA in the video community. Over at Doom9 pinterf has recently started to get interested in CUDA.
User avatar
hydra3333
Posts: 393
Joined: Wed Oct 06, 2010 3:34 am
Contact:

CUDASynth

Post by hydra3333 »

thanks. nice.
DAE avatar
Guest 2
Posts: 903
Joined: Mon Sep 20, 2010 2:18 pm

CUDASynth

Post by Guest 2 »

It seems that AVS+ is about doing the big jump to support CUDA.

Are you planning something?
User avatar
Rocky
Posts: 3525
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

Not yet, just waiting to see what it will be.
User avatar
Rocky
Posts: 3525
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

Got my 3090 tracker with alerts running for days. Twice I got the alert and within seconds went to the seller site and tried to buy. But both times they were already out of stock. This is getting to be very annoying. By the time I can actually buy one there'll be 4090 and 5090. :evil:
Post Reply