feat(libSceJxr): implement the pixel format hash, image IID lookups, aligned allocation and IDPEmpty #14905

Merged
Noxy-HNR merged 6 commits from upstream-pr/14905 into main 2026-11-05 21:30:10 +00:00
Noxy-HNR commented 2026-11-02 00:06:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Noxy-HNR on 2026-11-02T00:06:22Z.


What

Six named libSceJxr exports currently throw: GetPixelFormatFromHash, GetImageEncodeIID, GetImageDecodeIID, PKAllocAligned, PKFreeAligned and IDPEmpty. Implement them from Microsoft's jxrlib at the pinned submodule commit, JXRGlue.c and strcodec.c:

  • GetPixelFormatFromHash calls the pinned jxrlib through a C bridge, like PixelFormatLookup, and returns its read-only GUID for the hash (the GUID's last byte), or null.
  • GetImageEncodeIID / GetImageDecodeIID match .jxr, .wdp and .hdp as case-insensitive prefixes and store the exported IID_PKImageWmpEncode (101) / IID_PKImageWmpDecode (201). .wdp and .hdp encoding store a private IID_PKImageUnsupported (100), which the module does not export. Unknown extensions return WMP_errUnsupportedFormat (-106) without writing the output.
  • PKAllocAligned takes size + 8 + alignment - 1 bytes from the guest calloc, stores the original pointer just below the aligned block and returns WMP_errOutOfMemory (-101) when calloc fails. PKFreeAligned releases that original pointer through the guest free.
  • IDPEmpty returns ICERR_OK (0).

The third-party algorithms stay in the unmodified, source-built 3rdparty/jxrlib dependency, with its license notices retained. NativeGlue.c bridges to JXRGlue.c and strcodec.c; GlueHelpers.cpp supplies the guest ABI, argument checks and IID-object mapping. A dedicated JXRGlue.c build routes calloc and free through the guest heap. Null outputs, alignments below 8 and overflowing block sizes throw before entering jxrlib. That the console's module is jxrlib with these prototypes is inferred from the export names; nothing is checked on a console. These limits are recorded in the library's debt file. No title unblock is claimed.

Merge order: this PR follows #14425 and #14631. Both merge cleanly with current main individually, but their combination with this branch conflicts in the shared JXR files. There is no runtime dependency on either implementation; the dependency line records integration order. Rebase and rerun guest_jxr after those PRs merge. The current pairwise preview with #7645 is clean.

Tested

Latest follow-up verification at c7a34875b0: rebuilt guest_jxr_glue_tests, guest_jxr_stream_tests and guest_jxr_tests on Windows 11 x86-64, WinLibs MinGW GCC 15.2.0, Release. ctest -R '^guest_jxr(_glue|_stream)?$': 3/3 passed. This directly checks the new native glue, the guest allocator routing and existing stream helpers. Conventions and whitespace checks passed. The hosted Windows, conventions and library-portability checks also pass at this head. The earlier 10-test runs below are retained as prior verification; Linux and patched lookup tests were not rerun in this follow-up.

New guest_jxr_glue test: all 256 hashes against the pinned jxrlib's GetPixelFormatFromHash (null-ness and GUID bytes), the IID lookups for each extension, case, prefix and unknown extension with and without an output, aligned allocation for alignments 8, 16, 24, 64 and 4096 and sizes 0, 1 and 100 through a recording application allocator (calloc arguments, alignment, zero fill, stored original pointer, release), calloc failure, null and too-small alignments and size overflow.

  • Linux x86-64 (Ubuntu 24.04, GCC 13), Release, upstream 0580e5c951: ctest -R guest_jxr 10/10 passed.
  • Windows 11 x86-64, WinLibs MinGW GCC 15.2.0, Release: ctest -R guest_jxr 10/10 passed, including the _patched lookup tests against the patched libSceJxr.prx.
  • python tools/check_conventions.py --base origin/main, git diff --check and python core/libs/tests/test_public_headers.py --audit-only (399 libraries, 26,743 exports): passed.
  • python tools/pr_overlap.py --branch claude/jxr-glue-helpers (1,849 open PRs): #14425 (PKAlloc) and #14631 (WMPAlloc, WMPFree, memory stream) touch neighbouring lines of CMakeLists.txt, Export.cpp, include/Api.hpp and the debt file; neither shares an export or new file. Whichever lands second needs a small rebase. #7645 also edits libSceJxr/CMakeLists.txt (Windows DLL staging for guest_jxr_lookup_tests); if it lands first, guest_jxr_glue_tests may need the same treatment.

No console or retail-title test.

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: #14425, #14631
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5112917104 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14905). Originally posted by [Noxy-HNR](https://github.com/Noxy-HNR) on 2026-11-02T00:06:22Z. --- ### What Six named libSceJxr exports currently throw: `GetPixelFormatFromHash`, `GetImageEncodeIID`, `GetImageDecodeIID`, `PKAllocAligned`, `PKFreeAligned` and `IDPEmpty`. Implement them from Microsoft's jxrlib at the pinned submodule commit, [JXRGlue.c](https://github.com/4creators/jxrlib/blob/f7521879862b9085318e814c6157490dd9dbbdb4/jxrgluelib/JXRGlue.c#L64-L329) and [strcodec.c](https://github.com/4creators/jxrlib/blob/f7521879862b9085318e814c6157490dd9dbbdb4/image/sys/strcodec.c#L239-L244): - `GetPixelFormatFromHash` calls the pinned jxrlib through a C bridge, like `PixelFormatLookup`, and returns its read-only GUID for the hash (the GUID's last byte), or null. - `GetImageEncodeIID` / `GetImageDecodeIID` match `.jxr`, `.wdp` and `.hdp` as case-insensitive prefixes and store the exported `IID_PKImageWmpEncode` (101) / `IID_PKImageWmpDecode` (201). `.wdp` and `.hdp` encoding store a private `IID_PKImageUnsupported` (100), which the module does not export. Unknown extensions return `WMP_errUnsupportedFormat` (-106) without writing the output. - `PKAllocAligned` takes `size + 8 + alignment - 1` bytes from the guest `calloc`, stores the original pointer just below the aligned block and returns `WMP_errOutOfMemory` (-101) when `calloc` fails. `PKFreeAligned` releases that original pointer through the guest `free`. - `IDPEmpty` returns `ICERR_OK` (0). The third-party algorithms stay in the unmodified, source-built `3rdparty/jxrlib` dependency, with its license notices retained. `NativeGlue.c` bridges to `JXRGlue.c` and `strcodec.c`; `GlueHelpers.cpp` supplies the guest ABI, argument checks and IID-object mapping. A dedicated `JXRGlue.c` build routes `calloc` and `free` through the guest heap. Null outputs, alignments below 8 and overflowing block sizes throw before entering jxrlib. That the console's module is jxrlib with these prototypes is inferred from the export names; nothing is checked on a console. These limits are recorded in the library's debt file. No title unblock is claimed. Merge order: this PR follows #14425 and #14631. Both merge cleanly with current main individually, but their combination with this branch conflicts in the shared JXR files. There is no runtime dependency on either implementation; the dependency line records integration order. Rebase and rerun `guest_jxr` after those PRs merge. The current pairwise preview with #7645 is clean. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Latest follow-up verification at `c7a34875b0`: rebuilt `guest_jxr_glue_tests`, `guest_jxr_stream_tests` and `guest_jxr_tests` on Windows 11 x86-64, WinLibs MinGW GCC 15.2.0, Release. `ctest -R '^guest_jxr(_glue|_stream)?$'`: **3/3 passed**. This directly checks the new native glue, the guest allocator routing and existing stream helpers. Conventions and whitespace checks passed. The hosted Windows, conventions and library-portability checks also pass at this head. The earlier 10-test runs below are retained as prior verification; Linux and patched lookup tests were not rerun in this follow-up. New `guest_jxr_glue` test: all 256 hashes against the pinned jxrlib's `GetPixelFormatFromHash` (null-ness and GUID bytes), the IID lookups for each extension, case, prefix and unknown extension with and without an output, aligned allocation for alignments 8, 16, 24, 64 and 4096 and sizes 0, 1 and 100 through a recording application allocator (calloc arguments, alignment, zero fill, stored original pointer, release), calloc failure, null and too-small alignments and size overflow. - Linux x86-64 (Ubuntu 24.04, GCC 13), Release, upstream `0580e5c951`: `ctest -R guest_jxr` **10/10 passed**. - Windows 11 x86-64, WinLibs MinGW GCC 15.2.0, Release: `ctest -R guest_jxr` **10/10 passed**, including the `_patched` lookup tests against the patched `libSceJxr.prx`. - `python tools/check_conventions.py --base origin/main`, `git diff --check` and `python core/libs/tests/test_public_headers.py --audit-only` (399 libraries, 26,743 exports): passed. - `python tools/pr_overlap.py --branch claude/jxr-glue-helpers` (1,849 open PRs): #14425 (`PKAlloc`) and #14631 (`WMPAlloc`, `WMPFree`, memory stream) touch neighbouring lines of `CMakeLists.txt`, `Export.cpp`, `include/Api.hpp` and the debt file; neither shares an export or new file. Whichever lands second needs a small rebase. #7645 also edits `libSceJxr/CMakeLists.txt` (Windows DLL staging for `guest_jxr_lookup_tests`); if it lands first, `guest_jxr_glue_tests` may need the same treatment. No console or retail-title test. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: #14425, #14631 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
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!14905
No description provided.