fix(avplayer): add decode-ahead buffers for application video output #591
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/591"
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 hamb3r on 2026-10-05T00:10:25Z.
What
Applications can request as few as 2 video output buffers in AvPlayer settings. When the application holds one buffer for display and uses
SyncModeNone(dropping late frames on its own, common in Unity titles), a small decoding or scheduling delay causes playback to fall behind the game clock. The application then drops late frames faster than AvPlayer can recover, starving the video output permanently while audio continues.Adds 4 internal decode-ahead frames to the video buffer pool (
settings.videoBuffers + VideoDecodeAheadFrames) while keeping the application's requested output-buffer retained count semantics unchanged.Ported from OverkillLabs2/SoS-PS5#13 by @saulob.
Tested
Windows 10 / 11, AMD Ryzen 7 7700, NVIDIA GeForce RTX 3080. Tested with God of War: Sons of Sparta (PPSA28997): verified continuous, stutter-free playback of the intro video sequences and logo sections without freezing or stalls. Built with MinGW-w64 GCC 15.2.0.
git diff --checkis clean.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T01:18:37Z.
Thanks, the problem is real: with the minimum of 2 output buffers and nothing retained, one buffer is the frame the title holds and the decoder has a single spare, so it can only ever be one frame ahead.
One thing before it goes in: the 4 extra buffers come from the title's
allocate_texturecallback in its memory replacement, eachpitch * height * 3 / 2bytes (about 3 MB at 1080p, so about 12 MB more per player). A title that sizes its AvPlayer memory for the buffer count it asked for would now getSCE_AVPLAYER_ERROR_NO_MEMORYfromsceAvPlayerAddSourcewhere it worked before. How many buffers the console's player requests isn't known, so I'd either:num_output_video_framebuffers+ 4 video buffers from the memory replacement and that the console's count is unknown, orEither is fine with me. A test row in
guest_avplayerwith 2 buffers and sync mode none that takes frames late would also show the stall and the fix, but that's optional.PPSA21564 plays its intro video through
sceAvPlayerInitandsceAvPlayerGetVideoDataEx, so this path matters for my runs; I'll check that video here once it's updated. The CI run still needs workflow approval.Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-05T01:59:46Z.
Implemented in commit cf10b5e.
The Source.cpp and GuestAvPlayer.cpp translation units compile successfully. A full local link is currently blocked by the prebuilt FFmpeg archives referencing MSVC security-cookie symbols that are unavailable in this MinGW link setup; CI should provide the final build result.
@oneandonlydean, this is ready for review. Please verify the memory behavior and the PPSA21564 video path once CI completes.
Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-05T02:07:17Z.
Follow-up fix in bb165d2a fixes the CI regression.
The /app0/missing.mp4 line is intentional: guest_avplayer verifies that a missing source returns OperationFailed. The actual failure was in the new memory-limit test helper: it changed the existing texture allocation counter from cumulative to active, while an older assertion relies on the cumulative count. The helper now counts active texture blocks separately and preserves the existing counter semantics.
The updated branch is pushed and CI is running again.
Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-05T02:13:51Z.
Second follow-up fix in 86e5ae5c fixes the remaining guest_avplayer failure.
The texture limit check was still using the historical allocation counter, so later test cases inherited the count from earlier players and the limited allocator rejected even the mandatory buffers. Both the limit check and the assertion now use the current number of active texture blocks; the existing cumulative counter remains unchanged.
This was a test helper regression, not a CI infrastructure failure. The branch is pushed and CI is running again.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T02:47:21Z.
Thanks, making the extra buffers optional and adding the TechnicalDebt line is what I had in mind, and rolling back a partial set keeps the title's memory exactly as it asked for.
The first push failed
guest_avplayerbecause the new decrement inReleasebroke main'sallocations.textures >= 4check inTestPlayback; your last commit (86e5ae5) counts the live texture blocks for the limit instead and leaves the total alone, which fixes it. On this headguest_avplayerpasses here three times in a row, and your new test fails on main's code (main never allocates more than the 2 buffers, so the 6 buffer case times out), so it covers the change.Since PPSA21564 plays its intro video through
sceAvPlayerAddSourceandsceAvPlayerGetVideoDataEx, I'll check that video with this change before it's merged. CI is green on this head.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T05:04:07Z.
Gated on PPSA21564, whose intro video goes through AvPlayer: the video plays cleanly, no visual or FPS change.