feat(avplayer): decode H.264 and AAC with FFmpeg #307
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/307"
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 oneandonlydean on 2026-10-02T01:12:28Z.
What
Replaces the AvPlayer from #80 with one that decodes. #80 implements the player's state machine but has no decoder: whatever the source, it plays a fixed clip of 120 black 1920x1080 frames (about 4 s) on a wall clock, never delivers audio, and then reports the end of the stream. A title that shows its intro or tutorial movies through AvPlayer gets about 4 s of black and silence instead. It also logs unconditionally (
[AVP],[AVPLIFE]), and none of this is listed in TechnicalDebt.The player here is a port of shadPS4's AvPlayer (its SPDX header is kept, as in libSceFont) on top of FFmpeg:
sceAvPlayerAddSource(Ex)opens the MP4 with libavformat, by path throughResolvePath_nid_no_patchor through the title's file replacement callbacks (a custom AVIOContext). H.264, HEVC and AAC streams are reported; other streams are left out.num_output_video_framebuffers, clamped to 2..16). Audio is converted to interleaved 16-bit PCM in chunks of 1024 samples, into buffers from the title's plain allocator.sceAvPlayerSetAvSyncMode(1)hands out frames as soon as they are decoded.num_output_video_framebuffers - 3before it are held back.sceAvPlayerJumpToTimeseeks and reportsWAR_JUMP_COMPLETE, looping reportsWAR_LOOPING_BACK, and the end of the file fires the STOP event.auto_start, the player enables a video stream and an audio stream, preferringdefault_language, then starts.Build:
Export.cpp, as on main since #80, and both export the same set of functions. Both build the shared player inlibSceAvPlayer/srcthroughAvPlayerLibrary.cmake(likeFontLibrary.cmake), with hidden visibility, and link the sharedffmpegtarget from ffmpeg-core, as libSceVideodec2 does.network.oandurl.oreferencesocketandgetaddrinfo), so on MinGW theffmpegtarget also linksws2_32, next to bcrypt, ole32 and user32. No other library on main uses libavformat yet.Exports, compared with #80:
GetVideoData,GetVideoDataExGetAudioDataGetStreamInfoGetStreamInfoExthis_sizeis left as the caller set itChangeStreamSetTrickSpeedStartExStartStart; the start info is ignoredInit,InitExwithout allocatorsSetAvailableBandwidth,SetLogCallbackAddSourcewith an HLS source (.m3u8or source type 8)IsActive,CurrentTime,Pause,Resume,StopInitExreadsSceAvPlayerInitDataExwith its own layout (the language pointer, then the per-thread priorities and affinities, then the frame buffer count and auto start), where #80 read it as theInitDatalayout after the size.Struct checks: #80's
static_asserts move next to the types in SceTypes.hpp:SceAvPlayerFrameInfo(40 bytes, timestamp at 16),SceAvPlayerVideoEx(80, crop offsets at 20, pitch at 36) andSceAvPlayerFrameInfoEx(104, details at 24). New ones coverSceAvPlayerStreamInfo(32) andSceAvPlayerStreamInfoEx(104, details at 16, duration at 96). #80's check for a double frame rate at offset 48 ofSceAvPlayerVideoExis not kept: SceTypes.hpp has a 32-bitframerateat offset 16 instead, and which is right is unknown, so the frame rate is left zero.TechnicalDebt:
SetLogCallbacknever calls its callback (the player produces no log messages);SetAvailableBandwidthhas no effect (it governs HLS, whichAddSourcedoes not implement); negative trick speeds deliver no frames.StartExstart info layout; what the library does without a memory replacement; the frame rate field ofSceAvPlayerVideoEx.Tested
guest_avplayer(ctest) plays a 5986-byte MP4 embedded in the test as bytes, like GuestVideodec2's stream, so it runs on CI without an encoder. The movie is 1 s long: 100x60 H.264 at 30 fps with B-frames, whose two halves change brightness every frame; a silent English stereo AAC track; and a French mono AAC track with a 440 Hz tone. The test writes it toapp0and covers:WAR_LOOPING_BACK;ChangeStreambefore start and during playback (audio switches to the French track's audible, mono,fra-tagged chunks, with no jump warning);StartEx;InitandInitExwithout allocators (frames from the guest heap); file replacement with auto start;ctest: 97/97 pass. Thelibstarget builds and the NID patcher accepts both libraries.operator new, notaligned_alloc; paths go to FFmpeg as UTF-8file:URLs.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 repositoryffmpegtarget)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-02T01:12:50Z.
Progress report (
5026351→b62d02c)📈 System libraries: 80.56% (+0.19%, +28 implemented functions)
✅ 28 implemented
sceAvPlayerAddSourcesceAvPlayerAddSourceExsceAvPlayerChangeStreamsceAvPlayerClosesceAvPlayerCurrentTimesceAvPlayerDisableStreamsceAvPlayerEnableStreamsceAvPlayerGetAudioDatasceAvPlayerGetStreamInfosceAvPlayerGetStreamInfoExsceAvPlayerGetVideoDatasceAvPlayerGetVideoDataExsceAvPlayerInitsceAvPlayerInitExsceAvPlayerIsActivesceAvPlayerJumpToTimesceAvPlayerPausesceAvPlayerPostInitsceAvPlayerResumesceAvPlayerSetAvSyncModesceAvPlayerSetAvailableBandwidthsceAvPlayerSetLogCallbacksceAvPlayerSetLoopingsceAvPlayerSetTrickSpeedsceAvPlayerStartsceAvPlayerStartExsceAvPlayerStopsceAvPlayerStreamCount