From f8b395082971fbc925c4bb7075b51a1e0db58432 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Tue, 20 Aug 2019 14:45:39 +0800 Subject: [PATCH 1/3] CMake: separate options for FFmpeg decoder/dumper Separate options are now provided for FFmpeg AAC audio decoder and FFmpeg video dumper. This allows users to configure Citra with greater freedom. Also, previously for Linux builds, AAC decoder is accidentally enabled along with the dumper, which could potentially cause patent issues (?). This commit fixes it by only enabling video dumper. --- .travis/linux-flatpak/generate-data.sh | 2 +- .travis/linux-mingw/docker.sh | 2 +- .travis/linux/docker.sh | 2 +- .travis/macos/build.sh | 2 +- CMakeLists.txt | 11 +++++++---- appveyor.yml | 4 ++-- src/audio_core/CMakeLists.txt | 2 +- src/citra_qt/main.cpp | 2 +- src/core/CMakeLists.txt | 2 +- src/core/core.cpp | 4 ++-- 10 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.travis/linux-flatpak/generate-data.sh b/.travis/linux-flatpak/generate-data.sh index 066534016..aaecd0500 100644 --- a/.travis/linux-flatpak/generate-data.sh +++ b/.travis/linux-flatpak/generate-data.sh @@ -87,7 +87,7 @@ cat > /tmp/org.citra.$REPO_NAME.json < "$HOME/.ccache/ccache.conf" mkdir build && cd build -cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_MF=ON -DENABLE_FFMPEG=ON -DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE -DCOMPILE_WITH_DWARF=OFF +cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_MF=ON -DENABLE_FFMPEG_VIDEO_DUMPER=ON -DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE -DCOMPILE_WITH_DWARF=OFF ninja echo "Tests skipped" diff --git a/.travis/linux/docker.sh b/.travis/linux/docker.sh index 171c8706a..4f4d63ed5 100755 --- a/.travis/linux/docker.sh +++ b/.travis/linux/docker.sh @@ -3,7 +3,7 @@ cd /citra mkdir build && cd build -cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_FFMPEG=ON +cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_FFMPEG_VIDEO_DUMPER=ON ninja ctest -VV -C Release diff --git a/.travis/macos/build.sh b/.travis/macos/build.sh index 5bac2aa9a..c1093b7ca 100755 --- a/.travis/macos/build.sh +++ b/.travis/macos/build.sh @@ -8,7 +8,7 @@ export PATH="/usr/local/opt/ccache/libexec:$PATH" # TODO: Build using ninja instead of make mkdir build && cd build -cmake .. -DCMAKE_OSX_ARCHITECTURES="x86_64;x86_64h" -DCMAKE_BUILD_TYPE=Release -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_FFMPEG=ON +cmake .. -DCMAKE_OSX_ARCHITECTURES="x86_64;x86_64h" -DCMAKE_BUILD_TYPE=Release -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_FFMPEG_AUDIO_DECODER=ON -DENABLE_FFMPEG_VIDEO_DUMPER=ON make -j4 ctest -VV -C Release diff --git a/CMakeLists.txt b/CMakeLists.txt index ce6cf9ee8..ad09bb382 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,9 @@ option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) -option(ENABLE_FFMPEG "Enable FFmpeg decoder/encoder" OFF) -CMAKE_DEPENDENT_OPTION(CITRA_USE_BUNDLED_FFMPEG "Download bundled FFmpeg binaries" ON "ENABLE_FFMPEG;MSVC" OFF) +option(ENABLE_FFMPEG_AUDIO_DECODER "Enable FFmpeg audio (AAC) decoder" OFF) +option(ENABLE_FFMPEG_VIDEO_DUMPER "Enable FFmpeg video dumper" OFF) +CMAKE_DEPENDENT_OPTION(CITRA_USE_BUNDLED_FFMPEG "Download bundled FFmpeg binaries" ON "ENABLE_FFMPEG_AUDIO_DECODER OR ENABLE_FFMPEG_VIDEO_DUMPING;MSVC" OFF) option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF) @@ -189,7 +190,7 @@ if (ENABLE_QT) endif() endif() -if (ENABLE_FFMPEG) +if (ENABLE_FFMPEG_AUDIO_DECODER OR ENABLE_FFMPEG_VIDEO_DUMPER) if (CITRA_USE_BUNDLED_FFMPEG) if ((MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1930) AND ARCHITECTURE_x86_64) set(FFmpeg_VER "ffmpeg-4.1-win64") @@ -207,8 +208,10 @@ if (ENABLE_FFMPEG) if ("${FFmpeg_avcodec_VERSION}" VERSION_LESS "57.48.101") message(FATAL_ERROR "Found version for libavcodec is too low. The required version is at least 57.48.101 (included in FFmpeg 3.1 and later).") endif() +endif() - add_definitions(-DENABLE_FFMPEG) +if (ENABLE_FFMPEG_VIDEO_DUMPER) + add_definitions(-DENABLE_FFMPEG_VIDEO_DUMPER) endif() # Platform-specific library requirements diff --git a/appveyor.yml b/appveyor.yml index 688713132..d8cbfc35f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -40,9 +40,9 @@ before_build: $COMPAT = if ($env:ENABLE_COMPATIBILITY_REPORTING -eq $null) {0} else {$env:ENABLE_COMPATIBILITY_REPORTING} if ($env:BUILD_TYPE -eq 'msvc') { # redirect stderr and change the exit code to prevent powershell from cancelling the build if cmake prints a warning - cmd /C 'cmake -G "Visual Studio 15 2017 Win64" -DCITRA_USE_BUNDLED_QT=1 -DCITRA_USE_BUNDLED_SDL2=1 -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_MF=ON -DENABLE_FFMPEG=ON .. 2>&1 && exit 0' + cmd /C 'cmake -G "Visual Studio 15 2017 Win64" -DCITRA_USE_BUNDLED_QT=1 -DCITRA_USE_BUNDLED_SDL2=1 -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_MF=ON -DENABLE_FFMPEG_VIDEO_DUMPER=ON .. 2>&1 && exit 0' } else { - C:\msys64\usr\bin\bash.exe -lc "cmake -G 'MSYS Makefiles' -DCMAKE_BUILD_TYPE=Release -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_MF=ON -DENABLE_FFMPEG=ON .. 2>&1" + C:\msys64\usr\bin\bash.exe -lc "cmake -G 'MSYS Makefiles' -DCMAKE_BUILD_TYPE=Release -DENABLE_QT_TRANSLATION=ON -DCITRA_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_MF=ON -DENABLE_FFMPEG_VIDEO_DUMPER=ON .. 2>&1" } - cd .. diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index e820f9670..4e0c9f4de 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -47,7 +47,7 @@ if(ENABLE_MF) ) target_link_libraries(audio_core PRIVATE mf.lib mfplat.lib mfuuid.lib) target_compile_definitions(audio_core PUBLIC HAVE_MF) -elseif(ENABLE_FFMPEG) +elseif(ENABLE_FFMPEG_AUDIO_DECODER) target_sources(audio_core PRIVATE hle/ffmpeg_decoder.cpp hle/ffmpeg_decoder.h diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index d1a31fa5c..ed609fce3 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -606,7 +606,7 @@ void GMainWindow::ConnectMenuEvents() { connect(ui.action_Capture_Screenshot, &QAction::triggered, this, &GMainWindow::OnCaptureScreenshot); -#ifndef ENABLE_FFMPEG +#ifndef ENABLE_FFMPEG_VIDEO_DUMPER ui.action_Dump_Video->setEnabled(false); #endif connect(ui.action_Dump_Video, &QAction::triggered, [this] { diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 0c7bbbecf..d303ac3ad 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -446,7 +446,7 @@ add_library(core STATIC tracer/recorder.h ) -if (ENABLE_FFMPEG) +if (ENABLE_FFMPEG_VIDEO_DUMPER) target_sources(core PRIVATE dumping/ffmpeg_backend.cpp dumping/ffmpeg_backend.h diff --git a/src/core/core.cpp b/src/core/core.cpp index 162a4d2b1..03dfc59c9 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -17,7 +17,7 @@ #include "core/core.h" #include "core/core_timing.h" #include "core/dumping/backend.h" -#ifdef ENABLE_FFMPEG +#ifdef ENABLE_FFMPEG_VIDEO_DUMPER #include "core/dumping/ffmpeg_backend.h" #endif #include "core/gdbstub/gdbstub.h" @@ -231,7 +231,7 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, u32 system_mo return result; } -#ifdef ENABLE_FFMPEG +#ifdef ENABLE_FFMPEG_VIDEO_DUMPER video_dumper = std::make_unique(); #else video_dumper = std::make_unique(); From ce3459192e46bf48235a7dc0b53d046c17d7134d Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Tue, 20 Aug 2019 14:58:43 +0800 Subject: [PATCH 2/3] fixup! CMake: separate options for FFmpeg decoder/dumper --- src/core/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d303ac3ad..12e923e1e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -472,6 +472,6 @@ if (ARCHITECTURE_x86_64) target_link_libraries(core PRIVATE dynarmic) endif() -if (ENABLE_FFMPEG) +if (ENABLE_FFMPEG_VIDEO_DUMPER) target_link_libraries(core PRIVATE FFmpeg::avcodec FFmpeg::avformat FFmpeg::swscale FFmpeg::swresample FFmpeg::avutil) endif() From 609bd71da341a023c8e511af252d573e737805e3 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Tue, 20 Aug 2019 15:26:59 +0800 Subject: [PATCH 3/3] Fix dependent options --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad09bb382..b1afb4b82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,12 @@ option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) option(ENABLE_FFMPEG_AUDIO_DECODER "Enable FFmpeg audio (AAC) decoder" OFF) option(ENABLE_FFMPEG_VIDEO_DUMPER "Enable FFmpeg video dumper" OFF) -CMAKE_DEPENDENT_OPTION(CITRA_USE_BUNDLED_FFMPEG "Download bundled FFmpeg binaries" ON "ENABLE_FFMPEG_AUDIO_DECODER OR ENABLE_FFMPEG_VIDEO_DUMPING;MSVC" OFF) + +if (ENABLE_FFMPEG_AUDIO_DECODER OR ENABLE_FFMPEG_VIDEO_DUMPER) + set(ENABLE_FFMPEG ON) +endif() + +CMAKE_DEPENDENT_OPTION(CITRA_USE_BUNDLED_FFMPEG "Download bundled FFmpeg binaries" ON "ENABLE_FFMPEG;MSVC" OFF) option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF) @@ -190,7 +195,7 @@ if (ENABLE_QT) endif() endif() -if (ENABLE_FFMPEG_AUDIO_DECODER OR ENABLE_FFMPEG_VIDEO_DUMPER) +if (ENABLE_FFMPEG) if (CITRA_USE_BUNDLED_FFMPEG) if ((MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1930) AND ARCHITECTURE_x86_64) set(FFmpeg_VER "ffmpeg-4.1-win64")