CUDASynth

These CUDA filters are packaged into DGDecodeNV, which is part of DGDecNV.
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

hydra3333 wrote:
Mon Apr 01, 2024 1:07 am
Wondering, the original video author may have intended for some type of shade graduation left to right to remain apparent, perhaps a squirrely monster lurks in the shadows or something, and my tired old eyes don't quite perceive the result like that or I didn't properly discern your intent.
Sure, it depends on the use case. Think of it as the two extremes of possible processing of that image. There is this thing called lerping that allows you to generate any intermediate between the two extremes:

https://stackoverflow.com/questions/198 ... using-lerp
I guess you are saying that's doable and depends on some parameters (curves?) one specifies in the call. I must read the documentation you provided in the release.
You could use lerping to make an acceptable intermediate. But if you are not interested in spatially equalizing things at all, then you wouldn't use a windowed filter.
Would it be possible to post the clip with the stones, for us to play with?
The original is an image that you can turn into a clip with ImageSource() or directly in VirtualDub. Right click and 'Save image as ...' on the stones image here:

https://www.rationalqm.us/winhistogram.html

Note that this filter's 'Strength' parameter just controls a lerping of the original and fully filtered outputs.

Hope you had a cracker of an Easter, m8!
User avatar
hydra3333
Posts: 413
Joined: Wed Oct 06, 2010 3:34 am
Contact:

CUDASynth

Post by hydra3333 »

Rocky wrote:
Mon Apr 01, 2024 1:47 pm
Hope you had a cracker of an Easter, m8!
And you ! :D
Cheers
Rocky wrote:
Mon Apr 01, 2024 1:37 pm
You'd start with some other source filter, then add the proposed DGFilters() filter.
...

here are two advantages: 1) different source filters could be used (while retaining the advantages of CUDASynth), and 2) I wouldn't have to individually implement standalone filters; I'd just have the one do-it-all DGFilters().
Yes, that seemed like a beaut concept.
I gather ?vapoursynth author? seems to be developing https://github.com/vapoursynth/bestsource which I guess some may consider using for odd formats or perhaps "real" vfr->cfr if required, so that approach would be great.
I really do like it here.
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

For sure. Bit of chutzpah there to name your tool "BestTool" but perhaps it's a bit of tongue-in-cheek. Wasn't that Ron Jeremy's trademark? ;)

So yeah, and it won't be hard to implement. Just make an alias DGFilters for DGSource and have it pass a null dgi string. Then, in GetFrame, if the dgi was null, instead of doing source filter stuff we do normal filter stuff plus uploading/downloading the frame at the start and end of the chain. Then the rest of the code doesn't know or care whether it's DGSource or DGFilters. Let's see. After that initial implementation, we'll have greatly reduced development/testing/maintenance going forward.

Off to make a DGMPGDec release...
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

I got rid of my own points file format and replaced it with the GIMP curve file format. GIMP is free so it's ideal to create and export curve files. I'll need a ranges file, though, to do frame ranges.
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

My solution is working great for the luma curve but there are issues with color. Now be aware that since this is going into DGSource() it must and only accepts YUV (aka YCbCr). So I thought, erm, all I have to do is convert to RGB, apply the RGB curves and convert back to YUV. What's the big deal? Well, the deal is that, believe it or not, not all legal YUV values generate legal RGB. I saw some colors producing RGB values of up to -10 (for 8-bit). Yes, negative! OK, no problemo, just clip to 0-255. That's easy but the result is horrible. Ya know, people don't just clip for HDR to SDR tone mapping, and for good reason.

Hmm, I thought, Vapoursynth-Curve accepts both YUV and RGB, let's see what they do. Oy, ya know what they do? When the input is YUV, the 'red' curve controls Y, the 'green' controls U, and the 'blue' controls V. Yuck. Nobody in their right mind would want or be able to intuitively tweak U and V directly. We want to do things like up the redness a little, so we have to act in RGB space.

