Files
AnyPS5/docs/dev/debt/libSceJxr.md
T
2026-11-06 10:33:53 +13:00

9.6 KiB

libSceJxr technical debt

GUID exports

  • GUID data exports use 84 values from the pinned JXR header. Their NIDs and bytes match version-labelled images; the labels are not authenticated. Runtime behavior on a console and complete consumer coverage are unverified. Four additional 4-byte interface identifiers have names and values matching the pinned upstream JXR implementation and both version-labelled images; their relative placement in a guest image and use by consumers are unverified. One older 8-byte writable object has a relocation and no matching later-image data export; its identity, lifetime and initialization remain unknown and it is not implemented.

Functional

  • PKAlloc: console behavior and ABI remain unverified. The implementation follows pinned jxrlib JXRGlue.c, using guest calloc(1, cb) so allocations match the guest heap released by PKFree. It stores the allocation, including null on failure, and returns WMP_errSuccess (0) or WMP_errOutOfMemory (-101) as a 64-bit ERR. A null ppv throws instead of the upstream null dereference; zero size follows guest calloc.

  • PixelFormatLookup uses pinned public jxrlib through a C bridge and a 56-byte LP64 guest record. BunnyFl reports firmware 13.42 native-PC comparisons: the 68 table entries match public jxrlib, and return values/record fields match across 802 cases repeated three times, except that the module clears padding bytes 28..31 on all 309 successes. This bridge now clears that four-byte range explicitly on success; it does not copy indeterminate C++ padding. This is attributed single-firmware evidence, not an author-run console measurement or proof of the complete Sony ABI/configuration. Module/library versions, other firmware and valid-mode null arguments remain unverified. Modes 0/1 perform forward GUID/reverse TIFF lookup; other modes and misses leave the entire record unchanged. Valid-mode null records and forward null GUIDs remain explicitly unsupported. Success borrows a read-only static GUID while the module is loaded; callers must not free it. Closes when: remaining Sony ABI, version/configuration and invalid-argument behavior are verified by attributable measurements or disassembly

  • PKFree (libSceJxr) follows Microsoft's jxrlib JXRGlue.c, whose four exported names the module shares: a non-null ppv has *ppv released with the guest free and set to null, and the result is always WMP_errSuccess (0) as a 64-bit ERR (long). That the console's module is built from jxrlib, and that its PKFree releases through libc's free, is inferred from the export names and not checked against the console's code. Closes when: the console's PKFree is disassembled or measured on a PS5

  • WMPAlloc, WMPFree and the memory stream (CreateWS_Memory, EOSWS_Memory, ReadWS_Memory, WriteWS_Memory, SetPosWS_Memory, GetPosWS_Memory): console code and layouts are unverified. They follow pinned jxrlib strcodec.c on the LP64 WMPStream layout, allocating with guest calloc(1, cb) and free; that the module is built from jxrlib is inferred from the export names. The Close callback is jxrlib's CloseWS_Memory, which the export inventory lacks. Where jxrlib dereferences null, std::invalid_argument is thrown: a null ppv, stream or poffPos, and a null buffer when a read or write copies at least one byte. Closes when: the console's functions are disassembled or measured on a PS5

  • readIS and writeIS use the non-ARM, LP64 BitIOInfo and WMPStream ABI and packet algorithm from Microsoft's JPEG XR reference implementation. Console structure layouts and execution remain unverified. Profiling callbacks are omitted as in the reference Unix build with DISABLE_PERF_MEASUREMENT; the codec argument is unused. Where the reference uses an invalid pointer, std::invalid_argument is thrown instead: a null bit state, stream or callback, a read-only read packet, and a null packet when a read copies its shadow or a successful write offsets it; a null packet still reaches the callback first. No codec is instantiated by these helpers; callers must supply the reference ring buffer and guest-ABI stream callbacks.

  • GetPixelFormatFromHash, GetImageEncodeIID and GetImageDecodeIID call jxrlib's JXRGlue.c, built from 3rdparty/jxrlib, through a C bridge. That the console's module is jxrlib with these prototypes is inferred from the export names. The hash lookup, like PixelFormatLookup, borrows the bridge's read-only GUID. IID values map to the module's exported IID objects; .wdp and .hdp encoding return a private IID_PKImageUnsupported (100), which the module does not export. A null extension, or a null output for a known extension, throws where jxrlib dereferences it. Closes when: the console's functions are disassembled or measured on a PS5

  • PKAllocAligned, PKFreeAligned and IDPEmpty call jxrlib's JXRGlue.c and strcodec.c, with that JXRGlue.c copy's calloc and free routed to the guest heap; that the console allocates there is inferred. A null output, an alignment below 8 and a block size over SIZE_MAX throw before jxrlib can fault, write before the block or wrap. Closes when: the console's functions are disassembled or measured on a PS5

  • remapQP, formatQuantizer, getACPredMode and InitZigzagScan call jxrlib's strPredQuant.c, strcodec.c and image.c, built from 3rdparty/jxrlib, on the caller's 20-byte quantizer, 1,160-byte macroblock and 704-byte coding context without WMP_OPT_QT. These prototypes and layouts are inferred from the export names. A null quantizer, quantizer table, used channel or macroblock, more than 16 channels, and a scaled shift that takes the QP outside 32 bits throw. Closes when: the console's functions are disassembled or measured on a PS5

  • Bit I/O (peekBit16, flushBit16, getBit16, getBool16, getBit16s, getBit32, flushToByte, putBit16z, putBit16, putBit32, fillToByte, getSizeRead, getSizeWrite, getPosRead, dquantBits) calls jxrlib's non-ARM strcodec.c, built from 3rdparty/jxrlib, on the guest BitIOInfo. That the console's module uses these prototypes and that layout is inferred from the export names. Bit counts over jxrlib's asserted limits, a value wider than putBit16z's count, an odd read wrap mask and a null state or current pointer throw. Closes when: the console's functions are disassembled or measured on a PS5

  • Bit I/O boundaries: the console behaviour for these cases is unknown. The adapter defines paths jxrlib leaves undefined in C: a zero-bit peek returns 0; zero-bit getBit16 and getBit32 return 0 after flushBit16(0); an empty store or byte fill at a word boundary changes nothing. Masked writes use unsigned masks and putBit16z in 16-bit parts, avoiding jxrlib's negative left shift. A bit position of 16 or more or a byte pointer not aligned for a 16-bit store throws before changing state or memory. Closes when: the console's functions are disassembled or measured on a PS5

  • getBit16_S is getBit16 followed by readIS, as in strcodec.c with readIS_L1 defined as readIS; the codec argument is passed through. Closes when: the console's function is disassembled or measured on a PS5

  • The 97 additional exports in Export.cpp are present in the pinned firmware 13.60 libSceJxr export inventory. Their parameter lists, return types and behavior are unverified. Parameterless int declarations are import-resolution placeholders, not verified ABI prototypes; every entry throws through NotImplemented_nid_no_patch. The _nid_postfix aliases keep the guest bindings distinct from private native helpers. No runtime functionality is implemented.