fix(libScePngEnc): honor zlib compression levels #18387
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18387"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-11-11T13:13:11Z.
What
compression_level=0still compresses PNG data because stb treats the value as a search-quality setting and raises values below 5 to 5. Use the existing bundledzlibstaticcompressor for levels 0–9, so zero produces stored DEFLATE blocks and positive levels use the requested zlib level. Keep row filtering and PNG chunk emission unchanged, and remove the unused stb writer implementation.This restores the compression-control behavior promised by #227 and follows the libpng compression-level contract and zlib API. The static zlib archive is hidden from PRX exports. The PNG targets reuse the existing zlib submodule at its current pinned revision. Compressed byte sequences change; exact native PS5 compressed bytes remain unmeasured as recorded in the existing debt entry.
Regressions check stored-block structure, LEN/NLEN, Adler32 and a multi-block stream above 65535 bytes; levels 0–9 also decode to the expected pixels with the selected filters. A separate regression calls the actual
scePngEncEncodeexport.Tested
Windows 11 Pro 10.0.26300; AMD Ryzen 9 7900X; 32 GB RAM; NVIDIA RTX 4070 Ti SUPER (unused by these codec tests). WinLibs MinGW-w64 GCC 15.2.0 r7, CMake 4.3.1, Ninja, Release.
Base reproduction:
2ecc68bda2642fbd5b4c9fb799bc1da4aa3df191. Final tested commit:887c2c6e51e6b926a773abaa43e9f15b71af1efc, based oned4b2e4cd8940464c89a40f89a092062c2203cdd.scePngEncEncodelevel-0 stored-block regressionA fresh full-project configuration used
BUILD_TESTING=ONandANYPS5_RELINKER_ONLY=OFF, with exact current submodules. The project'sconfigure_seed.pyreused compiler-probe answers from this session's identical toolchain, dependency revisions and configure-check inputs; all runtime targets were built in the new isolated build directory.All seven selected tests passed: six runtime tests and the public-header audit. Export/import-table audits of raw and NID-patched PngEnc/PngDec copies found no exported host zlib API or zlib DLL dependency. PngEnc's complete export and DLL sets equal the base; NID patching preserved export counts (15 for PngEnc, 26 for PngDec). Standalone runtime tests used the raw linked PRX; standalone NID copies were audited statically. The combined-stack probe below additionally executes NID-resolved exports.
Conventions and
git diff --checkpassed. Independent review of the complete patch found no introduced defect. Linux, macOS, console, titles and the full CTest suite were not tested.Hosted Windows job 130544673152 passed for head
887c2c6e51e6b926a773abaa43e9f15b71af1efc; its changed-test selection ranguest_png_encsuccessfully (1/1). Conventions, library portability, intake and eligibility also passed. Linux and unrelated jobs were skipped.Pre-opening
python tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch codex/fix-png-compression-level --jobs 8checked 1,987 open PR heads and reported no overlap. A separate merge-tree check with #18382 head65fa4e73c96d26721170675076e73e07aa6fe1cfalso merged cleanly: its sample-depth/background extension and this compression change are independent. Additional Cairo runtime compatibility is recorded below.Additional integration validation: current main
0effa485f96a4fcf8fef433a09cdd862c65b7767plus #18361 (2464b95fe12373ab2a4b46024b6b29390d615935), #18370 (c8388f97ab26a188bd07751a2f5ba2afce058bc6) and #18387 (887c2c6e51e6b926a773abaa43e9f15b71af1efc), composed locally as7b8bc0d80db09dee5e39bcdf5159d8b8791d9db9. A fresh full-project build passed all 10 focused PNG/JPEG runtime CTests andpublic_headers(11/11). A separate temporary PNG probe passed in fresh processes through both raw and production-NID-resolved exports with an isolated patched libc/kernel/PNG closure. It checks level-0 stored RGB/RGBA streams, literal decoded pixels, 1/7/full-image callback chunks with an error only after IEND, repeated decode without another callback and row padding. This is synthetic Windows integration coverage; no title or console run is claimed. Probe source and reproduction commands are included in #18387.Combined-stack PNG raw/NID probe
Start at the main revision above, compose the three commits, configure the full build as documented, and save this source as
build/nid_probe.cpp. Use the supported WinLibs toolchain on PATH. Each invocation runs in a separate process; the complete runtime DLL closure is staged beside the probe.Observed result in both raw and NID modes:
PASS: runtime exports, level-0 stored RGB/RGBA PNGs, literal pixels, IEND callback boundary, repeated decode, padding.Cairo compatibility validation: after reviewing the complete introduced diff
2ecc68bda2642fbd5b4c9fb799bc1da4aa3df191..65fa4e73c96d26721170675076e73e07aa6fe1cf, I three-way merged that exact #18382 head into the local three-PR validation stack. The resulting local commit is72659301b8c884f06ff5358831bf59d92e2da9c0(treea9c723b70b0efdcd79db6988a93246b41cdae132). Rebuildingguest_cairo_png_testsand the ten codec runtime targets, then addingguest_cairo_pngto the focused CTest selection above, passed all 12 checks includingpublic_headers. This exercises Cairo's 16-bit floating-point PNG outputs, whitebKGD, eight image formats, subsurfaces and callback failures with the zlib compressor. The raw and NID PNG probes also passed again against freshly copied, hash-verified rebuilt modules. Cairo changes are confined to the local validation tree; the published PNG compression patch is unchanged.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T14:58:30Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
887c2c6e51:tools/check_conventions.pyfailed;git diff --checkclean.decoder_png,decoder_png_tests,guest_png_enc_testsbuilt cleanly.decoder_png,guest_png_enc):core/Decoder/Png/src/Png.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.conventions: { ok: false }). The pull request body stripped the required template from.github/pull_request_template.md, missing all required checkboxes and mandatory sections (Depends on,Fixes,Unblocks,GPUs tested,AI-assisted), and left theTestedsection truncated mid-sentence.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T14:25:05Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
887c2c6e51e6b926a773abaa43e9f15b71af1efc, basemain. No merged-preview check.description.md,commits.md,manifest.json,files.jsonanddiff.patchfrom the review folder, then the changed hunks and their neighbouring lines at head with the reader. No build, no test run, no write to the repository.Results
Commands and output
The commands are listed under What I ran. The search for
stb_image_writereturned no matching lines. The search forAdler32returned five matching lines incore/Decoder/Png/tests/Png.cppandcore/libs/tests/GuestWebKitZlib.cpp.Findings
Blocking
None.
Non-blocking
None found in the changed hunks.
Checked and consistent with the description:
Png::Encoderejects levels outside 0–9 beforecompress2is called (core/Decoder/Png/src/Png.cpp:196), so zlib gets a valid level. Level 0 selects stored blocks in zlib.INT_MAXcheck runs after compression (core/Decoder/Png/src/Png.cpp:230), wherecompressedSizeholds the real size.stb_image_writereference is left undercore.Adler32(core/Decoder/Png/tests/Png.cpp:94) is used by the stored-block check; the check on the first IDAT block header incore/libs/tests/GuestPngEnc.cppreads inside the chunk extent.Sources
github.com/boykopovar/AnyPS5@887c2c6e51/core/Decoder/Png/src/Png.cpp (L224-L230)github.com/boykopovar/AnyPS5@887c2c6e51/core/Decoder/Png/CMakeLists.txt (L9-L13)Not verified
guest_png_enc. Thedecoder_pngtests and the decoder's level-0 regression rest on the author's local run.core/Decoder/Png/CMakeLists.txt. macOS and MSVC behaviour was not checked, and the author says macOS was not tested.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T21:09:37Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
887c2c6e51:tools/check_conventions.pypassed;git diff --checkclean.decoder_png_tests,guest_png_enc_testsbuilt cleanly.decoder_png,guest_png_enc):core/Decoder/Png/src/Png.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me