Repository navigation
feat(libSceJxr): create WMP encoders and decoders as jxrlib does - #21991
Merged
oneandonlydean merged 6 commits intoNov 20, 2026
Merged
Conversation
PKImageEncode_Create_WMP and PKImageDecode_Create_WMP follow pinned jxrlib JXRGlueJxr.c: they run the generic constructors and install guest-ABI thunks for the _WMP slots, backed by the JXRGlueJxr.c code already linked into libSceJxr. Guest stream callbacks are reached through host adapters, and Transcode_WMP calls guest record slots with the guest ABI.
PrivacyOnion
approved these changes
Nov 17, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 0ca88cc5fb:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_jxr_wmp_tests,jxr_wmp_referencebuilt cleanly. - CTest (
guest_jxr_wmp):1/1 Test #4028: guest_jxr_wmp .................... Passed 0.05 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceJxr/Export.cpp,core/libs/prx/libSceJxr/include/Api.hpp,core/libs/prx/libSceJxr/src/NativeWmp.c,core/libs/prx/libSceJxr/src/Wmp.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass. - Code reading:
- Verified PKImageEncode_Create_WMP_nid_postfix and PKImageDecode_Create_WMP_nid_postfix creation routines and slot bindings against upstream jxrlib JXRGlueJxr.c
- Verified WMP stream proxying and VABI callback bridges in NativeWmp.c and Wmp.cpp including scope guard restoration and target unwrapping
- Audited proxy lifetime management in proxies map guarded by proxyMutex, properly releasing retained proxy buffers on encoder and decoder release
- Checked AGENTS.md rules, technical debt fragment formatting in docs/dev/debt/changes/feat-jxr-wmp-codec-create.md, and license/comment conventions
- Verified 64-bit portability (LP64/LLP64) in static asserts and type alignments in NativeWmp.c and WmpBridge.h
Looks Good To Me
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
Progress report (6d46e92 → 0ca88cc)📈 System libraries: 41.95% (+0.02%, +16 implemented, +4 declared functions) ✅ 16 implemented
🆕 4 declared as stubs
Changed libraries (implemented exports)
|
Contributor
|
Tested
AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports. |
12 tasks done
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.
What
PKImageEncode_Create_WMPandPKImageDecode_Create_WMP(libSceJxr) no longer throw. Onmainboth were bareNotImplemented_nid_no_patchstubs, andPKCodecFactory_CreateCodecalready sends the two WMP IIDs to them. They follow pinned jxrlibJXRGlueJxr.c, the same commit libSceJxr already follows.Constructors (
src/Wmp.cpp):PKImageEncode_Create_WMP(L1498-L1524) runs the existing guestPKImageEncode_Create, returns its error unchanged if it fails, then installs the eleven_WMPslots (Initialize, Terminate, SetColorContext, SetDescriptiveMetadata, WritePixels, WritePixelsBandedBegin, WritePixelsBanded, WritePixelsBandedEnd, Transcode, CreateNewFrame, Release) and setsbWMP(offset 520).PKImageDecode_Create_WMP(L2261-L2279) runs the existing guestPKImageDecode_Create, then installs Initialize, GetSize, GetRawStream, Copy, GetColorContext, GetDescriptiveMetadata and Release. GetPixelFormat, GetResolution, GetFrameCount and SelectFrame keep the generic slots, as upstream.PKCodecFactory_CreateCodecnow calls both with their own prototypes instead of through a cast function pointer.Slots. Each slot is an
APS5_VABIthunk that calls the upstream_WMPfunction on the guest record through a C bridge (src/NativeWmp.c, declared insrc/WmpBridge.h). It does not buildJXRGlueJxr.ca second time. The file is already compiled intojxr_metadata_native(Metadata.cmake), wherePKFreeandFreeDescMetadataare renamed to the guest-heap versions, andPKAlloccomes from the guest-heapJXRGlue.cofjxr_glue_guest(nmshows a single_PKAlloc, and it callsJxrGuestCalloc_nid_no_patch). A second copy would define every_WMPsymbol twice.JXRMeta.c, which the decoder uses to read descriptive metadata, is already injxr. The newWmp.cmakeadds the bridge tojxr_metadata_nativeand the thunks tolibSceJxr.Guest ABI. On Windows
APS5_VABIissysv_abi, and the upstream code calls stream callbacks and record slots with the host ABI. To handle that:guestpointer after aWMPStreamwhose six callbacks call the guest callbacks throughAPS5_VABI.wmiSCP.pWStreamfrom Initialize,pPATempFilefrom WritePixelsBandedBegin) are owned per record and freed by the record's Release. A new_Create_WMPat the same address drops any left over.pStreamis swapped for a stack adapter and then restored, so guest code sees its own stream pointer inpStreamand from GetRawStream.Close, so the guest gets&pStream, as upstream.PKImageEncode_Transcode_WMPcallsGetPixelFormat,SetPixelFormat,SetSize,GetResolution,SetResolutionandGetRawStreamon guest records, so it is ported (L1359-L1435) intoNativeWmp.cwithAPS5_VABIcasts. The Microsoft licence notice is kept at the top of the file, as inListStream.cpp.Throws, where upstream is undefined or crashes:
NotImplemented_nid_no_patch, asTranscode.cppandWriteSource.cppalready do. Upstream ignores thePixelFormatLookuperror in all three. WritePixels (L1185) and Transcode then read an uninitializedPKPixelInfo. WritePixelsBanded declares it asPKPixelInfo PI = {0}(L1237), so its behaviour is defined there, but encoding with a zeroed pixel info is not verified, so this PR throws in that case too.DPKVT_LPWSTRdescriptive text in SetDescriptiveMetadata, and in the header that WritePixels and Transcode write:NotImplemented_nid_no_patch. Upstream measures it withwcslen((wchar_t*)…), and the guestwchar_twidth is not settled.CopybeforeInitializeand a nullGetRawStreamslot reached by Transcode:std::invalid_argument.std::logic_error, before any codec state changes. WritePixels needs an encoder that has not started a banded or non-banded encode (L1188), so a second WritePixels or a WritePixels after WritePixelsBandedBegin throws. WritePixelsBandedBegin has the same rule (L1224), so a second Begin throws. WritePixelsBandedEnd throws unless a banded encode has written its first band, so also right after WritePixelsBandedBegin (L1310). In a Release build upstream would instead set up a second codec over the first, or replace the temp file of the first Begin.std::invalid_argumentbefore any codec state changes. Upstream only asserts the range (L1399), and its alpha checks before that assert do not catch mode 4 or higher with an alpha source. The test checks mode 4 with an alpha source, and a control without the check fails it.assert(FALSE). The result is the same as in Release.Jxr::SetImageEncodeMetadatahelper, which already backs the EXIF/GPS/IPTC/Photoshop setters, with the color-context offsets (200/208).Debt. The fragment
docs/dev/debt/changes/feat-jxr-wmp-codec-create.mdadds two libSceJxr entries (919 and 730 characters). They cover: not measured on a PS5, LP64 layout inferred, the host adapters held in internal stream fields, codec state on the host heap (not freed when a decode stops early, as upstream), and the throws above.Progress (
python3 tools/progress.py --module libSceJxr, then--compare, base3b7ffd7a05c): libSceJxr goes from 136 of 143 (95.10%) to 152 of 161 (94.41%), -0.69%. The percentage drops because the scanner counts everyAPS5_VABIdefinition, so the 18 slot thunks are now counted: 14 as implemented and 4 as pending. Both constructors move from pending to implemented (136 + 2 + 14 = 152, 7 - 2 + 4 = 9).EncodeWritePixels,EncodeBanded,EncodeTranscodeandEncodeSetDescriptiveMetadatashow as pending because they reachNotImplemented_nid_no_patchfor the unknown-format and wide-text cases above.Neighbouring PRs.
pr_overlap.py --namesreports no open PR for either function.pr_overlap.py --branchmerged 4 sharing PRs without a line overlap. It could not compare #15646 (EnumConversions), which no longer merges withmain(CMakeLists.txt, Export.cpp, Api.hpp). This PR changes two lines ofPKCodecFactory_CreateCodecand deletes the two stubs inExport.cpp, next to the code #20362 (CreateDecoderFromFile, which reaches these constructors through CreateCodec), #19182 and #18247 touch. Rebasing around them is mechanical. #21550 (checked guest copies inImageEncode.cpp) and #21717 (progress counting, which touchesBitIo.cpp,GlueHelpers.cppandMetadata.cpp) are open libSceJxr PRs that share no file with this one.Tested
macOS 27.0.1, x86_64 build under Rosetta 2 (Ninja, Release,
/usr/bin/cc/c++,BUILD_TESTING=ON). Not built or run on Linux or Windows; the Windows ABI path (adapters,APS5_VABIcasts) is only exercised as the identity ABI here. No title. Built onmain3b7ffd7a05cmerged in;ninjabuilds every target this PR touches. Two unrelated targets fail locally:libSceLibcInternal/TimeGetFields.cppfrommain(reinterpret_castfromconst void*casts away qualifiers on this clang) and thelibcurl.prxlink (local environment).guest_jxr_wmp(core/libs/tests/GuestJxrWmp.cppwith a host jxrlib reference inGuestJxrWmpReference.c, registered inlibSceJxr/Wmp.cmakelike the other libSceJxr tests):CreateCodecfor both IIDs. Out-of-memory returns -101 with a null output.Transcode_WMPoutput is byte-identical to host jxrlib for 24bppBGR and for 32bppBGRA with planar alpha (uAlphaMode2, which runs the second alpha transcode), and a generic decoder with no GetRawStream slot throws.NativeWmp.cpins the LP64 layout it relies on with_Static_asserts, includingoffsetof(PKImageEncode, bWMP) == 520.main's stub bodies (only the prototypes changed so the test compiles) aborts withstd::runtime_error: PKImageEncode_Create_WMP_nid_postfix not implemented.ctest -R jxr(26 tests, includingguest_jxr_factory,guest_jxr_decode_create,guest_jxr_glue,guest_jxr_metadata(_patched)and theguest_jxr_lookup*patched-prx tests): 26 of 26 passed, 3 runs.guest_pointer_audit,export_gap,unbuilt_exportsandpublic_headers*: 68 of 68 passed.tools/check_conventions.py --base origin/mainpasses.tools/debt_fold.py --checkfails onmainbecause two libSceLibreSsl3 fragments change the same entry. With that unrelated fragment removed in a scratch copy, it passes and--show libSceJxrplaces both new entries under Functional.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)