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]>
4.1 KiB
libSceVideodec technical debt
Unknown function info
- sceVideodecCreateDecoder, sceVideodecDecode, sceVideodecDeleteDecoder, sceVideodecFlush, sceVideodecQueryResourceInfo and sceVideodecReset (libSceVideodec) - the structure layouts and the error codes follow shadPS4's PS4 library and its implementation, not measured on a PS5: the console's error for a rejected argument and its own version of the structures are unknown. The decoder runs through libSceVideodec2, which decodes H.264 with FFmpeg, and the picture is copied into the caller's frame buffer with the pitch aligned to 64 and the coded height, as the reference writes it. The null and structure-size checks in
sceVideodecDeleteDecoderandsceVideodecReset, the handle check insceVideodecResetand the picture-information size check insceVideodecDecodeare not in the reference and not measured on a PS5.
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
sceVideodec2QueryDecoderMemoryInfogives for the configuration mapped assceVideodecCreateDecodermaps it. The GPU memory size that query also gives has no field in this structure and is dropped. The memory pointers andthisSizeare 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, andsceVideodecQueryResourceInfovalidate caller input and output pointers usingGuestCopyIn_nid_no_patchandGuestCopyOut_nid_no_patch, returningVideodecErrorArgumentPointerorVideodecErrorFrameBufferPointeron 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.