feat(libSceVideodec): implement the video decoder on top of libSceVideodec2 #8094
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8094"
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 slick-daddy on 2026-10-19T21:21:18Z.
What
libSceVideodec's five exports were stubs that threw. Decoder creation, decoding, flushing, resetting and deleting are now implemented with the structure layouts of shadPS4's PS4 library, and the decode runs through libSceVideodec2, which decodes H.264 with FFmpeg. The picture is copied into the caller's frame buffer as NV12 with the pitch aligned to 64 and the coded height the decoder reports, the chroma after the luma rows, and the picture information holds the timestamps and the crop offsets in the unit the H.264 offsets use. A guest test decodes the shared H.264 fixture through the library, both as it is and with a sequence parameter set that crops the picture, and checks the pictures against the reference hashes, the display order, the geometry, the crop and the argument errors.
Tested
Windows 11, MinGW-w64 GCC 15.2.0,
ctest --test-dir build -R "guest_videodec$|guest_videodec2|guest_vdecsw"passes. No title was run: no game dump was available here.python3 tools/check_conventions.py --base origin/mainandpython3 tools/pr_overlap.py --branch newwypass.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T21:22:09Z.
Progress report (
339217e→51c6b38)📈 System libraries: 64.03% (+0.07%, +5 implemented functions)
✅ 5 implemented
sceVideodecCreateDecodersceVideodecDecodesceVideodecDeleteDecodersceVideodecFlushsceVideodecResetImported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T22:03:55Z.
CodedSizeis written as if libSceVideodec2 might report the visible size. It never does. Videodec2 opens FFmpeg withapply_cropping = 0and reports the AVFrame's size as-is (L492). FFmpeg'savcodec.hdocuments that with 0 "the width/height fields of the output frames will be set to the coded dimensions and the crop_* fields will describe the cropping rectangle". Videodec2's own test also checksframeHeight == CodedHeight(GuestVideodec2.cpp#L544).So
sizeis always a multiple of 16. The first branch fires whenever one axis's crop adds up to a nonzero multiple of 16, and then it counts the crop a second time. That happens with deliberate SPS crops, or with a field-coded 1280x720 stream, which is coded at 736 rows.Example: a 1920x1072 stream coded as 1920x1088 with
frame_crop_top_offset = frame_crop_bottom_offset = 4. Videodec2 reports 1920x1088 with crop 8/8, andCodedSize(1088, 8, 8)returns 1104. Decode then needs 3,179,520 bytes. A buffer sized the way the PR's test sizes it (pitch × coded height × 1.5 = 3,133,440) gets 0x80C1000B on every picture. Each refused picture is lost, because Videodec2 has already dequeued it. With a larger buffer the caller gets frameHeight 1104, rows 1088-1103 repeat row 1087, and offsets 4/4 leave a 1088-row window instead of 1072. A left+right crop of 8+8 inflates the width the same way (1936, pitch 1984).I checked this with the PR's own test. I replaced only the shared fixture's SPS (bytes 10-34) with the same SPS cropping 4 at the top and 4 at the bottom:
67 64 00 0a ac d9 44 7f 29 70 11 00 00 03 00 01 00 00 03 00 3c 0f 12 25 96. The coded pictures don't change, so the existing hashes still apply. Atabf83aa,guest_videodecfails withdecode of unit 2 failed with -2134835189(0x80C1000B). With this change inMeasure, both the modified fixture and the original one pass:After that change,
CodedSize, the visible/coded split inGeometryand the row-repeat loops inCopyPicture(L271) no longer do anything and can be removed. The debt sentence at libSceVideodec.md#L13 about repeated crop rows and lost top/side rows is also wrong, because the caller always gets the whole coded picture. RunningtestDecodeon the cropped fixture as well would cover this case.Imported from boykopovar/AnyPS5. Originally posted by slick-daddy on 2026-10-20T22:13:40Z.
Verified: Videodec2 opens FFmpeg with
apply_cropping = 0and reports the AVFrame's size as-is, so the size is the coded size andcrop_*only describes the cropping rectangle. TheCodedSizeheuristic counted the crop a second time whenever it added up to a multiple of 16.Fixed in
51c6b3897:Measuretakes the frame's size as the coded size;CodedSize, the visible/coded split inGeometryand the row-repeat loops inCopyPictureare gone. The frame buffer now holds the coded picture, so the rows the crop covers are in it and the caller crops them.H264Fixture.hppgainscroppedStream()andaccessUnits()takes a stream), and the guest test runs the decode over that stream too. Atabf83aathat case fails withdecode of unit 2 failed with -2134835189(0x80C1000B); with the fix both streams pass.One correction to my earlier report: the
guest_videodec2failure I mentioned was a stale build in my tree, not a real failure. It passes with the current sources.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T22:28:47Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/tests/H264Fixture.hpp