feat(libSceJxr): implement decoder post-processing helpers #16282
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16282"
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-06T03:47:56Z.
What
Four libSceJxr decoder post-processing helpers currently throw:
slideOneMBRow,updatePostProcInfo,postProcMBandpostProcBlock. They now call jxrlib's postprocess.c, built from3rdparty/jxrlib, through a C bridge (src/NativePostProc.c). No jxrlib logic is copied intocore/.slideOneMBRowswaps each channel's previous and current macroblock-info rows, and marks the new rows bumpy at the top or bottom edge.updatePostProcInforecords a macroblock's DC and its macroblock and block textures.postProcMBsmooths the 2-pixel macroblock boundaries between four neighbouring macroblocks and stores their block DCs.postProcBlockdeblocks the 16 blocks of the upper-left macroblock.All four work on the caller's
tagPostProcInfo* [16][2]row table, 88-byte LP64tagPostProcInfoentries (the bridge asserts the layout) andPixelImacroblock rows. The C++ adapters insrc/PostProc.cppthrow on a null table, a null macroblock or row the call dereferences, more than 16 channels, a channel past 15, and a column or row width whose byte offset overflows. Before calling jxrlib they open host writes on exactly the table, info entries and pixel ranges each call writes, so a read-only guest page throws instead of faulting. The row length is not an argument, so a column past the caller's row cannot be detected.cmake/Jxr.cmakebuildspostprocess.cwith-fwrapv. Its smoothing and DC comparisons overflowInton extreme pixel or DC values, which is undefined behaviour in the host build. With-fwrapvthey wrap instead, and in-range results don't change.The row table comes from
initPostProcand is released bytermPostProc, which #16267 and #16269 added tomain. That the console's module uses these prototypes and layouts is inferred from the export names. Nothing is checked on a console, and the debt file records this. No title unblock is claimed.This branch is built on #15689, which includes #15479, so the diff also shows their commits. This PR's own change is commit
3980822836; the merge commits after it bring in the updated #15689. It goes right after #15689.Tested
New
guest_jxr_postproctest. Each case builds a randomized row table and macroblock rows, clones it, runs the guest export on one copy and jxrlib directly on the other, and compares the rows, the pixels and the table pointers (by offset):slideOneMBRowfor 0, 1, 3 and 16 channels, widths 0 to 12, every top/bottom combination, three slides in a row.updatePostProcInfofor every column and several channels, with dense, sparse and all-zero macroblocks (smooth and bumpy textures).postProcMBandpostProcBlockfor every column 0 to 12, thresholds 0, 1, 4 and 100, and flat and mixed textures. Also extreme values (random 32-bit pixels and DCs, thresholdINT32_MAX).sceKernelMprotect(checked withVirtualQuery). Each call is rejected exactly when a page it writes is read-only, and succeeds once write access is restored.postProcMB/postProcBlockby one, makes the test fail.Results:
40ea2a1518on upstream6bf3a19b81(after #16267 and #16269 merged):ctest -R guest_jxr15/15 passed in each of 3 runs. Earlier,1a408e876don upstreamc36ab99c74also passed 15/15 in each of 3 runs. The first version,3980822836on upstream04cdd52760, passed 13/13 in each of 3 runs.-fsanitize=signed-integer-overflow -fno-sanitize-recover=all) onpostprocess.cwith the test's case generator: in-range cases are clean with or without-fwrapv. Extreme cases stop with signed overflow atpostprocess.c:187without-fwrapv, and are clean with it.40ea2a1518,ctest -R guest_jxr15/15 passed in each of 3 runs, including the read-only page checks. Earlier,1a408e876dalso passed 15/15 in each of 3 runs. The first version,3980822836, passed 13/13 in each of 3 runs, including the read-only page checks, and the build log showspostprocess.ccompiled with-fwrapv.python tools/check_conventions.py --base origin/mainandpython core/libs/tests/test_public_headers.py --audit-only(406 libraries, 30,646 exports): passed.python tools/pr_overlap.py --branch claude/jxr-postproc(1,894 open PRs): no shared exports. It could not compare 11 open libSceJxr PRs that conflict withmain(#15148, #15232, #15626, #15645, #15646, #15684, #15771, #15772, #15774, and #14905 and #14916, which have since merged). Checked by hand, none of them adds these four functions. They overlap only on neighbouring lines ofCMakeLists.txt,Export.cpp,include/Api.hppand the debt file.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)