Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
#1 | Link |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
Zsmooth - cross-platform smoothing functions written in Zig!
Hello Doom9!
After being part of this community for many years, I finally got the time to start writing my own plugins, and so today I present something I've been working on for the past few months. Zsmooth - Cross-platform smoothing functions written in Zig Current Version: 0.14 Currently implemented functions
All functions take 8-16bit integer, and 16-32 bit float clips, in RGB, YUV, and GRAY formats. Parameter scaling is optional, based on a 'scalep' parameter, so you can choose to pass 0-255 values or get more specific. Every function has SIMD support on x86_64 and ARM processors, thanks to the power of Zig's Vectors. This means that every function should be as fast, if not faster than existing plugins, and it should be fast everywhere. Note: 16bit float support is a work in progress. All functions take it, but some are very slow due to some compilation bugs. I'll be working on ironing these out over time. Please feel free to test these functions out and report back! I've been testing these myself over the past few months, and I *think* I've ironed out the bugs, but please report back any issues that you find, or major drops in performance compared to existing plugins. Also, I've only been testing on Linux, so I'm honestly curious to hear how things are on Windows and Mac. Benchmarks https://github.com/adworacz/zsmooth/.../BENCHMARKS.md Bugs / Feature Requests Feel free to either open an issue on Github or post in this thread. https://github.com/adworacz/zsmooth/issues Downloads All releases are on Github. I've provided pre-compiled binaries for Windows, Mac and Linux, with the latter offering x86_64 and aarch64 (ARM) binaries. https://github.com/adworacz/zsmooth/releases
__________________
Flawless Media - Digitizing and Restoration Zsmooth - Cross-platform smoothing for Vapoursynth Zscene - Scene change detection for Vapoursynth Old Site:Adubvideo Last edited by Adub; 16th November 2025 at 20:36. Reason: Version 0.14 |
|
|
|
|
|
#2 | Link |
|
Registered User
Join Date: Dec 2020
Posts: 100
|
wow, incredible work!
Your code will help me a lot, since i'm still a beginner in the dev world, I was working with RemoveGrain too, only @Vectors code, but i was stuck at mode 20 hahaha If you happen to use Discord, we have a vapoursynth devs server: https://discord.gg/XTpc6Fa9eB it would be great to have you there |
|
|
|
|
|
#3 | Link |
|
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,647
|
Interesting. I would however request that you don't spread TemporalSoften(2) around. That function was only ever used with the maximum thresholds and was simply a cargoculted discount AverageFrames. Promotes bad scripts.
But very interesting to see zig used for things.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
|
|
|
|
#4 | Link |
|
Registered User
Join Date: Dec 2020
Posts: 100
|
About printf memory leak, you can avoid this by using bufPrintZ instead of allocPrintZ.
I've added a function to the zig module and updated the example, so you can import from vsh now. |
|
|
|
|
|
#5 | Link |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
@Julek - Thank you for your comments, and help in creating the vapoursynth-zig project. It definitely made my work a lot easier, and I'm happy to contribute as well. I just opened a few issues that I noticed while looking at the code, and I can submit a PR with fixes once I get a spare moment.
Also, good call on the memory leak thing. I'll look at updating. @Myrsloik - Good to know on TemporalSoften / AverageFrames. I have seen some uses of TemporalSoften with the threshold, but I'll keep in mind that AverageFrames exists as well. And yeah, Zig is a surprisingly excellent language for video processing filters, in my opinion. The C-interop, compile-time language execution, native SIMD vector support, comptime type passing, f16 support, etc etc etc make for a really nice development environment. |
|
|
|
|
|
#6 | Link |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
FYI - Selur has already found a bug (thank you!) in TemporalMedian:
https://github.com/adworacz/zsmooth/issues/1 I suspect I know the issue, and will be testing/fixing over the next day or so. |
|
|
|
|
|
#7 | Link | |
|
Registered User
Join Date: Dec 2020
Posts: 100
|
Quote:
I'll wait for your PRs ![]() A question about the benchmark, how was your RGVS compiled? Is the SSE code active? Because in my tests the zig version has pretty much the same speed. My RGVS code in zig was also getting the same performance as the c++ plugin with SSE. |
|
|
|
|
|
|
#8 | Link |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
Version 0.3 is up: https://github.com/adworacz/zsmooth/releases/tag/0.3
This should fix all stride + vector related handling (turns out I had a few bugs wrt non-mod 32 handling). |
|
|
|
|
|
#9 | Link | |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
Quote:
I'll work in a PR with fixes to vapoursynth-zig in the next day or so. As for my RG benchmarks - I simply compiled my version locally using "zig build -Doptimize=ReleaseFast". I've noticed that the performance difference can really depend on the CPU in use. On my laptop I see a massive speedup, but on my desktop the performance difference between Zsmooth's version of RG and RGVS seems negligible. Floating point is still generally faster with Zsmooth due to using single precision vs RGSF's double precision. |
|
|
|
|
|
|
#10 | Link | |
|
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,843
|
Quote:
Last edited by Selur; 27th April 2024 at 20:53. |
|
|
|
|
|
|
#11 | Link |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
Version 0.4 is up: https://github.com/adworacz/zsmooth/releases/tag/0.4
Should have fixes for all bit depths, and now uses Zig slices for array bounds checking in debug mode. Also added unit tests to assert the stride handling behavior as a double check. I've tested with RGB, YUV420, YUV422, and YUV444, and I can't replicate any more artifacts (green pixels or black bars). Hopefully everything is fixed this time. Thank you for bearing with me as I iron out these kinks. |
|
|
|
|
|
#13 | Link |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
Version 0.5 is out with the last of the stride fixes - https://github.com/adworacz/zsmooth/releases/tag/0.5
Big thank you to NSQY, Selur, and Julek for testing and helping to diagnose the issue. |
|
|
|
|
|
#14 | Link |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
Minor update: I'm working on a few updates for 0.6, mainly adding DegrainMedian support (mode 0 is *much* faster than the existing plugin), along with some minor dependency updates and Zig version bump.
After that I'll work on adding Dogway's IQMV (Inter Quartile Median) filters, and then maybe CCD after. I still need to finish the RemoveGrain functions (Repair and Cleanse) as well. |
|
|
|
|
|
#15 | Link | |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
Version 0.6 is now available, including prebuilt binaries for x86_64 and aarch64 Mac - https://github.com/adworacz/zsmooth/releases/tag/0.6
Quote:
|
|
|
|
|
|
|
#17 | Link |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
Just so I don't pollute https://forum.doom9.org/showthread.php?t=186119, bit of a status update:
1. I've started my work on implementing Repair. It's going extremely well, with some pretty insane speedups over the older plugins, especially RGSF. We're talking a frequent 10-20x improvement. Again, not a typo. 2. Community members have requested that I change how Repair (and potentially RemoveGrain...) is implemented. Prior implementations of RG/Repair simply copy the edge pixels (so first/last row/column) to make the underlying algorithms easier to write. Since those plugins were written an alternative technique has arisen for filling in the requisite information for edges, which is "mirroring". I'll be experimenting with this approach as it makes sense and I should be able to implement it in the next version or two. More details can be found on the Github issue: https://github.com/adworacz/zsmooth/issues/6 3. As part of investigation into #2, I've uncovered some more speedups in RemoveGrain as part of a refactor I started. I'm seeing a good 10%+ improvement in RG speeds (and I think I'm bottlenecking on something else now so it could be even higher). |
|
|
|
|
|
#20 | Link |
|
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,753
|
TemporalRepair seems reasonable. AutoLevel seems outside the scope of Zsmooth in particular, but I'll consider it for another plugin at some point.
I've added TemporalRepair to a pinned issue on Github, so feel free to up vote or add others there: https://github.com/adworacz/zsmooth/issues/7 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|