Skip to content

Commit

Permalink
Merge pull request #3 from squidbus/shad
Browse files Browse the repository at this point in the history
Update for shadPS4 repo and add ljpeg encoder.
  • Loading branch information
georgemoralis authored Nov 28, 2024
2 parents 63b5fa6 + 5022882 commit 27de97c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 11 deletions.
43 changes: 38 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: C/C++ CI

on: [push]
Expand All @@ -24,24 +25,43 @@ 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
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:
- 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)
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)
Expand All @@ -61,9 +81,22 @@ 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 }}
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:
Expand Down Expand Up @@ -101,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 }}
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down Expand Up @@ -40,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)
Expand Down Expand Up @@ -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}")
"${CMAKE_BINARY_DIR}/external/ffmpeg/lib/${LIB_PREFIX}swresample.${LIB_EXT}")
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions ffmpeg.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion triplets/x64-win-llvm/x64-win-llvm.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down

0 comments on commit 27de97c

Please sign in to comment.