Repository navigation
Stream SSIMULACRA2 in C and upgrade to Zig 0.17 - #7
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SSIMULACRA2 currently writes full-frame intermediate planes and reserves scratch proportional to image area. Replace the production Zig implementation with a streaming C pipeline: decode sRGB rows, downsample directly into the next scale, convert only active XYB channels, and retain small row rings. The C loops use compiler vectorization, with no explicit Zig SIMD in the production metric.
On an Apple M5 Pro, the direct filter benchmark is 17–20% faster than the exact vapoursynth-zip 23.0.0 filter at 1080p with 1/8/16 workers and at 4K with one worker. Scratch at 1080p falls to 1.88 MiB per workspace versus upstream's 13.27 MiB, and is independent of height. The existing 4K PAM CLI comparison improves from 173.1 ms / 714.3 MiB to 92.1 ms / 116.0 MiB. x86 throughput has not been measured.
Scores deliberately use float linear samples and a more stable SSIM variance calculation. Identical inputs score exactly 100. Across all 4,341 CID22 pairs, KRCC/SRCC/PCC change from 0.708176/0.891111/0.873170 to 0.708025/0.890985/0.873013, each a difference below 0.0002. The existing PAM pair changes from 70.5898 to 70.5839.
Also migrate the build, translated C imports, Python build requirement, and simpleimgio/libspng/fcvvdp pins to Zig 0.17. Remove the previous Zig implementation and preserve the pre-existing test suite unchanged. The C, Zig, and Python error-map APIs and packed RGBA output remain compatible with existing callers. Zig 0.17 LTO is restricted to ELF targets; macOS now reports an actionable error for that option.
Validation:
Reproducible benchmark and correlation commands/results are in
tests/bench/README.md.The executable uv script
tests/bench/compare_video.pycompares both metrics on identical linear RGB video frames and exports per-frame scores and timing.