-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Artifacts using TemporalMedian #1
Comments
Fascinating - thanks for the bug report. I'll take a look at what could be causing this in the next few days.
|
I have a sneaking suspicion that I already know what the issue is (and that's my handling of |
Yes, I just tested it and this is a stride problem, VS won't always leave stride == width, it depends on the type of memory alignment, in this case the video is 720 and the stride 736. |
Solid, thank you for confirming @dnjulek . I'll update all of my functions to respect |
Nice, looking forward to a fixed version. |
Selur, please try the 0.3 release, which should have everything fixed now: https://github.com/adworacz/zsmooth/releases/tag/0.3 |
Bugger okay, thank you for confirming. I also found that it crashes with non 8-bit content as well, so I'll work on a new round of fixes. |
For non 8-bit stride you need to divide it by |
If you don't want to divide, sekrit-twc usually casts the ptr back to u8 and always makes the ptr shift as u8. |
Yup, that's exactly the solution I came to myself. Since all divisions are powers of 2, I've got no problems using division since the compiler will optimize it all to right shifts anyways. @Selur - I've got version 0.4 up now: https://github.com/adworacz/zsmooth/releases/tag/0.4 I tested it locally with TemporalMedian (radius = 1) on RGB, YUV420, YUV422, YUV444, in 1920x1080 and 720x480 and I get no black bars anywhere. I even added unit tests to assert the stride handling behavior. So fingers cross all of the artifacts/black bars issues should be fixed now. |
Doesn't work either.
|
Just to show that it's not just mpeg2 content: |
I've just build from source and the error doesn't happen, maybe the dll is wrong? |
ah, you're using avx512, I can't test it here |
I tested both and used: Here's the script I use for the comparision:
|
To be sure it's nothing else I did, I simplified the script:
|
python_O54GocB8t4.webmI've just done another test, the previous one was with Linux from source, now I've done it in Windows with 0.4/zsmooth.avx2.dll, no errors. |
Okay, so it must be something related to my setup. |
Yes, CRC64: E3D6E45A3C709BF6 |
Do you know a tool which calculates CRC64 on Windows?
|
found one: |
Redownloaded |
This is what I have on my end, which seems to match your original sha512, Selur sha256 sha512 |
I'll try testing with your sample |
Hmmm, I'm also seeing no issues at all using your test sample. I'm using version 66 of Vapoursynth - what version are you using? Used script: import vapoursynth as vs
core = vs.core
clip = core.lsmas.LibavSMASHSource("/home/adub/Downloads/sample_mpeg4.mp4")
zsmooth = clip.zsmooth.TemporalMedian(radius=1)
clip = clip.text.Text("Original")
zsmooth = zsmooth.text.Text("Filtered")
stacked = core.std.StackHorizontal([clip,zsmooth])
stacked.set_output(0) |
7-zip, right-click -> 7-zip has all the options. |
I'm using R65 since some of the torch stuff I use isn't available for Python 3.12. |
Name: zsmooth.avx2.dll |
This is very strange. It's almost like the it's not processing all planes, or getting the wrong width for different planes. I think I'm going to have to put a debug build together that spits out some of this information so we can see what the plugin is working with. I have no idea why it would be any different on your machine, since it should be using the same function calls in Vapoursynth for all of them. It is interesting that the output looks a little different in VS 66 - there's some of the original image that's come through, but it's like one of the planes wasn't operated on properly. |
I can reproduce this with the 0.4 release DLLs (both avx2 and avx512), however I cannot repo when compiling af9c956 with 0.13.0-dev.46+3648d7df1 Here's my env Windows 11
Minimal test case: import vapoursynth as vs
core = vs.core
clip = core.std.BlankClip(None, width=720, height=480, format=vs.RGB24, color=[127]*3)
zsmooth = core.zsmooth.TemporalMedian(clip, radius=1)
zsmooth.set_output() |
Oh realllyyy??? That’s fascinating. I wonder if it’s a zig version difference (I’m using 0.12), or something else. Or are you saying that the issue was created in DLL 0.4? @NSQY - would you mind trying a rebuild using 0.12 with the latest commit? I want to track down if it’s a zig version thing or a bug introduced in 0.4. |
It might also be a cross-compilation issue, since I’m compiling the binaries on a Linux machine. Zig should be doing everything right for cross-compilation, but we’ll have to see. I’ll look into setting up a Windows VM so I can attempt to replicate the problem myself. |
I'm saying that I can only reproduce with whatever was used to compile the provided .dll files, so either they're based off a different commit or something went wrong in the compile. I can reproduce the original problem with test512.webm |
|
I wrote a basic script that just checks the PlaneStatsAverage of all BlankClip frames and ensures they're all the same. Looks like 5d40eff and newer are ok?
|
Okay, this is super helpful testing. The DLLs were compiled with this script, and cross compilation happens at this line specifically: Line 6 in 992421d
This was done on my Intel laptop, running Linux. I’m going to set up a VM to see if I can get this issue reproduced. Meanwhile, it sounds like the workaround is simply for Windows users to compile their own DLLs from source on the machines they’re going to run the DLL on. |
I will try cross-compiling from my WSL Arch image. zig-windows-x86_64-0.13.0-dev.46+3648d7df1 errors at the same spot btw
Thankfully zig makes this trivial 😊 |
992421d .dll built with
|
This is great @NSQY ! I was starting to wonder the same thing, if it's related to the If you run I'm starting to suspect that there's something wrong with the chosen SIMD vector lengths, and I'm wondering if it's specific to the CPU and not the operating system. Both you and Selur are running 7950X's, which have AVX512 and would use a 64 element wide SIMD vector for 8-bit content (for 512 bits). BUT the In theory, this shouldn't matter, but maybe I have a bug in my math somewhere or for some reason running 256bit vectors on a machine that supports 512bit vectors may be causing some kind of issue. |
|
Excellent, we’re really narrowing things down now. I have a suspicion on the source of the issue. I’ll try and get a potential fix together tonight. |
I have a quick potential fix up in a branch here: 389e11e The pertinent one-line change is here: 🤞 that's the final piece. I'll work on getting all other filters updated tonight if that proves to be the solution. |
I was checking this part of the code just now, I thought it would be here too. |
They produce the exact same code after compilation. See this Compiler Explorer (Godbolt) link with both implementations. One jumps to other because they are identical. |
Okay, I've committed potential fixes to Temporal Soften and FluxSmooth as well. sha256
Please try this version of the DLL: |
That one seems to work for me. 👍 |
I think with this we're good to go. 992421d Summary
Summary
626ade0 Summary
|
Nice, looking forward for the next release. 👍 |
Am I missing something?
Using:
with both the avx2 and the avx512 version on Windows11, Ryzen 9 7950X, Vapoursynth R65.
Artifacts change depending on the input color space.
This only happens with some files.
This does not happen with all files, but a bunch, I attached a small sample file
![grafik](https://private-user-images.githubusercontent.com/843640/325687615-b106c65d-df2a-4928-97c6-33d4164e9c7b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExNTM1NDYsIm5iZiI6MTcyMTE1MzI0NiwicGF0aCI6Ii84NDM2NDAvMzI1Njg3NjE1LWIxMDZjNjVkLWRmMmEtNDkyOC05N2M2LTMzZDQxNjRlOWM3Yi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcxNlQxODA3MjZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zYmQ4NWU5NGI3OTg0ZmZjNDJhMjExZGM0MTI1MmRmMzIyOWFlMzJiODc1YjgwMTE1MDM3ZTQ5YTg4Njk3MjVlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.bFcx3cfq50jHsoH2aCc5VrKO3gaV884dsD3yUCaREKc)
example.zip
no clue what the cause happens with different files with different resolution and color spaces.
The text was updated successfully, but these errors were encountered: