feat(libSceJxr): implement quantizer sharing and DC/AC prediction state helpers #15479
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15479"
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-03T14:43:00Z.
What
Five libSceJxr codec helpers currently throw:
setUniformQuantizer,useDCQuantizer,useLPQuantizer,getDCACPredModeandupdatePredInfo. They now call jxrlib's strcodec.c and strPredQuant.c, built from3rdparty/jxrlib, through a C bridge (src/NativePredict.c). No jxrlib logic is copied intocore/.setUniformQuantizerpoints every tile's DC, LP or HP quantizers at tile 0's.useDCQuantizer/useLPQuantizercopy a tile's DC quantizer into its first LP slot, or its LP quantizers into its HP slots.getDCACPredModepicks the DC and AC prediction directions for a macroblock column from the current and previous prediction rows.updatePredInfostores a macroblock's DC, LP QP index and first AC row and column for the next prediction.All five work on the caller's
CWMImageStrCodec. The bridge asserts its LP64 layout (35,944 bytes, with the offsets these calls read), 432-byte tiles and 48-byte prediction entries. Before calling jxrlib, it throws on a null codec, tile table, used channel quantizer, prediction row, AC buffer or macroblock, more than 16 channels or quantizers, a tile pastcNumOfSliceMinus1V, a column outsidecmbWidth, a column 0 that needs a left neighbour, and an unknown color format. 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.allocateQuantizer,freeQuantizer,allocatePredInfoandfreePredInfoare left as they are, because jxrlib allocates them with the hostmalloc.Tested
New
guest_jxr_predicttest. Each case builds randomized codec state, clones it, runs the guest export on one copy and jxrlib directly on the other, and compares quantizer data, quantizer pointers (by offset) and prediction rows:setUniformQuantizerfor 1, 6, 11 and 16 channels, 1 to 4 tiles and all bands;useDCQuantizeranduseLPQuantizer(0 to 16 quantizers) for every tile.getDCACPredModefor every color format, every left/top context and every valid column, 8 random states each.updatePredInfofor every color format and 1 to 16 channels, including a macroblock inside the codec itself.Results:
03fcc3d275, withmain04cdd52760(after #14933) merged in: Linux x86-64 (Ubuntu 24.04, GCC 13), Release,ctest -R guest_jxr11/11 passed in each of 3 runs. Windows 11 x86-64, WinLibs MinGW GCC 15.2.0, Release: 11/11 passed.d1ae628bc2:ctest -R guest_jxr10/10 passed. Built with-fsanitize=undefined, the test reports no UBSan errors.ctest -R guest_jxr10/10 passed in each of 3 runs, including the_patchedlookup tests.python tools/check_conventions.py --base origin/mainandpython core/libs/tests/test_public_headers.py --audit-only(405 libraries, 28,213 exports): passed.python tools/pr_overlap.py --branch claude/jxr-predict(1,714 open PRs): no shared exports or new files, and no open PR mentions or adds these five functions. #14905, #14916, #15148 and #15232 touch neighbouring lines ofCMakeLists.txt,Export.cpp,include/Api.hppand the debt file, so whichever lands later will getmainmerged in. #15689 includes this PR and goes right after it.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)