Files
AnyPS5/docs/dev/debt/libSceVideodec.md
T
Dean Galvinandfogydes 13d4482884 fix(libSceVideodec): read the full size fields and check them before the structures
ConfigInfo::thisSize and ResourceInfo::thisSize are 64-bit, so read them
as std::uint64_t in CreateDecoder and QueryResourceInfo. Decode, Flush,
DeleteDecoder and Reset now read and check each thisSize before copying
the whole structure in, so a short structure at the end of a mapped page
gets the struct size error, not the pointer error. CreateDecoder no
longer writes ctrl before it can fail; the copy-out after creation
already cleans up. The debt entry now says that the console's answer for
an unreadable pointer is not measured.

Tests cover size fields with only their upper bits set, short
structures at the end of a page, an untouched ctrl after a failed
create, and read-only output blocks.

Co-authored-by: fogydes <[email protected]>
2026-11-06 03:14:22 +13:00

4.1 KiB

libSceVideodec technical debt

Unknown function info

Functional

  • sceVideodecCreateDecoder (libSceVideodec) - the codec type is not checked and the decoder always decodes H.264, as the PS4 library does; the console's codec ids are not documented. A configuration without a maximum frame size is refused with the configuration error, and the resource information the caller passes is not used

  • sceVideodecQueryResourceInfo (libSceVideodec) - the sizes it reports are libSceVideodec2's, not the console's: the CPU memory, CPU-GPU memory and frame buffer sizes and the frame buffer alignment that sceVideodec2QueryDecoderMemoryInfo gives for the configuration mapped as sceVideodecCreateDecoder maps it. The GPU memory size that query also gives has no field in this structure and is dropped. The memory pointers and thisSize are left as the caller passed them, where shadPS4 clears the pointers; what the console writes there is not known. A larger structure is accepted, as by the module's other exports, where shadPS4 requires the exact size, and a configuration without a maximum frame size is refused with the configuration error, where shadPS4 assumes 1920x1080 or 3840x2160

  • sceVideodecDecode and sceVideodecFlush (libSceVideodec) - the picture information's video usability information (the tick rate, the sample aspect ratio and the colour description) stays zero, as the decoder does not report it, and the crop offsets are the decoded picture's crop halved, the unit the H.264 offsets use. The frame buffer holds the coded picture the decoder reports, so the rows the crop covers are in it and the caller crops them. A picture deeper than 8 bits, such as one of a High 10 stream, throws, as what the console writes for it is not known; when its rows do not fit the staging buffer sized for 8-bit pictures of the configured size, the decode fails with the decode error before that

  • sceVideodecMapMemory (libSceVideodec) - its name is listed in the PS5 3.20 export table and cross-checked against PS5 13.60. Its signature and behaviour are unverified; this no-parameter declaration only resolves the import and throws through NotImplemented_nid_no_patch.

  • sceVideodec pointer safety (libSceVideodec) - sceVideodecCreateDecoder, sceVideodecDecode, sceVideodecDeleteDecoder, sceVideodecFlush, sceVideodecReset, and sceVideodecQueryResourceInfo validate caller input and output pointers using GuestCopyIn_nid_no_patch and GuestCopyOut_nid_no_patch, returning VideodecErrorArgumentPointer or VideodecErrorFrameBufferPointer on invalid or unwritable memory rather than causing host access violations. What the console returns for an unreadable or unwritable pointer is not measured; these functions return the pointer errors instead.