build(videodec2): build FFmpeg from a pinned submodule

Add FFmpeg n9.0.2 as the 3rdparty/FFmpeg submodule (shallow) and build
it with ExternalProject_Add through its own configure and make, instead
of using the system libraries from pkg-config.

Only avcodec, avutil and swscale are built, with the H.264 decoder as
the single component (--disable-everything, --disable-autodetect), as
static PIC archives linked into libSceVideodec2.prx with
--exclude-libs,ALL. Without nasm the x86 assembly is disabled.
ANYPS5_ENABLE_FFMPEG=OFF, or a missing sh/make, keeps the black-picture
fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pacuka
2026-09-28 21:04:08 +02:00
committed by boykopovar
parent a38ef6132f
commit 62cb92716a
4 changed files with 74 additions and 8 deletions
+4
View File
@@ -28,3 +28,7 @@
[submodule "3rdparty/stb"]
path = 3rdparty/stb
url = https://github.com/nothings/stb.git
[submodule "3rdparty/FFmpeg"]
path = 3rdparty/FFmpeg
url = https://github.com/FFmpeg/FFmpeg.git
shallow = true
Vendored Submodule
+1
Submodule 3rdparty/FFmpeg added at 291f96f792
+68 -8
View File
@@ -5,15 +5,75 @@ add_library(libSceVideodec2 SHARED EXCLUDE_FROM_ALL
target_include_directories(libSceVideodec2 PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceVideodec2)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(VIDEODEC2_FFMPEG QUIET IMPORTED_TARGET libavcodec libavutil libswscale)
endif()
if(VIDEODEC2_FFMPEG_FOUND)
target_link_libraries(libSceVideodec2 PRIVATE PkgConfig::VIDEODEC2_FFMPEG)
option(ANYPS5_ENABLE_FFMPEG "Build FFmpeg from 3rdparty/FFmpeg for H.264 decoding in libSceVideodec2" ON)
set(VIDEODEC2_FFMPEG_SOURCE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/FFmpeg)
find_program(VIDEODEC2_SH sh)
find_program(VIDEODEC2_MAKE NAMES make mingw32-make)
if(ANYPS5_ENABLE_FFMPEG AND EXISTS ${VIDEODEC2_FFMPEG_SOURCE_DIR}/configure AND VIDEODEC2_SH AND VIDEODEC2_MAKE)
include(ExternalProject)
set(VIDEODEC2_FFMPEG_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/ffmpeg)
set(VIDEODEC2_FFMPEG_INCLUDE_DIR ${VIDEODEC2_FFMPEG_PREFIX}/include)
set(VIDEODEC2_FFMPEG_LIB_DIR ${VIDEODEC2_FFMPEG_PREFIX}/lib)
set(VIDEODEC2_FFMPEG_LIBS
${VIDEODEC2_FFMPEG_LIB_DIR}/libavcodec.a
${VIDEODEC2_FFMPEG_LIB_DIR}/libswscale.a
${VIDEODEC2_FFMPEG_LIB_DIR}/libavutil.a
)
set(VIDEODEC2_FFMPEG_OPTIONS
--prefix=${VIDEODEC2_FFMPEG_PREFIX}
--enable-static
--disable-shared
--enable-pic
--disable-autodetect
--disable-everything
--disable-programs
--disable-doc
--disable-network
--disable-avdevice
--disable-avformat
--disable-avfilter
--disable-swresample
--enable-avcodec
--enable-avutil
--enable-swscale
--enable-decoder=h264
)
if(CMAKE_C_COMPILER)
list(APPEND VIDEODEC2_FFMPEG_OPTIONS --cc=${CMAKE_C_COMPILER})
endif()
find_program(VIDEODEC2_NASM nasm)
if(NOT VIDEODEC2_NASM)
list(APPEND VIDEODEC2_FFMPEG_OPTIONS --disable-x86asm)
endif()
cmake_host_system_information(RESULT VIDEODEC2_JOBS QUERY NUMBER_OF_LOGICAL_CORES)
ExternalProject_Add(ffmpeg_h264
SOURCE_DIR ${VIDEODEC2_FFMPEG_SOURCE_DIR}
PREFIX ${VIDEODEC2_FFMPEG_PREFIX}
BINARY_DIR ${VIDEODEC2_FFMPEG_PREFIX}/build
CONFIGURE_COMMAND ${VIDEODEC2_SH} ${VIDEODEC2_FFMPEG_SOURCE_DIR}/configure ${VIDEODEC2_FFMPEG_OPTIONS}
BUILD_COMMAND ${VIDEODEC2_MAKE} -j${VIDEODEC2_JOBS}
INSTALL_COMMAND ${VIDEODEC2_MAKE} install
BUILD_BYPRODUCTS ${VIDEODEC2_FFMPEG_LIBS}
EXCLUDE_FROM_ALL ON
)
file(MAKE_DIRECTORY ${VIDEODEC2_FFMPEG_INCLUDE_DIR})
add_dependencies(libSceVideodec2 ffmpeg_h264)
target_include_directories(libSceVideodec2 SYSTEM PRIVATE ${VIDEODEC2_FFMPEG_INCLUDE_DIR})
target_link_libraries(libSceVideodec2 PRIVATE ${VIDEODEC2_FFMPEG_LIBS})
if(NOT WIN32)
target_link_libraries(libSceVideodec2 PRIVATE m)
endif()
target_link_options(libSceVideodec2 PRIVATE -Wl,--exclude-libs,ALL)
target_compile_definitions(libSceVideodec2 PRIVATE APS5_HAVE_FFMPEG=1)
set(VIDEODEC2_HAS_FFMPEG ON PARENT_SCOPE)
message(STATUS "libSceVideodec2: H.264 decoding with FFmpeg ${VIDEODEC2_FFMPEG_libavcodec_VERSION}")
message(STATUS "libSceVideodec2: H.264 decoding with FFmpeg from 3rdparty/FFmpeg")
else()
message(STATUS "libSceVideodec2: FFmpeg not found, decoders return black pictures")
message(STATUS "libSceVideodec2: FFmpeg disabled or 3rdparty/FFmpeg missing, decoders return black pictures")
endif()
+1
View File
@@ -13,6 +13,7 @@
Throughout the project, every function at every stage either **does exactly what it's supposed to or throws an exception**. Everywhere... except:
- [libSceSaveDataDialog.native](../../core/libs/prx/libSceSaveDataDialog.native/Export.cpp)
- [libSceCommonDialog](../../core/libs/prx/libSceCommonDialog/Export.cpp)
- [libSceVideodec2](../../core/libs/prx/libSceVideodec2/Export.cpp) returns black pictures for every codec except H.264, and for H.264 too when [FFmpeg](../../3rdparty/FFmpeg) is not built (`ANYPS5_ENABLE_FFMPEG=OFF`, or no `sh`/`make`, as with a plain MinGW setup)
- The shader recompiler [skips baryctric coordinates](../../core/shader/recompiler/Recompiler.cpp) (is not even passed to SpirvTargetOptions at row 212).
### Unknown function info