feat(videodec2): decode H.264 with FFmpeg #42
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/42"
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 Pacuka on 2026-09-27T19:52:21Z.
What
This adds libSceVideodec2 with real H.264 decoding through FFmpeg (libavcodec, libavutil, libswscale). FFmpeg is built from source as a submodule.
3rdparty/FFmpeg.ExternalProject_Addruns FFmpeg's ownconfigureandmake. Only avcodec, avutil and swscale are built, and the H.264 decoder is the only component (--disable-everything --enable-decoder=h264 --disable-autodetect). They are static PIC archives linked intolibSceVideodec2.prxwith--exclude-libs,ALL, so the prx has no FFmpeg runtime dependency and exports no FFmpeg symbols. Without nasm, the x86 assembly is disabled.framePitch * frameHeight). Titles read it there, so a 1080-row movie has its chroma at row 1080, not 1088.isAccepted/isValidsay whether the buffer was used. Flush drains the reordered pictures one per call. Reset clears the decoder.-DANYPS5_ENABLE_FFMPEG=OFF, or withoutsh/make(plain MinGW), the module still builds. Decoders then return black NV12 pictures that carry the timestamps, so players still advance through a movie. This fallback and the non-H.264 codecs are listed under silent stubs in TechnicalDebt.md.Limitations: H.264 only (HEVC and other codec types get the black-picture behaviour); decoding runs on the CPU with FFmpeg slice threads.
Tested
Linux (CachyOS, GCC), clean build directory.
guest_videodec2test. It decodes an embedded 64x40 High-profile stream with 2 B-frames, once as Annex B and once as length-prefixed. For every picture it checks the geometry, the display order, the timestamps and attached data, and the IDR/profile flags, and it compares a hash of the NV12 against the reference from the ffmpeg CLI. Passes with the submodule build. I checked that the test fails when the chroma plane is moved to the aligned height.libs; ctest passes 57/57. FFmpeg's configure and build take about 20 s.-DANYPS5_ENABLE_FFMPEG=OFFalso builds.shandmake(MSYS2) for FFmpeg's configure; without them the fallback is used.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 repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-09-27T21:27:22Z.
Is it possible to use ffmpeg from source instead of the system version? As a new submodule. And if we compile from source, I don't think the whole ffmpeg is needed, just avcodec, avutil, swscale and H.264. But the problem is that FFmpeg is not a CMake project.
Imported from boykopovar/AnyPS5. Originally posted by julienlgy on 2026-09-28T12:09:24Z.
Add FFmpeg as a pinned submodule and build only the required H.264 decoder, avcodec, avutil and swscale with CMake’s ExternalProject_Add, which can run FFmpeg’s own configure and Make build without requiring FFmpeg to support CMake.
Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-09-28T19:05:11Z.
Done: FFmpeg n9.0.2 is now a pinned shallow submodule in
3rdparty/FFmpeg, built withExternalProject_Addthrough its own configure/make (thanks @julienlgy). Only avcodec, avutil and swscale are built, with the H.264 decoder as the single component, as static archives linked into the prx. The system FFmpeg is no longer used. Also rebased onto main. Details are in the updated description.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-09-28T19:05:19Z.
Progress report (
fc05962→1e1f056)📈 System libraries: 74.71% (+0.08%, +10 implemented functions)
✅ 10 implemented
sceVideodec2AllocateComputeQueue_nid_postfixsceVideodec2CreateDecoder_nid_postfixsceVideodec2Decode_nid_postfixsceVideodec2DeleteDecoder_nid_postfixsceVideodec2Flush_nid_postfixsceVideodec2GetPictureInfo_nid_postfixsceVideodec2QueryComputeMemoryInfo_nid_postfixsceVideodec2QueryDecoderMemoryInfo_nid_postfixsceVideodec2ReleaseComputeQueue_nid_postfixsceVideodec2Reset_nid_postfixImported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-09-28T22:28:50Z.
Can you resolve conflicts? I'll test it.
Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-09-29T15:41:24Z.
Rebased onto current main and resolved the conflicts (.gitmodules, TechnicalDebt.md moved to docs/dev). Build and ctest (61/61) pass on Linux. Ready for testing.
Imported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-09-30T08:44:15Z.
STL1te proposed a more lightweight approach in #153. It eliminates the need to rely on the system ffmpeg and build it from source. The submodule is already added and used in main. Please adapt your changes to this.
Imported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-09-30T14:43:31Z.
I've switched to using the ffmpeg-core submodule and removed the black frame fallback. If anything is wrong, please open a new PR.