But fear not, I have some ideas to make the scheme work. I want to do some experiments before describing them, because they could be stupid and I don't want to :oops: myself. But let's see.
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

Hehe, good day at the office. I discovered that it wasn't the RGB clipping that caused the horrible result. It was a widdle oversight in my code. Now the concept of YUV->RGB->apply curves->YUV is working great. So it's onward and upward! Still need to implement:

* specification of matrix 601/709/2020 [DONE]
* 16-bit support [DONE]
* allow drawing of master (Y), r, g, or b curves [DONE]
* presets
* frame ranges
* port to CUDASynth framework

Sherman has been busy on his radios. He just finished a nice Zenith H723Z2 AM/FM radio. It gets MeTV FM real good so mission accomplished. A Zenith X337 AM/FM is arriving shortly. That is the last manufactured Zenith tube AM/FM radio. And BTW, Zenith was headquartered right here in Chi-town. We already have a wooden and a bakelite AM/FM. The X337 is wooden but with a plastic front, call it a hybrid. It's supposed to have audio on a par with the big German sets. We'll see.
User avatar
hydra3333
Posts: 413
Joined: Wed Oct 06, 2010 3:34 am
Contact:

CUDASynth

Post by hydra3333 »

Nice job, on both fronts.
Thank you very much.
I really do like it here.
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

OK, matrices, 16-bit, and drawing are done. I'll probably do the CUDASynth stuff before presets and frame ranges.

But first, I have noticed that GIMP's curve drawing is not just a simple cubic/hermite spline. It's some kind of tensioned piecewise linear thing. I could check the source code but I found something interesting called Chaikin's algorithm:

https://www.cs.unc.edu/~dm/UNC/COMP258/ ... orithm.pdf

I'm going to implement that, but instead of the 25/75% locations I'll use 10/90% to stay closer to the polyline. Probably 2 or 3 iterations will be enough. I don't like the typical splines because they can deviate too much from the polyline defined by the configured points. Splines can be unstable/unpredictable in some cases, too. This approach will be pretty close to what GIMP does, so the GIMP GUI will be useful for setting up curves for our filter.

Technical note: Chaikin's algorithm with the 25/75% positions is equivalent to a quadratic uniform B-spline curve when the number of iterations is large. We'll use 10/90% to cling to the polyline a little tighter. We don't mind linear segments because it's only the vertices that can cause banding. But we eliminate that by smoothing out the vertices.

https://www.cs.unc.edu/~dm/UNC/COMP258/ ... nement.pdf
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

I added a mode "slinear" that does Chaikin 10/90% with 2 iterations and it looks great, if I do say so myself. ;)

So we have linear, slinear, cubic, and hermite. Maybe for fun I'll see what GIMP is doing.

EDIT: GIMP uses a cubic bezier. The code is complex so currently I don't see the need to match that precisely.

https://blog.maximeheckel.com/posts/cub ... to-motion/
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

I've started CUDA-izing it.

But right now it's time-out for the final round of the chess world championship candidates tournament. It's gonna be either the Indian Gukesh, the Russian Nepomniatchi, or one of the Americans Nakamura or Caruana. I'll go out on a limb (not really so risky for a squirrel!) and predict that Gukesh wins it.
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

Congrats to Gukesh! India versus China will be an epic encounter.
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

Sorry guys, I'm kinda fixated on getting the Curves filter done. Don't worry, I'll get to the other stuff in good time.

So, OK, I have the framework done (JIT, upload tables to GPU, etc.) and luma working in CUDA. I have to implement chroma and Vapoursynth. It's going to be blazingly fast compared to (say) Vapoursynth-Curve, especially for UHD. When that's done I'll make a test release and then we move on to automaticity, presets, and frame ranges.

Also, I've been helping Sherman with his Zenith X337 radio. He's doing electrical and I'm doing cosmetics.
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

Chroma is working. On to Vapoursynth.
User avatar
Sherman
Posts: 633
Joined: Mon Jan 06, 2020 10:19 pm

