revert: encode PNG with zlib at the requested compression level (#18387) #21466

Merged
oneandonlydean merged 1 commit from upstream-pr/21466 into main 2026-11-16 08:07:42 +00:00
oneandonlydean commented 2026-11-16 07:18:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-11-16T07:18:02Z.


What

Exact inverse revert of #18387 (merge 179a2ef3dc). Since it merged, the Windows patched_libraries test fails on main (0694c4cbd6, on two machines): libSceVideoOut.prx and libSceGnmDriver.prx fail to load with LoadLibraryEx error 127. The PNG encoder now calls zlib's compress2 and compressBound; on Windows libSceVideoOut.prx imports them from libSceAgcDriver.prx (checked with objdump -p on the built files), which does not export them, and libSceGnmDriver.prx fails because it loads libSceVideoOut.prx. The compression-level fix can come back once the PNG decoder links zlib so that every library using it gets its own copy.

Tested

The full Windows suite on this PR must show patched_libraries passing.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5332814499 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21466). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-11-16T07:18:02Z. --- ### What Exact inverse revert of #18387 (merge 179a2ef3dc9). Since it merged, the Windows `patched_libraries` test fails on `main` (0694c4cbd6, on two machines): `libSceVideoOut.prx` and `libSceGnmDriver.prx` fail to load with `LoadLibraryEx` error 127. The PNG encoder now calls zlib's `compress2` and `compressBound`; on Windows `libSceVideoOut.prx` imports them from `libSceAgcDriver.prx` (checked with `objdump -p` on the built files), which does not export them, and `libSceGnmDriver.prx` fails because it loads `libSceVideoOut.prx`. The compression-level fix can come back once the PNG decoder links zlib so that every library using it gets its own copy. ### Tested The full Windows suite on this PR must show `patched_libraries` passing. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-16 07:20:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T07:20:19Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 9f284c930e:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: decoder_png_tests, guest_png_enc_tests built cleanly.
  • CTest (decoder_png, guest_png_enc):
    1/2 Test #4608: decoder_png ......................   Passed    0.01 sec
    2/2 Test #4618: guest_png_enc ....................   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/Decoder/Png/src/Png.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified core/Decoder/Png/CMakeLists.txt removes zlibstatic and --exclude-libs link options, restoring linkage strictly against ${runtimeTarget}.
    • Verified core/Decoder/Png/src/Png.cpp (Decoder::Png::Encode) bounds-checks (rowSize + 1) * height <= INT_MAX before casting filtered.size() to int for stbi_zlib_compress, and frees the returned buffer with STBIW_FREE via std::unique_ptr custom deleter.
    • Verified core/Decoder/Png/src/Png.cpp throws std::runtime_error when stbi_zlib_compress returns nullptr and passes compressedSize safely as std::size_t to appendChunk.
    • Verified core/Decoder/Png/tests/Png.cpp and core/libs/tests/GuestPngEnc.cpp cleanly remove only the stored-block compression-level 0 assertions introduced in #18387 while retaining full round-trip, filter-selection, and error-handling coverage.
    • Verified compliance with AGENTS.md and CONVENTIONS.md (no code comments, no stray files, passing mechanical conventions and CTest suites for decoder_png and guest_png_enc).

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5916326548 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21466#pullrequestreview-5916326548). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T07:20:19Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `9f284c930e`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `decoder_png_tests`, `guest_png_enc_tests` built cleanly. - **CTest** (`decoder_png`, `guest_png_enc`): ``` 1/2 Test #4608: decoder_png ...................... Passed 0.01 sec 2/2 Test #4618: guest_png_enc .................... Passed 0.01 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/Decoder/Png/src/Png.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified `core/Decoder/Png/CMakeLists.txt` removes `zlibstatic` and `--exclude-libs` link options, restoring linkage strictly against `${runtimeTarget}`. - Verified `core/Decoder/Png/src/Png.cpp` (`Decoder::Png::Encode`) bounds-checks `(rowSize + 1) * height <= INT_MAX` before casting `filtered.size()` to `int` for `stbi_zlib_compress`, and frees the returned buffer with `STBIW_FREE` via `std::unique_ptr` custom deleter. - Verified `core/Decoder/Png/src/Png.cpp` throws `std::runtime_error` when `stbi_zlib_compress` returns `nullptr` and passes `compressedSize` safely as `std::size_t` to `appendChunk`. - Verified `core/Decoder/Png/tests/Png.cpp` and `core/libs/tests/GuestPngEnc.cpp` cleanly remove only the stored-block compression-level 0 assertions introduced in #18387 while retaining full round-trip, filter-selection, and error-handling coverage. - Verified compliance with `AGENTS.md` and `CONVENTIONS.md` (no code comments, no stray files, passing mechanical conventions and CTest suites for `decoder_png` and `guest_png_enc`). Looks Good To Me
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!21466
No description provided.