|
|
|
@@ -37,15 +37,7 @@ if (NOT YUZU_USE_BUNDLED_FFMPEG)
|
|
|
|
|
elseif (NOT (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES CMAKE_SYSTEM_PROCESSOR
|
|
|
|
|
AND CMAKE_HOST_SYSTEM_NAME MATCHES CMAKE_SYSTEM_NAME))
|
|
|
|
|
string(TOLOWER "${CMAKE_SYSTEM_NAME}" FFmpeg_SYSTEM_NAME)
|
|
|
|
|
# All of these platforms are supported by ffmpeg as native build OSes
|
|
|
|
|
# anything else (like Redox or Managarm or PS4) is NOT natively supported
|
|
|
|
|
# hence, assume the "unix like" is just "none" for the sake of OUR sanity.
|
|
|
|
|
# If YOUR OS/platform has actual native support:
|
|
|
|
|
# 1. congrats
|
|
|
|
|
# 2. feel free to add it on the condition below
|
|
|
|
|
if (NOT (NETBSD OR SOLARIS OR FREEBSD
|
|
|
|
|
OR OPENBSD OR DRAGONFLYBSD OR HAIKU
|
|
|
|
|
OR LINUX OR MSYS OR WIN32 OR ANDROID OR APPLE))
|
|
|
|
|
if (FFmpeg_SYSTEM_NAME STREQUAL "openorbis" OR FFmpeg_SYSTEM_NAME STREQUAL "managarm")
|
|
|
|
|
set(FFmpeg_SYSTEM_NAME "none")
|
|
|
|
|
endif()
|
|
|
|
|
# TODO: Can we really do better? Auto-detection? Something clever?
|
|
|
|
@@ -64,26 +56,23 @@ if (NOT YUZU_USE_BUNDLED_FFMPEG)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (OPENORBIS OR MANAGARM OR EMSCRIPTEN)
|
|
|
|
|
if (OPENORBIS OR MANAGARM)
|
|
|
|
|
# Doesn't support VA-API, don't go thru the embarrassment of trying to enable it
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vaapi)
|
|
|
|
|
elseif (ANDROID)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
|
|
|
|
--disable-vaapi
|
|
|
|
|
--disnable-cuvid
|
|
|
|
|
--disnable-ffnvcodec
|
|
|
|
|
--disnable-nvdec
|
|
|
|
|
--disable-vulkan
|
|
|
|
|
--disable-libdrm)
|
|
|
|
|
elseif (UNIX)
|
|
|
|
|
--enable-mediacodec
|
|
|
|
|
--enable-jni
|
|
|
|
|
)
|
|
|
|
|
elseif (UNIX AND NOT DEFINED FFmpeg_IS_CROSS_COMPILING AND NOT ANDROID)
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
|
pkg_check_modules(LIBVA libva)
|
|
|
|
|
pkg_check_modules(CUDA cuda)
|
|
|
|
|
pkg_check_modules(FFNVCODEC ffnvcodec)
|
|
|
|
|
pkg_check_modules(VDPAU vdpau)
|
|
|
|
|
|
|
|
|
|
# X11 is "optional", some distros may opt for a super-fully wayland install...
|
|
|
|
|
find_package(X11)
|
|
|
|
|
if(X11_FOUND)
|
|
|
|
|
# Include X11 if possible, some APIs such as VDPAU heavily depend
|
|
|
|
|
# upon it's existence!
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${X11_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${X11_INCLUDE_DIRS})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${X11_LDFLAGS})
|
|
|
|
|
if (NOT APPLE)
|
|
|
|
|
# In Solaris needs explicit linking for ffmpeg which links to /lib/amd64/libX11.so
|
|
|
|
|
if(SOLARIS)
|
|
|
|
@@ -92,37 +81,32 @@ elseif (UNIX)
|
|
|
|
|
"${CMAKE_SYSROOT}/usr/lib/xorg/amd64/libdrm.so")
|
|
|
|
|
else()
|
|
|
|
|
pkg_check_modules(LIBDRM libdrm REQUIRED)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${LIBDRM_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${LIBDRM_INCLUDE_DIRS})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${LIBDRM_LDFLAGS})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES
|
|
|
|
|
${LIBDRM_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS
|
|
|
|
|
${LIBDRM_INCLUDE_DIRS})
|
|
|
|
|
endif()
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_FLAGS --enable-libdrm)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
|
|
|
|
--enable-libdrm)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
pkg_check_modules(LIBVA libva)
|
|
|
|
|
if(LIBVA_FOUND)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${LIBVA_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${LIBVA_INCLUDE_DIRS})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${LIBVA_LDFLAGS})
|
|
|
|
|
|
|
|
|
|
# Logically, they can only exist if libva itself exists
|
|
|
|
|
pkg_check_modules(LIBVA-DRM libva-drm REQUIRED)
|
|
|
|
|
pkg_check_modules(LIBVA-X11 libva-x11 REQUIRED)
|
|
|
|
|
if (LIBVA-DRM_FOUND)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${LIBVA-DRM_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${LIBVA-DRM_INCLUDE_DIRS})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${LIBVA-DRM_LDFLAGS})
|
|
|
|
|
endif()
|
|
|
|
|
if (LIBVA-X11_FOUND)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${LIBVA-X11_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${LIBVA-X11_INCLUDE_DIRS})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${LIBVA-X11_LDFLAGS})
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES
|
|
|
|
|
${X11_LIBRARIES}
|
|
|
|
|
${LIBVA-DRM_LIBRARIES}
|
|
|
|
|
${LIBVA-X11_LIBRARIES}
|
|
|
|
|
${LIBVA_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
|
|
|
|
--enable-hwaccel=h264_vaapi
|
|
|
|
|
--enable-hwaccel=vp8_vaapi
|
|
|
|
|
--enable-hwaccel=vp9_vaapi)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS
|
|
|
|
|
${X11_INCLUDE_DIRS}
|
|
|
|
|
${LIBVA-DRM_INCLUDE_DIRS}
|
|
|
|
|
${LIBVA-X11_INCLUDE_DIRS}
|
|
|
|
|
${LIBVA_INCLUDE_DIRS}
|
|
|
|
|
)
|
|
|
|
|
message(STATUS "ffmpeg: va-api libraries version ${LIBVA_VERSION} found")
|
|
|
|
|
else()
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vaapi)
|
|
|
|
@@ -133,12 +117,6 @@ elseif (UNIX)
|
|
|
|
|
message(WARNING "ffmpeg: X11 libraries not found, disabling VA-API...")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
pkg_check_modules(CUDA cuda)
|
|
|
|
|
pkg_check_modules(FFNVCODEC ffnvcodec)
|
|
|
|
|
pkg_check_modules(VDPAU vdpau)
|
|
|
|
|
pkg_check_modules(VULKAN vulkan)
|
|
|
|
|
find_package(spirv-headers)
|
|
|
|
|
|
|
|
|
|
if (FFNVCODEC_FOUND)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
|
|
|
|
--enable-cuvid
|
|
|
|
@@ -146,7 +124,8 @@ elseif (UNIX)
|
|
|
|
|
--enable-nvdec
|
|
|
|
|
--enable-hwaccel=h264_nvdec
|
|
|
|
|
--enable-hwaccel=vp8_nvdec
|
|
|
|
|
--enable-hwaccel=vp9_nvdec)
|
|
|
|
|
--enable-hwaccel=vp9_nvdec
|
|
|
|
|
)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${FFNVCODEC_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${FFNVCODEC_INCLUDE_DIRS})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${FFNVCODEC_LDFLAGS})
|
|
|
|
@@ -167,7 +146,8 @@ elseif (UNIX)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
|
|
|
|
--enable-vdpau
|
|
|
|
|
--enable-hwaccel=h264_vdpau
|
|
|
|
|
--enable-hwaccel=vp9_vdpau)
|
|
|
|
|
--enable-hwaccel=vp9_vdpau
|
|
|
|
|
)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${VDPAU_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${VDPAU_INCLUDE_DIRS})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${VDPAU_LDFLAGS})
|
|
|
|
@@ -176,24 +156,6 @@ elseif (UNIX)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vdpau)
|
|
|
|
|
message(WARNING "ffmpeg: libvdpau-dev not found, disabling Video Decode and Presentation API for Unix (VDPAU)...")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (VULKAN_FOUND AND NOT APPLE)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
|
|
|
|
--enable-vulkan
|
|
|
|
|
--enable-hwaccel=h264_vulkan
|
|
|
|
|
--enable-hwaccel=vp9_vulkan)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${VULKAN_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${VULKAN_INCLUDE_DIRS})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${VULKAN_LDFLAGS})
|
|
|
|
|
message(STATUS "ffmpeg: vulkan libraries version ${VULKAN_VERSION} found")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (SPIRV_HEADERS_FOUND)
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${SPIRV_HEADERS_LIBRARIES})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${SPIRV_HEADERS_INCLUDE_DIRS})
|
|
|
|
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${SPIRV_HEADERS_LDFLAGS})
|
|
|
|
|
message(STATUS "ffmpeg: spirv-headers libraries version ${SPIRV_HEADERS_VERSION} found")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (OPENORBIS)
|
|
|
|
@@ -202,28 +164,20 @@ if (OPENORBIS)
|
|
|
|
|
-lSceUserService
|
|
|
|
|
-lSceSysmodule
|
|
|
|
|
-lSceNet
|
|
|
|
|
-lSceLibcInternal)
|
|
|
|
|
-lSceLibcInternal
|
|
|
|
|
)
|
|
|
|
|
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS
|
|
|
|
|
--disable-pthreads
|
|
|
|
|
--extra-cflags=${CMAKE_SYSROOT}/usr/include
|
|
|
|
|
--extra-cxxflags=${CMAKE_SYSROOT}/usr/include
|
|
|
|
|
--extra-libs="${FFmpeg_CROSS_COMPILE_LIBS}")
|
|
|
|
|
--extra-libs="${FFmpeg_CROSS_COMPILE_LIBS}"
|
|
|
|
|
)
|
|
|
|
|
elseif (MANAGARM)
|
|
|
|
|
# Required for proper stuff
|
|
|
|
|
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS
|
|
|
|
|
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS
|
|
|
|
|
--disable-pthreads
|
|
|
|
|
--extra-libs="${FFmpeg_CROSS_COMPILE_LIBS}")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Usually used by Emscripten
|
|
|
|
|
if (DEFINED CMAKE_AR)
|
|
|
|
|
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS --ar=${CMAKE_AR})
|
|
|
|
|
endif()
|
|
|
|
|
if (DEFINED CMAKE_NM)
|
|
|
|
|
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS --nm=${CMAKE_NM})
|
|
|
|
|
endif()
|
|
|
|
|
if (DEFINED CMAKE_RANLIB)
|
|
|
|
|
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS --ranlib=${CMAKE_RANLIB})
|
|
|
|
|
--extra-libs="${FFmpeg_CROSS_COMPILE_LIBS}"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (YUZU_USE_BUNDLED_FFMPEG)
|
|
|
|
@@ -298,14 +252,8 @@ else()
|
|
|
|
|
|
|
|
|
|
# `configure` parameters builds only exactly what yuzu needs from FFmpeg
|
|
|
|
|
# `--disable-vdpau` is needed to avoid linking issues
|
|
|
|
|
set(FFmpeg_CC ${CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER})
|
|
|
|
|
set(FFmpeg_CXX ${CMAKE_CXX_COMPILER_LAUNCHER} ${CMAKE_CXX_COMPILER})
|
|
|
|
|
if (FFmpeg_IS_CROSS_COMPILING)
|
|
|
|
|
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS --ld=${CMAKE_LINKER})
|
|
|
|
|
endif ()
|
|
|
|
|
# TODO: This is a bit fragile, it depends on FFmpeg_HWACCEL_LDFLAGS being a list
|
|
|
|
|
# whereas CMAKE_C_FLAGS (and likewise) is meant to NOT be a list, but rather
|
|
|
|
|
# an elongated piece of string
|
|
|
|
|
set(FFmpeg_CC ${CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER})
|
|
|
|
|
set(FFmpeg_CXX ${CMAKE_CXX_COMPILER_LAUNCHER} ${CMAKE_CXX_COMPILER})
|
|
|
|
|
add_custom_command(
|
|
|
|
|
OUTPUT
|
|
|
|
|
${FFmpeg_MAKEFILE}
|
|
|
|
@@ -319,7 +267,6 @@ else()
|
|
|
|
|
--disable-ffprobe
|
|
|
|
|
--disable-network
|
|
|
|
|
--disable-swresample
|
|
|
|
|
--disable-iconv
|
|
|
|
|
--enable-decoder=h264
|
|
|
|
|
--enable-decoder=vp8
|
|
|
|
|
--enable-decoder=vp9
|
|
|
|
@@ -327,9 +274,10 @@ else()
|
|
|
|
|
--enable-pic
|
|
|
|
|
--cc=${FFmpeg_CC}
|
|
|
|
|
--cxx=${FFmpeg_CXX}
|
|
|
|
|
--ld=${CMAKE_LINKER}
|
|
|
|
|
--extra-cflags=${CMAKE_C_FLAGS}
|
|
|
|
|
--extra-cxxflags=${CMAKE_CXX_FLAGS}
|
|
|
|
|
--extra-ldflags="${FFmpeg_HWACCEL_LDFLAGS}"
|
|
|
|
|
--extra-ldflags=${CMAKE_C_LINK_FLAGS}
|
|
|
|
|
${FFmpeg_HWACCEL_FLAGS}
|
|
|
|
|
${FFmpeg_CROSS_COMPILE_FLAGS}
|
|
|
|
|
WORKING_DIRECTORY
|
|
|
|
@@ -337,33 +285,31 @@ else()
|
|
|
|
|
)
|
|
|
|
|
unset(FFmpeg_CC)
|
|
|
|
|
unset(FFmpeg_CXX)
|
|
|
|
|
unset(FFmpeg_LD)
|
|
|
|
|
unset(FFmpeg_HWACCEL_FLAGS)
|
|
|
|
|
unset(FFmpeg_CROSS_COMPILE_FLAGS)
|
|
|
|
|
|
|
|
|
|
# Workaround for Ubuntu 18.04's older version of make not being able to call make as a child
|
|
|
|
|
# with context of the jobserver. Also helps ninja users.
|
|
|
|
|
cmake_host_system_information(RESULT SYSTEM_THREADS QUERY NUMBER_OF_LOGICAL_CORES)
|
|
|
|
|
execute_process(
|
|
|
|
|
COMMAND
|
|
|
|
|
nproc
|
|
|
|
|
OUTPUT_VARIABLE
|
|
|
|
|
SYSTEM_THREADS)
|
|
|
|
|
|
|
|
|
|
set(FFmpeg_BUILD_LIBRARIES ${FFmpeg_LIBRARIES})
|
|
|
|
|
|
|
|
|
|
# BSD make or Solaris make don't support ffmpeg make-j8
|
|
|
|
|
if (DEFINED SYSTEM_THREADS AND (LINUX OR ANDROID OR APPLE OR WIN32))
|
|
|
|
|
if (LINUX OR ANDROID OR APPLE OR WIN32 OR FREEBSD)
|
|
|
|
|
set(FFmpeg_MAKE_ARGS -j${SYSTEM_THREADS})
|
|
|
|
|
else()
|
|
|
|
|
set(FFmpeg_MAKE_ARGS "")
|
|
|
|
|
endif()
|
|
|
|
|
find_program(MAKE gmake)
|
|
|
|
|
if (NOT MAKE_FOUND)
|
|
|
|
|
# Arch famously names 'gmake' as 'make'
|
|
|
|
|
find_program(MAKE make REQUIRED)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
|
OUTPUT
|
|
|
|
|
${FFmpeg_BUILD_LIBRARIES}
|
|
|
|
|
COMMAND
|
|
|
|
|
${MAKE} ${FFmpeg_MAKE_ARGS}
|
|
|
|
|
gmake ${FFmpeg_MAKE_ARGS}
|
|
|
|
|
WORKING_DIRECTORY
|
|
|
|
|
${FFmpeg_BUILD_DIR}
|
|
|
|
|
)
|
|
|
|
|