CUDASynth

Post by Sherman »

Sorry, Rocky, I tried to hand rub it but it's been very cold and humid so it wasn't ready for that. What now?
Sherman Peabody
Director of Linux Development
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

Just leave it alone for 72 hours. Then we'll hit it with some 0000 steel wool and put on a second light coat of poly. After that, DO NOT TOUCH it for a whole week. Then some furniture wax and buffing. I like that pecan stain. Great job on the electrical. It sounds amazing.
User avatar
Sherman
Posts: 633
Joined: Mon Jan 06, 2020 10:19 pm

CUDASynth

Post by Sherman »

Thanks, Rocky, you're the squirrel! Can I have it in my bedroom?
Sherman Peabody
Director of Linux Development
User avatar
Mr. Peabody
Posts: 46
Joined: Tue Dec 24, 2019 9:20 am

CUDASynth

Post by Mr. Peabody »

As long as you promise to turn it off by 10:00pm every night.
User avatar
Sherman
Posts: 633
Joined: Mon Jan 06, 2020 10:19 pm

CUDASynth

Post by Sherman »

It's a promise. Pinky!

Guys, the Eico 368 sweep generator came in today. I'm gonna use it for FM alignment. Stay tuned. That's a pun, get it?
Sherman Peabody
Director of Linux Development
User avatar
Curly
Posts: 768
Joined: Sun Mar 15, 2020 11:05 am

CUDASynth

Post by Curly »

I don't get it.
Curly Howard
Director of EAC3TO Development
User avatar
Britney
Posts: 153
Joined: Sun Aug 09, 2020 3:24 pm

CUDASynth

Post by Britney »

Me too.
User avatar
Sherman
Posts: 633
Joined: Mon Jan 06, 2020 10:19 pm

CUDASynth

Post by Sherman »

You guys aren't smart enough.
Sherman Peabody
Director of Linux Development
User avatar
Curly
Posts: 768
Joined: Sun Mar 15, 2020 11:05 am

CUDASynth

Post by Curly »

Albert said it's all relative so get over yourself, kid.

Hey Rocky, instead of building any infrastructure/code to support presets, why not just have some pre-defined CRV files with appropriate names? Then that would fit well with the frame range implementation.
Curly Howard
Director of EAC3TO Development
User avatar
Rocky
Posts: 3754
Joined: Fri Sep 06, 2019 12:57 pm

CUDASynth

Post by Rocky »

I like that idea, thank you. Less work!

As soon as I complete refinishing on Sherman's Zenith C845 I'll get back to coding.
User avatar
Sherman
Posts: 633
Joined: Mon Jan 06, 2020 10:19 pm

CUDASynth

Post by Sherman »

Thanks, Rocky, you're the squirrel.

I fixed up the first FM IF can (silver mica sh*t) and the storm is gone. Both sides peaked up OK with 40pF but the overall sensitivity for FM is bad, with everything in the top half of the band missing. I ordered all new tubes for it. I hope DG is OK with that. I think he'll be OK as the C845 is possibly the best ever Zenith AM/FM tube radio. Yeah, yeah, I know the X337 is amazing and I already got that working great (until 10:00pm :roll:), but the C845 is in another universe, trust me. You could make a Twilight Zone episode about it...with me as the star, of course. Curly could be the warm-up act. So when the tubes are in I'll do a full FM alignment and this baby will sing. :o

The Eico 368 has a short in the marker circuit. I think I isolated it to a bad ceramic cap. Gonna replace that and see.
It's not sweeping too, not good. OK, carry on.
Sherman Peabody
Director of Linux Development
User avatar
DG
Posts: 94
Joined: Thu Dec 31, 2020 9:55 am

CUDASynth

Post by DG »

No problem, Sherm, spend all my money before I cast off my mortal coils. Yes, and before it inflates away to nothing. At least we'll have some fine radios.
Post Reply