feat(libSceJxr): implement codec row-state and coding-context reset helpers #15689
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15689"
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 Noxy-HNR on 2026-11-04T05:58:18Z.
What
Implements seven libSceJxr exports as thin adapters over the pinned jxrlib (
3rdparty/jxrlib,f7521879862b9085318e814c6157490dd9dbbdb4), through a C bridge injxr_lookup_native:checkImageBufferandgetTilePos(strcodec.c)initMRPtr,advanceMRPtr,advanceOneMBRowandswapMRPtr(strcodec.c)ResetCodingContext(image.c)They act on the caller's LP64
CWMImageStrCodec(35,944 bytes) and its alpha codec, or on a 704-byteCCodingContext._Static_asserts pin the sizes and the field offsets used. The prototypes come from jxrlib'sstrcodec.h; matching the export names to them is an inference.GuestArena::HostWrite. A codec, alpha codec or context that the host may not write throwsstd::invalid_argument, and no byte changes.checkImageBufferonly reads.std::invalid_argumentinstead:advanceMRPtr: a secondary codec (jxrlib asserts this), an unknown color format (it indexescblkChromas), or a null row buffer it would advanceThe debt entry records what is inferred, and the remaining-export count drops by seven.
Tested
New
guest_jxr_rowstest. It builds randomized codec pairs and runs each export on one copy and jxrlib's own function on a clone. It then compares the codecs (pointers by offset), row buffers, prediction rows and coding context. Coverage:checkImageBuffer: YUV and non-YUV data, 7 color formats, 6 bit depths, 8 unit sizes and random strides, at each of 6 widths × 7 row counts.getTilePos: walks a 12×8 macroblock grid for every 1–4 × 1–4 tile layout.initMRPtr, threeadvanceMRPtrcalls,swapMRPtrandadvanceOneMBRow.ResetCodingContext: 8 random contexts.sceKernelMprotect, andPAGE_READONLYis confirmed withVirtualQuery.checkImageBufferstill reads the codec. Each mutating export throws with every page byte-for-byte unchanged, including when only the alpha codec is read-only. After write access is restored, the calls succeed.Rows.cppremoved, the test crashes with an access violation (0xc0000005) on the read-only page. On Linux, with the jxrlib calls ingetTilePosandswapMRPtrstubbed out, it fails with "getTilePos differs from jxrlib".Results:
93b082c157, withmain04cdd52760(after #14933) and the updated #15479 merged in: Ubuntu 24.04 x86-64, GCC 13.3.0, Release,ctest -R guest_jxrpassed 12/12 (addingguest_jxr_quantizerfrommain) in each of 3 runs. Windows 11 x86-64, WinLibs GCC 15.2.0, Release: 12/12 passed.ctest -R guest_jxrpassed 10/10 in each of 3 runs. With #15479 merged in, 11/11 (addingguest_jxr_predict) in each of 3 runs.ctest -R guest_jxrpassed 10/10 in each of 3 runs, including the read-only page checks. No new warnings. With #15479 merged in, 11/11 in each of 3 runs.python3 tools/check_conventions.py --base origin/mainandgit diff --check: passed. Merges cleanly withmainatb8efa6292a.python3 tools/pr_overlap.py --branch claude/jxr-row-state: no open PR implements the same exports or adds the same files. The other open libSceJxr PRs overlap only on the debt count line and neighbouring lines inExport.cppandApi.hpp. #15479 changes the same debt lines, so this branch merges it in with those lines resolved, and this PR goes right after it. The check could not compare #7645, which conflicts withmain; itslibSceJxr/CMakeLists.txtchange applies cleanly on top of this branch.No console or retail-title test.
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)