From 81ef795220fcc688010c7aa94d999c098be8d6aa Mon Sep 17 00:00:00 2001 From: Seungyun Lee Date: Wed, 4 Sep 2024 23:44:07 +0900 Subject: [PATCH 1/4] ci: install VCPKG on macOS before building --- .github/workflows/build.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a314722..595a152 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,13 +27,13 @@ jobs: - build: macos os: macos-latest triplet: osx-release - vcpkg-root: /usr/local/share/vcpkg + vcpkg-root: /Users/runner/vcpkg extra-args: "" - build: macos os: macos-latest arch: universal triplet: osx-release - vcpkg-root: /usr/local/share/vcpkg + vcpkg-root: /Users/runner/vcpkg extra-args: --overlay-triplets=./triplets steps: @@ -41,7 +41,9 @@ jobs: - name: Set up build environment (macos-latest) run: | - brew install nasm + brew install nasm vcpkg + git clone https://github.com/microsoft/vcpkg "$HOME/vcpkg" + echo VCPKG_ROOT="$HOME/vcpkg" >> $GITHUB_ENV if: matrix.os == 'macos-latest' - name: Set up build environment (ubuntu-latest) From 61f008bd7a97041ee6be439094a4a5a298b46cb2 Mon Sep 17 00:00:00 2001 From: Seungyun Lee Date: Thu, 5 Sep 2024 09:11:59 +0900 Subject: [PATCH 2/4] ci: fix arm64 windows build failure --- triplets/x64-win-llvm/x64-win-llvm.toolchain.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/triplets/x64-win-llvm/x64-win-llvm.toolchain.cmake b/triplets/x64-win-llvm/x64-win-llvm.toolchain.cmake index 3f2f9bd..104c891 100644 --- a/triplets/x64-win-llvm/x64-win-llvm.toolchain.cmake +++ b/triplets/x64-win-llvm/x64-win-llvm.toolchain.cmake @@ -50,7 +50,10 @@ set(ignore_werror "/WX-") cmake_language(DEFER CALL add_compile_options "/WX-") # make sure the flag is added at the end! # general architecture flags -set(arch_flags "-mcrc32") +set(arch_flags "") +if(VCPKG_TARGET_ARCHITECTURE STREQUAL x64) + string(APPEND arch_flags "-mcrc32") +endif() # -mcrc32 for libpq # -mrtm for tbb (will break qtdeclarative since it cannot run the executables in CI) # -msse4.2 for everything which normally cl can use. (Otherwise strict sse2 only.) From 7f58d787c93af98d5f1d97ba53c04534968d8842 Mon Sep 17 00:00:00 2001 From: oltolm Date: Mon, 16 Sep 2024 20:52:52 +0200 Subject: [PATCH 3/4] cmake: add support for triplet x64-mingw-static (#15) * cmake: add support for triplet x64-mingw-static * rename build to mingw --- .github/workflows/build.yml | 28 +++++++++++++++++++++++++++- CMakeLists.txt | 4 +++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 595a152..7e6b2c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,4 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json name: C/C++ CI on: [push] @@ -24,6 +25,12 @@ jobs: triplet: win-llvm-static-release vcpkg-root: C:\vcpkg extra-args: --overlay-triplets=./triplets + - build: mingw + os: windows-latest + triplet: mingw-static + vcpkg-root: C:\vcpkg + arch: x64 + extra-args: "" - build: macos os: macos-latest triplet: osx-release @@ -37,6 +44,17 @@ jobs: extra-args: --overlay-triplets=./triplets steps: + - run: git config --global core.autocrlf input + - uses: msys2/setup-msys2@v2 + id: msys2 + with: + msystem: CLANG64 + update: true + pacboy: >- + toolchain:p + cmake:p + ninja:p + if: matrix.triplet == 'mingw-static' - uses: actions/checkout@v4 - name: Set up build environment (macos-latest) @@ -65,7 +83,15 @@ jobs: - name: Build ffmpeg run: | - vcpkg ${{ matrix.extra-args }} install ffmpeg[avcodec,avfilter,avdevice,avformat,swresample,swscale]:${{ matrix.arch }}-${{ matrix.triplet }} + vcpkg ${{ matrix.extra-args }} install ffmpeg[avcodec,avfilter,avdevice,avformat,swresample,swscale]:${{ matrix.arch }}-${{ matrix.triplet }} + if: matrix.triplet != 'mingw-static' + + - name: Build ffmpeg (x64-mingw-static) + shell: msys2 {0} + run: | + export PATH=$(cygpath '${{ matrix.vcpkg-root }}'):$PATH + vcpkg ${{ matrix.extra-args }} install ffmpeg[avcodec,avfilter,avdevice,avformat,swresample,swscale]:${{ matrix.arch }}-${{ matrix.triplet }} + if: matrix.triplet == 'mingw-static' - uses: actions/upload-artifact@v4 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index f5f108c..c6c6a5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ elseif (APPLE) set(FFMPEG_PREBUILTS_NAME "ffmpeg-macos") elseif (UNIX) set(FFMPEG_PREBUILTS_NAME "ffmpeg-linux") +elseif (MINGW) + set(FFMPEG_PREBUILTS_NAME "ffmpeg-mingw") else () message(FATAL_ERROR "Unsupported OS.") endif () @@ -76,4 +78,4 @@ target_link_libraries(${FFMPEG_CORE_NAME} INTERFACE "${CMAKE_BINARY_DIR}/external/ffmpeg/lib/${LIB_PREFIX}swscale.${LIB_EXT}" "${CMAKE_BINARY_DIR}/external/ffmpeg/lib/${LIB_PREFIX}avutil.${LIB_EXT}" "${CMAKE_BINARY_DIR}/external/ffmpeg/lib/${LIB_PREFIX}avfilter.${LIB_EXT}" - "${CMAKE_BINARY_DIR}/external/ffmpeg/lib/${LIB_PREFIX}swresample.${LIB_EXT}") \ No newline at end of file + "${CMAKE_BINARY_DIR}/external/ffmpeg/lib/${LIB_PREFIX}swresample.${LIB_EXT}") From 50228828eaa95cbba51fe850b90d54382d27da25 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Thu, 28 Nov 2024 05:44:44 -0800 Subject: [PATCH 4/4] Update for shadPS4 repo and add ljpeg encoder. --- .github/workflows/build.yml | 7 ++++++- CMakeLists.txt | 2 +- Readme.md | 2 +- ffmpeg.patch | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e6b2c0..f44e5b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -81,6 +81,11 @@ jobs: (cd ${{ matrix.vcpkg-root }} && git checkout f6a5d4e8eb7476b8d7fc12a56dff300c1c986131) (cd ${{ matrix.vcpkg-root }} && git apply --ignore-space-change --ignore-whitespace --3way ${{ github.workspace }}/ffmpeg.patch) + - name: Bootstrap vcpkg (windows-latest) + run: | + (cd ${{ matrix.vcpkg-root }} && .\bootstrap-vcpkg.bat) + if: matrix.os == 'windows-latest' + - name: Build ffmpeg run: | vcpkg ${{ matrix.extra-args }} install ffmpeg[avcodec,avfilter,avdevice,avformat,swresample,swscale]:${{ matrix.arch }}-${{ matrix.triplet }} @@ -129,6 +134,6 @@ jobs: ls -al artifacts/ wget -c https://github.com/tcnksm/ghr/releases/download/v0.14.0/ghr_v0.14.0_linux_amd64.tar.gz tar xfv ghr_v0.14.0_linux_amd64.tar.gz - ghr_v0.14.0_linux_amd64/ghr -u Vita3K -r ffmpeg-core -n 'Automatic FFmpeg CI builds (${{ env.COMMIT_SHORT_SHA }})' -b "$(printf "Corresponding commit: ${{ github.sha }}")" ${{ env.COMMIT_SHORT_SHA }} artifacts/ + ghr_v0.14.0_linux_amd64/ghr -u shadps4-emu -r ext-ffmpeg-core -n 'Automatic FFmpeg CI builds (${{ env.COMMIT_SHORT_SHA }})' -b "$(printf "Corresponding commit: ${{ github.sha }}")" ${{ env.COMMIT_SHORT_SHA }} artifacts/ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index c6c6a5e..87b395d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ execute_process( # Download prebuilt ffmpeg if(NOT EXISTS "${CMAKE_BINARY_DIR}/external/ffmpeg.zip") message(STATUS "Downloading FFMPEG prebuilts...") - file(DOWNLOAD https://github.com/Vita3K/ffmpeg-core/releases/download/${FFMPEG_GIT_SHA}/${FFMPEG_PREBUILTS_NAME} + file(DOWNLOAD https://github.com/shadps4-emu/ext-ffmpeg-core/releases/download/${FFMPEG_GIT_SHA}/${FFMPEG_PREBUILTS_NAME} "${CMAKE_BINARY_DIR}/external/ffmpeg.zip" SHOW_PROGRESS STATUS FILE_STATUS) list(GET FILE_STATUS 0 STATUS_CODE) diff --git a/Readme.md b/Readme.md index 930b4a3..322ad57 100644 --- a/Readme.md +++ b/Readme.md @@ -1,5 +1,5 @@ ## FFmpeg builtins -This repository contains the ffmpeg builtins for Vita3K - shadowps4 and the CI to build them using vcpkg and github action. +This repository contains the FFmpeg builtins for shadPS4 and the CI to build them using vcpkg and GitHub actions. The Windows version is built using clang-cl, this is done so that inline assembly optimisations (which are not supported by MSVC) can be enabled. diff --git a/ffmpeg.patch b/ffmpeg.patch index ea598ad..4f7066a 100644 --- a/ffmpeg.patch +++ b/ffmpeg.patch @@ -9,12 +9,12 @@ index 35bac875b..b16d9cb64 100644 -set(OPTIONS "--enable-pic --disable-doc --enable-debug --enable-runtime-cpudetect --disable-autodetect") +set(OPTIONS "--enable-pic --disable-doc --enable-runtime-cpudetect --disable-autodetect") + -+# Only enable what is used by Vita3K ++# Only enable what is used by shadPS4 +string(APPEND OPTIONS " --disable-everything") +string(APPEND OPTIONS " --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-decoder=atrac9 --enable-decoder=mp3 --enable-decoder=pcm_s16le --enable-decoder=pcm_s8") +string(APPEND OPTIONS " --enable-decoder=mov --enable-decoder=h264 --enable-decoder=mpeg4 --enable-decoder=mpeg2video --enable-decoder=mjpeg --enable-decoder=mjpegb") +string(APPEND OPTIONS " --enable-encoder=pcm_s16le") -+string(APPEND OPTIONS " --enable-encoder=ffv1 --enable-encoder=mpeg4 --enable-encoder=mjpeg") ++string(APPEND OPTIONS " --enable-encoder=ffv1 --enable-encoder=mpeg4 --enable-encoder=ljpeg --enable-encoder=mjpeg") +string(APPEND OPTIONS " --enable-muxer=avi") +string(APPEND OPTIONS " --enable-demuxer=h264 --enable-demuxer=m4v --enable-demuxer=mp3 --enable-demuxer=mpegvideo --enable-demuxer=mpegps --enable-demuxer=mjpeg --enable-demuxer=mov --enable-demuxer=avi --enable-demuxer=aac --enable-demuxer=pmp --enable-demuxer=oma --enable-demuxer=pcm_s16le --enable-demuxer=pcm_s8 --enable-demuxer=wav") +string(APPEND OPTIONS " --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=mpegvideo --enable-parser=mjpeg --enable-parser=aac --enable-parser=aac_latm")