diff --git a/.github/workflows/build-ffmpeg.yml b/.github/workflows/build-ffmpeg.yml deleted file mode 100644 index 4568a566..00000000 --- a/.github/workflows/build-ffmpeg.yml +++ /dev/null @@ -1,619 +0,0 @@ ---- -name: Build ffmpeg - -on: - pull_request: - branches: [master] - types: [opened, synchronize, reopened] - push: - branches: [master] - workflow_dispatch: - -concurrency: - group: "${{ github.workflow }}-${{ github.ref }}" - cancel-in-progress: true - -env: - MACOSX_DEPLOYMENT_TARGET: 13.0 - -jobs: - ffmpeg: - name: ffmpeg (${{ matrix.name }}) - # https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu - # https://trac.ffmpeg.org/wiki/CompilationGuide/macOS - # https://trac.ffmpeg.org/wiki/CompilationGuide/MinGW - strategy: - fail-fast: false # false to test all, true to fail entire job if any fail - matrix: - include: - - name: Linux-x86_64 # ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR} - os_type: linux - os: ubuntu-22.04 - arch: x86_64 - shell: bash - cmake_generator: Unix Makefiles - ffmpeg_extras: >- - --enable-amf - --enable-cuda - --enable-cuda_llvm - --enable-encoder=h264_amf,hevc_amf,av1_amf - --enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc - --enable-encoder=h264_vaapi,hevc_vaapi,av1_vaapi - --enable-encoder=h264_v4l2m2m - --enable-ffnvcodec - --enable-nvenc - --enable-v4l2_m2m - --enable-vaapi - - name: Linux-aarch64 - os_type: linux - os: ubuntu-22.04 - arch: aarch64 - shell: bash - cmake_generator: Unix Makefiles - host: aarch64-linux-gnu - ffmpeg_extras: >- - --enable-amf - --enable-cuda - --enable-cuda_llvm - --enable-encoder=h264_amf,hevc_amf,av1_amf - --enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc - --enable-encoder=h264_vaapi,hevc_vaapi,av1_vaapi - --enable-encoder=h264_v4l2m2m - --enable-ffnvcodec - --enable-nvenc - --enable-v4l2_m2m - --enable-vaapi - - name: Linux-ppc64le - os_type: linux - os: ubuntu-22.04 - arch: powerpc64le - shell: bash - cmake_generator: Unix Makefiles - host: powerpc64le-linux-gnu - ffmpeg_extras: >- - --enable-amf - --enable-cuda - --enable-cuda_llvm - --enable-encoder=h264_amf,hevc_amf,av1_amf - --enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc - --enable-encoder=h264_vaapi,hevc_vaapi,av1_vaapi - --enable-encoder=h264_v4l2m2m - --enable-ffnvcodec - --enable-nvenc - --enable-v4l2_m2m - --enable-vaapi - - name: Darwin-x86_64 - os_type: macos - os: macos-13 - arch: x86_64 - shell: bash - cmake_generator: Unix Makefiles # should be `Xcode` but that fails - ffmpeg_extras: >- - --enable-encoder=h264_videotoolbox,hevc_videotoolbox - --enable-videotoolbox - - name: Darwin-arm64 - os_type: macos - os: macos-14 - arch: aarch64 - shell: bash - cmake_generator: Unix Makefiles # should be `Xcode` but that fails - ffmpeg_extras: >- - --enable-encoder=h264_videotoolbox,hevc_videotoolbox - --enable-videotoolbox - - name: Windows-AMD64 - os_type: windows - os: windows-2022 - arch: x86_64 - shell: msys2 {0} - cmake_generator: MSYS Makefiles - ffmpeg_extras: >- - --enable-amf - --enable-cuda - --enable-d3d11va - --enable-encoder=h264_amf,hevc_amf,av1_amf - --enable-encoder=h264_mf,hevc_mf - --enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc - --enable-encoder=h264_qsv,hevc_qsv,av1_qsv - --enable-ffnvcodec - --enable-libvpl - --enable-nvenc - --enable-mediafoundation - runs-on: ${{ matrix.os }} - defaults: - run: - shell: ${{ matrix.shell }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Dependencies Unix - if: ${{ matrix.os_type != 'windows' }} - run: | - echo "::group::dependencies prep" - if [[ ${{ matrix.os }} == "ubuntu-18.04" ]]; then - dist="bionic" - elif [[ ${{ matrix.os }} == "ubuntu-20.04" ]]; then - dist="focal" - elif [[ ${{ matrix.os }} == "ubuntu-22.04" ]]; then - dist="jammy" - elif [[ ${{ matrix.os }} == "ubuntu-24.04" ]]; then - dist="noble" - fi - - package_arch="amd64" - if [[ ${{ matrix.arch }} == "aarch64" ]]; then - package_arch="arm64" - elif [[ ${{ matrix.arch }} == "powerpc64le" ]]; then - package_arch="ppc64el" - fi - - mirror="http://ports.ubuntu.com/ubuntu-ports" - extra_sources=$(cat <<- VAREOF - deb [arch=$package_arch] $mirror $dist main restricted - deb [arch=$package_arch] $mirror $dist-updates main restricted - deb [arch=$package_arch] $mirror $dist universe - deb [arch=$package_arch] $mirror $dist-updates universe - deb [arch=$package_arch] $mirror $dist multiverse - deb [arch=$package_arch] $mirror $dist-updates multiverse - deb [arch=$package_arch] $mirror $dist-backports main restricted universe multiverse - deb [arch=$package_arch] $mirror $dist-security main restricted - deb [arch=$package_arch] $mirror $dist-security universe - deb [arch=$package_arch] $mirror $dist-security multiverse - VAREOF - ) - echo "::endgroup::" - - if [[ ${{ matrix.os_type }} == "linux" ]]; then - echo "::group::linux dependencies" - - if [[ ${{ matrix.os }} == "ubuntu-20.04" ]]; then - # activate mesa backport PPA to ensure ffmpeg builds with vaSyncBuffer() - # (via libva 2.9.0 or later) - sudo add-apt-repository ppa:kisak/turtle -y - fi - - if [[ $package_arch != "amd64" ]]; then - # fix original sources - sudo sed -i -e "s#deb http#deb [arch=amd64] http#g" /etc/apt/sources.list - - sudo dpkg --add-architecture $package_arch - - echo "$extra_sources" | sudo tee -a /etc/apt/sources.list - echo "----" - sudo cat /etc/apt/sources.list - fi - - sudo apt-get update -q && sudo apt-get -y install \ - autoconf \ - automake \ - build-essential \ - cmake \ - git-core \ - libass-dev \ - libfreetype6-dev \ - libgnutls28-dev \ - libmp3lame-dev \ - libnuma-dev \ - libopus-dev \ - libsdl2-dev \ - libtool \ - libvorbis-dev \ - libxcb1-dev \ - libxcb-shm0-dev \ - libxcb-xfixes0-dev \ - meson \ - nasm \ - ninja-build \ - pkg-config \ - texinfo \ - wget \ - yasm \ - zlib1g-dev - - if [[ ${{ matrix.arch }} == "powerpc64le" ]]; then - sudo apt-get -y install \ - libva-dev:$package_arch \ - libva2:$package_arch \ - libva-drm2:$package_arch \ - libdrm2:$package_arch \ - libva-glx2:$package_arch \ - libgl1:$package_arch \ - libglx0:$package_arch \ - libglx-mesa0:$package_arch \ - libglapi-mesa:$package_arch \ - libgl1-mesa-dri:$package_arch \ - libdrm-amdgpu1:$package_arch \ - libdrm-nouveau2:$package_arch \ - libdrm-radeon1:$package_arch \ - libwayland-client0:$package_arch \ - libwayland-cursor0:$package_arch \ - libwayland-dev:$package_arch \ - libwayland-egl1:$package_arch \ - libwayland-server0:$package_arch \ - libva-wayland2:$package_arch \ - libva-x11-2:$package_arch - else - sudo apt-get -y install \ - libva-dev:$package_arch \ - libva-glx2:$package_arch \ - libgl1:$package_arch \ - libglx0:$package_arch - fi - - if [[ ${{ matrix.arch }} != "x86_64" ]]; then - sudo apt-get -y install \ - binutils-${{ matrix.host }} \ - g++-${{ matrix.host }} \ - gcc-${{ matrix.host }} - fi - echo "::endgroup::" - elif [[ ${{ matrix.os_type }} == "macos" ]]; then - echo "::group::macos dependencies" - brew install \ - automake \ - fdk-aac \ - git \ - lame \ - libass \ - libtool \ - libvorbis \ - libvpx \ - nasm \ - opus \ - pkg-config \ - sdl \ - shtool \ - texi2html \ - theora \ - wget \ - yasm \ - xvid - echo "::endgroup::" - fi - - - name: Setup Dependencies Windows - # if a dependency needs to be pinned, see https://github.com/LizardByte/build-deps/pull/186 - if: ${{ matrix.os_type == 'windows' }} - uses: msys2/setup-msys2@v2 - with: - msystem: ucrt64 - update: true - install: >- - diffutils - git - make - pkg-config - mingw-w64-ucrt-x86_64-binutils - mingw-w64-ucrt-x86_64-cmake - mingw-w64-ucrt-x86_64-gcc - mingw-w64-ucrt-x86_64-onevpl - mingw-w64-ucrt-x86_64-nasm - - - name: Initialize Submodules - # libx265 has issues when using the recursive method of the first checkout action - # this is after `msys2/setup-msys2@v2` because `msys2` (default) shell is not available until then. - run: | - git submodule update --init --recursive - - - name: Create Directories - id: root - run: | - echo "root_path=$PWD" >> $GITHUB_OUTPUT - mkdir -p ./bin ./ffmpeg_build ./ffmpeg_sources - - - name: patch - working-directory: ffmpeg_sources/ffmpeg - run: | - git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/01-amf-colorspace.patch - git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/02-idr-on-amf.patch - git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/03-amfenc-disable-buffering.patch - git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/04-mfenc-lowlatency.patch - git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/05-vaapi-customized-surface-alignment.patch - git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/06-amfenc-query-timeout.patch - git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/07-vaapi-leak.patch - - - name: Setup cross compilation - id: cross - if: ${{ matrix.arch != 'x86_64' }} - run: | - TOOLCHAIN_DIR=${{ steps.root.outputs.root_path }}/cmake/toolchain/${{ matrix.arch }}-${{ matrix.os_type }} - echo "CMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_DIR/crosscompile.cmake" >> $GITHUB_OUTPUT - if [[ ${{ matrix.os_type }} == 'linux' ]]; then - echo "CCPREFIX=/usr/bin/${{ matrix.host }}-" >> $GITHUB_OUTPUT - fi - - - name: amf - if: ${{ matrix.os_type != 'macos' }} - # https://ffmpeg.org/general.html#AMD-AMF_002fVCE - run: | - mkdir -p ./ffmpeg_build/include/AMF - cp -av "./ffmpeg_sources/AMF/amf/public/include/." "./ffmpeg_build/include/AMF" - - - name: av1 - working-directory: ffmpeg_sources/SVT-AV1/Build - env: - root_path: ${{ steps.root.outputs.root_path }} - CCPREFIX: ${{ steps.cross.outputs.CCPREFIX }} - run: | - echo "::group::configure" - PATH="$root_path/bin:$PATH" cmake -G "${{ matrix.cmake_generator }}" \ - -DCMAKE_TOOLCHAIN_FILE=${{ steps.cross.outputs.CMAKE_TOOLCHAIN_FILE }} \ - -DCMAKE_INSTALL_PREFIX="$root_path/ffmpeg_build" \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_APPS=OFF \ - -DBUILD_DEC=OFF \ - -DENABLE_AVX512=ON \ - -DBUILD_SHARED_LIBS=OFF \ - .. - echo "::endgroup::" - - echo "::group::make" - PATH="$root_path/bin:$PATH" make -j$(nproc || sysctl -n hw.logicalcpu) - echo "::endgroup::" - - echo "::group::make install" - make install - echo "::endgroup::" - - - name: libx264 - env: - root_path: ${{ steps.root.outputs.root_path }} - CCPREFIX: ${{ steps.cross.outputs.CCPREFIX }} - working-directory: ffmpeg_sources/x264 - run: | - echo "::group::configure options" - ./configure --help || true # this command has a non zero exit status, but we should continue anyway - echo "::endgroup::" - - echo "::group::configure extra flags for cross compilation" - extra_configure="" - if [[ ${{ matrix.os_type }} == "linux" && ${{ matrix.arch }} != "x86_64" ]]; then - extra_configure=$(cat <<- VAREOF - --host=${{ matrix.arch }}-${{ matrix.os_type }} - --cross-prefix=${CCPREFIX} - VAREOF - ) - fi - echo "$extra_configure" - echo "::endgroup::" - - echo "::group::configure" - PATH="$root_path/bin:$PATH" \ - PKG_CONFIG_PATH="$root_path/ffmpeg_build/lib/pkgconfig" \ - ./configure \ - $extra_configure \ - --prefix="$root_path/ffmpeg_build" \ - --bindir="$root_path/bin" \ - --disable-cli \ - --enable-static - echo "::endgroup::" - - echo "::group::make" - PATH="$root_path/bin:$PATH" make -j$(nproc || sysctl -n hw.logicalcpu) - echo "::endgroup::" - - echo "::group::make install" - make install - echo "::endgroup::" - - - name: libx265 - env: - root_path: ${{ steps.root.outputs.root_path }} - CCPREFIX: ${{ steps.cross.outputs.CCPREFIX }} - working-directory: ffmpeg_sources/x265_git - run: | - echo "::group::configure extra flags for cross compilation" - extra_configure="" - if [[ ${{ matrix.arch }} == "x86_64" ]]; then - # not currently supported in `aarch64` - extra_configure="-DENABLE_HDR10_PLUS=1" - fi - echo "$extra_configure" - echo "::endgroup::" - - echo "::group::configure" - PATH="$root_path/bin:$PATH" cmake -G "${{ matrix.cmake_generator }}" \ - $extra_configure \ - -DCMAKE_TOOLCHAIN_FILE=${{ steps.cross.outputs.CMAKE_TOOLCHAIN_FILE }} \ - -DCMAKE_INSTALL_PREFIX="$root_path/ffmpeg_build" \ - -DENABLE_CLI=OFF \ - -DENABLE_SHARED=OFF \ - -DSTATIC_LINK_CRT=ON \ - ./source - echo "::endgroup::" - - echo "::group::make" - PATH="$root_path/bin:$PATH" make -j$(nproc || sysctl -n hw.logicalcpu) - echo "::endgroup::" - - echo "::group::make install" - make install - echo "::endgroup::" - - - name: nvenc - id: nvenc - if: ${{ matrix.os_type != 'macos' }} - env: - root_path: ${{ steps.root.outputs.root_path }} - working-directory: ffmpeg_sources/nv-codec-headers - # https://trac.ffmpeg.org/wiki/HWAccelIntro#NVENC - run: | - echo "::group::patch Makefile" - # allow `PREFIX` to be overridden - sed -i 's/PREFIX =/PREFIX ?=/g' Makefile - echo "::endgroup::" - - echo "::group::make" - PREFIX=$root_path/ffmpeg_build make -j$(nproc || sysctl -n hw.logicalcpu) - echo "::endgroup::" - - echo "::group::make install" - PREFIX=$root_path/ffmpeg_build make install - echo "::endgroup::" - - - name: ffmpeg - env: - root_path: ${{ steps.root.outputs.root_path }} - working-directory: ffmpeg_sources/ffmpeg - run: | - echo "::group::configure options" - ./configure --help || true # this command has a non zero exit status, but we should continue anyway - echo "::endgroup::" - - echo "::group::configure extra flags for cross compilation" - extra_configure="" - if [[ ${{ matrix.os_type }} == "linux" && ${{ matrix.arch }} != "x86_64" ]]; then - CCPREFIX=${{ steps.cross.outputs.CCPREFIX }} - extra_configure=$(cat <<- VAREOF - --arch=${{ matrix.arch }} - --cross-prefix=${CCPREFIX} - --enable-cross-compile - --target-os=${{ matrix.os_type }} - VAREOF - ) - fi - echo "$extra_configure" - echo "::endgroup::" - - echo "::group::configure" - set +e # do not fail - PATH="$root_path/bin:$PATH" \ - PKG_CONFIG_PATH="$root_path/ffmpeg_build/lib/pkgconfig:/usr/lib/${{ matrix.host }}/pkgconfig" \ - ./configure \ - $extra_configure \ - --prefix="$root_path/ffmpeg_build" \ - --pkg-config-flags="--static" \ - --extra-cflags="-I$root_path/ffmpeg_build/include" \ - --extra-ldflags="-L$root_path/ffmpeg_build/lib" \ - --extra-libs="-lpthread -lm" \ - --bindir="$root_path/bin" \ - --disable-all \ - --disable-autodetect \ - --disable-iconv \ - --enable-avcodec \ - --enable-encoder=libsvtav1 \ - --enable-encoder=libx264,libx265 \ - --enable-gpl \ - --enable-libsvtav1 \ - --enable-libx264 \ - --enable-libx265 \ - --enable-static \ - --enable-swscale \ - --pkg-config=pkg-config \ - ${{ matrix.ffmpeg_extras }} \ - || config_error=true - set -e # reset fail on error - echo "::endgroup::" - - echo "::group::config error log" - cat ./ffbuild/config.log - - if [ $config_error ] - then - exit -1 - fi - echo "::endgroup::" - - echo "::group::make" - PATH="$root_path/bin:$PATH" make -j$(nproc || sysctl -n hw.logicalcpu) - echo "::endgroup::" - - echo "::group::make install" - make install - echo "::endgroup::" - - echo "::group::copy license" - cp ./COPYING.GPLv2 $root_path/ffmpeg_build/LICENSE - echo "::endgroup::" - - - name: cbs - env: - root_path: ${{ steps.root.outputs.root_path }} - run: | - mkdir -p build - cd build - - echo "::group::configure extra flags for cross compilation" - if [[ ${{ matrix.os_type }} == "macos" ]]; then - if [[ ${{ matrix.arch }} == "x86_64" ]]; then - export CC="gcc" - export CXX="g++" - else - export CFLAGS="${{ steps.cross.outputs.CFLAGS }}" - export CXXFLAGS="${{ steps.cross.outputs.CXXFLAGS }}" - export LDFLAGS="${{ steps.cross.outputs.LDFLAGS }}" - fi - fi - echo "::endgroup::" - - echo "::group::configure" - PATH="$root_path/bin:$PATH" cmake -G "${{ matrix.cmake_generator }}" \ - -DCMAKE_TOOLCHAIN_FILE=${{ steps.cross.outputs.CMAKE_TOOLCHAIN_FILE }} \ - -DCMAKE_INSTALL_PREFIX="$root_path/ffmpeg_build" \ - -DFFMPEG_CBS=ON \ - .. - echo "::endgroup::" - - echo "::group::make" - PATH="$root_path/bin:$PATH" make -j$(nproc || sysctl -n hw.logicalcpu) - echo "::endgroup::" - - echo "::group::make install" - make install - echo "::endgroup::" - - - name: Cleanup - run: | - rm -f -r ./ffmpeg_build/share - rm -f -r ./ffmpeg_build/lib/pkgconfig - - - name: Upload Artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.name }} - path: ./ffmpeg_build/ - - update_dist: - # only the commit is conditional, so the rest of the job can be verified on PRs - name: Update dist - needs: ffmpeg - runs-on: ubuntu-latest - - steps: - - name: Checkout dist - uses: actions/checkout@v4 - with: - ref: dist - path: dist - persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token - fetch-depth: 0 # otherwise, will fail to push refs to dest repo - - - name: Cleanup - run: | - rm -f -r dist/ffmpeg/*/share - rm -f -r dist/ffmpeg/*/lib/pkgconfig - - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - path: dist/ffmpeg - - - name: Debug - run: | - ls -R dist/ffmpeg - - - name: Commit dist - if: >- - startsWith(github.repository, 'LizardByte/') && - github.ref == 'refs/heads/master' && - (github.event_name == 'push' || github.event_name == 'workflow_dispatch') - uses: actions-js/push@v1.5 - with: - github_token: ${{ secrets.GH_BOT_TOKEN }} - author_email: ${{ secrets.GH_BOT_EMAIL }} - author_name: ${{ secrets.GH_BOT_NAME }} - directory: dist - branch: dist - force: false - message: "Commit ${{ github.sha }}" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..0913694a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,326 @@ +--- +name: CI + +on: + pull_request: + branches: [master] + types: [opened, synchronize, reopened] + push: + branches: [master] + workflow_dispatch: + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +env: + MACOSX_DEPLOYMENT_TARGET: 13.0 + +jobs: + build: + name: Build (${{ matrix.name }}) + # https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu + # https://trac.ffmpeg.org/wiki/CompilationGuide/macOS + # https://trac.ffmpeg.org/wiki/CompilationGuide/MinGW + strategy: + fail-fast: false # false to test all, true to fail entire job if any fail + matrix: + include: + - name: Linux-x86_64 # ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR} + os_type: linux + os: ubuntu-22.04 + arch: x86_64 + shell: bash + - name: Linux-aarch64 + os_type: linux + os: ubuntu-22.04 + arch: aarch64 + shell: bash + target: aarch64-linux-gnu + - name: Linux-ppc64le + os_type: linux + os: ubuntu-22.04 + arch: powerpc64le + shell: bash + target: powerpc64le-linux-gnu + - name: Darwin-x86_64 + os_type: macos + os: macos-13 + arch: x86_64 + shell: bash + - name: Darwin-arm64 + os_type: macos + os: macos-14 + arch: aarch64 + shell: bash + target: arm64-apple-macosx + - name: Windows-AMD64 + os_type: windows + os: windows-2022 + arch: x86_64 + shell: msys2 {0} + runs-on: ${{ matrix.os }} + defaults: + run: + shell: ${{ matrix.shell }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Dependencies Linux + if: ${{ matrix.os_type != 'windows' }} + run: | + echo "::group::dependencies prep" + if [[ ${{ matrix.os }} == "ubuntu-18.04" ]]; then + dist="bionic" + elif [[ ${{ matrix.os }} == "ubuntu-20.04" ]]; then + dist="focal" + elif [[ ${{ matrix.os }} == "ubuntu-22.04" ]]; then + dist="jammy" + elif [[ ${{ matrix.os }} == "ubuntu-24.04" ]]; then + dist="noble" + fi + + package_arch="amd64" + if [[ ${{ matrix.arch }} == "aarch64" ]]; then + package_arch="arm64" + elif [[ ${{ matrix.arch }} == "powerpc64le" ]]; then + package_arch="ppc64el" + fi + + mirror="http://ports.ubuntu.com/ubuntu-ports" + extra_sources=$(cat <<- VAREOF + deb [arch=$package_arch] $mirror $dist main restricted + deb [arch=$package_arch] $mirror $dist-updates main restricted + deb [arch=$package_arch] $mirror $dist universe + deb [arch=$package_arch] $mirror $dist-updates universe + deb [arch=$package_arch] $mirror $dist multiverse + deb [arch=$package_arch] $mirror $dist-updates multiverse + deb [arch=$package_arch] $mirror $dist-backports main restricted universe multiverse + deb [arch=$package_arch] $mirror $dist-security main restricted + deb [arch=$package_arch] $mirror $dist-security universe + deb [arch=$package_arch] $mirror $dist-security multiverse + VAREOF + ) + echo "::endgroup::" + + echo "::group::linux dependencies" + + if [[ ${{ matrix.os }} == "ubuntu-20.04" ]]; then + # activate mesa backport PPA to ensure ffmpeg builds with vaSyncBuffer() + # (via libva 2.9.0 or later) + sudo add-apt-repository ppa:kisak/turtle -y + fi + + if [[ $package_arch != "amd64" ]]; then + # fix original sources + sudo sed -i -e "s#deb http#deb [arch=amd64] http#g" /etc/apt/sources.list + + sudo dpkg --add-architecture $package_arch + + echo "$extra_sources" | sudo tee -a /etc/apt/sources.list + echo "----" + sudo cat /etc/apt/sources.list + fi + + sudo apt-get update -q && sudo apt-get -y install \ + autoconf \ + automake \ + build-essential \ + cmake \ + git-core \ + libass-dev \ + libfreetype6-dev \ + libgnutls28-dev \ + libmp3lame-dev \ + libnuma-dev \ + libopus-dev \ + libsdl2-dev \ + libtool \ + libvorbis-dev \ + libxcb1-dev \ + libxcb-shm0-dev \ + libxcb-xfixes0-dev \ + meson \ + nasm \ + ninja-build \ + pkg-config \ + texinfo \ + wget \ + yasm \ + zlib1g-dev + + if [[ ${{ matrix.arch }} == "powerpc64le" ]]; then + sudo apt-get -y install \ + libva-dev:$package_arch \ + libva2:$package_arch \ + libva-drm2:$package_arch \ + libdrm2:$package_arch \ + libva-glx2:$package_arch \ + libgl1:$package_arch \ + libglx0:$package_arch \ + libglx-mesa0:$package_arch \ + libglapi-mesa:$package_arch \ + libgl1-mesa-dri:$package_arch \ + libdrm-amdgpu1:$package_arch \ + libdrm-nouveau2:$package_arch \ + libdrm-radeon1:$package_arch \ + libwayland-client0:$package_arch \ + libwayland-cursor0:$package_arch \ + libwayland-dev:$package_arch \ + libwayland-egl1:$package_arch \ + libwayland-server0:$package_arch \ + libva-wayland2:$package_arch \ + libva-x11-2:$package_arch + else + sudo apt-get -y install \ + libva-dev:$package_arch \ + libva-glx2:$package_arch \ + libgl1:$package_arch \ + libglx0:$package_arch + fi + + if [[ ${{ matrix.arch }} != "x86_64" ]]; then + sudo apt-get -y install \ + binutils-${{ matrix.target }} \ + g++-${{ matrix.target }} \ + gcc-${{ matrix.target }} + fi + echo "::endgroup::" + + - name: Setup Dependencies MacOS + if: ${{ matrix.os_type == 'macos' }} + run: | + brew install \ + automake \ + fdk-aac \ + git \ + lame \ + libass \ + libtool \ + libvorbis \ + libvpx \ + nasm \ + ninja \ + opus \ + pkg-config \ + sdl \ + shtool \ + texi2html \ + theora \ + wget \ + yasm \ + xvid + + - name: Setup Dependencies Windows + # if a dependency needs to be pinned, see https://github.com/LizardByte/build-deps/pull/186 + if: ${{ matrix.os_type == 'windows' }} + uses: msys2/setup-msys2@v2 + with: + msystem: ucrt64 + update: true + install: >- + diffutils + git + make + pkg-config + mingw-w64-ucrt-x86_64-binutils + mingw-w64-ucrt-x86_64-cmake + mingw-w64-ucrt-x86_64-gcc + mingw-w64-ucrt-x86_64-onevpl + mingw-w64-ucrt-x86_64-nasm + mingw-w64-ucrt-x86_64-ninja + + - name: Initialize Submodules + # libx265 has issues when using the recursive method of the first checkout action + # this is after `msys2/setup-msys2@v2` because `msys2` (default) shell is not available until then. + run: | + git submodule update --init --recursive + + - name: Setup ENV + id: root + run: | + echo "ROOT_PATH=$PWD" >> $GITHUB_ENV + + - name: Setup cross compilation + id: cross + if: ${{ matrix.arch != 'x86_64' }} + run: | + TOOLCHAIN=${ROOT_PATH}/cmake/toolchains/${{ matrix.target }}.cmake + echo "CMAKE_TOOLCHAIN_FILE=$TOOLCHAIN" >> $GITHUB_OUTPUT + if [[ ${{ matrix.os_type }} == 'linux' ]]; then + echo "CCPREFIX=/usr/bin/${{ matrix.target }}-" >> $GITHUB_OUTPUT + fi + + - name: ffmpeg + run: | + mkdir -p build + cmake \ + -B build \ + -S . \ + -G "Ninja" \ + -DCMAKE_TOOLCHAIN_FILE=${{ steps.cross.outputs.CMAKE_TOOLCHAIN_FILE }} \ + -DCMAKE_INSTALL_PREFIX="${ROOT_PATH}/build/dist" + ninja -C build + ninja -C build install + + - name: Debug + run: | + ls -R ./build/dist + + - name: Cleanup + # TODO + run: | + rm -f -r ./ffmpeg_build/share + rm -f -r ./ffmpeg_build/lib/pkgconfig + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.name }} + path: ./ffmpeg_build/ # TODO + + update_dist: + # only the commit is conditional, so the rest of the job can be verified on PRs + name: Update dist + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout dist + uses: actions/checkout@v4 + with: + ref: dist + path: dist + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token + fetch-depth: 0 # otherwise, will fail to push refs to dest repo + + - name: Cleanup + run: | + rm -f -r dist/ffmpeg/*/share + rm -f -r dist/ffmpeg/*/lib/pkgconfig + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: dist/ffmpeg + + - name: Debug + run: | + ls -R dist/ffmpeg + + - name: Commit dist + if: >- + startsWith(github.repository, 'LizardByte/') && + github.ref == 'refs/heads/master' && + (github.event_name == 'push' || github.event_name == 'workflow_dispatch') + uses: actions-js/push@v1.5 + with: + github_token: ${{ secrets.GH_BOT_TOKEN }} + author_email: ${{ secrets.GH_BOT_EMAIL }} + author_name: ${{ secrets.GH_BOT_NAME }} + directory: dist + branch: dist + force: false + message: "Commit ${{ github.sha }}" diff --git a/.gitignore b/.gitignore index 81ec4ba5..4c59bc5e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Distribution / packaging build/ +cmake-*/ # JetBrains project folder .idea/ diff --git a/.gitmodules b/.gitmodules index dbe2806c..9d1b313e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,24 +1,24 @@ -[submodule "ffmpeg_sources/AMF"] - path = ffmpeg_sources/AMF - url = https://github.com/GPUOpen-LibrariesAndSDKs/AMF +[submodule "third-party/FFmpeg/AMF"] + path = third-party/FFmpeg/AMF + url = https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git branch = master -[submodule "ffmpeg_sources/x264"] - path = ffmpeg_sources/x264 +[submodule "third-party/FFmpeg/x264"] + path = third-party/FFmpeg/x264 url = https://code.videolan.org/videolan/x264.git branch = stable -[submodule "ffmpeg_sources/x265_git"] - path = ffmpeg_sources/x265_git +[submodule "third-party/FFmpeg/x265_git"] + path = third-party/FFmpeg/x265_git url = https://bitbucket.org/multicoreware/x265_git.git branch = Release_3.5 -[submodule "ffmpeg_sources/nv-codec-headers"] - path = ffmpeg_sources/nv-codec-headers - url = https://github.com/FFmpeg/nv-codec-headers +[submodule "third-party/FFmpeg/nv-codec-headers"] + path = third-party/FFmpeg/nv-codec-headers + url = https://github.com/FFmpeg/nv-codec-headers.git branch = sdk/12.0 -[submodule "ffmpeg_sources/ffmpeg"] - path = ffmpeg_sources/ffmpeg - url = https://github.com/FFmpeg/FFmpeg +[submodule "third-party/FFmpeg/FFmpeg"] + path = third-party/FFmpeg/FFmpeg + url = https://github.com/FFmpeg/FFmpeg.git branch = release/7.1 -[submodule "ffmpeg_sources/SVT-AV1"] - path = ffmpeg_sources/SVT-AV1 +[submodule "third-party/FFmpeg/SVT-AV1"] + path = third-party/FFmpeg/SVT-AV1 url = https://gitlab.com/AOMediaCodec/SVT-AV1.git branch = v1.6.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 45ea850c..e5890013 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,65 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.25) project(build-deps - DESCRIPTION "Pre-build dependencies for LizardByte projects") + DESCRIPTION "Pre-build dependencies for LizardByte projects.") -option(FFMPEG_CBS "Enable CBS library configuration" ON) +option(BUILD_ALL "Build all dependencies" ON) +option(BUILD_ALL_SUNSHINE "Build all Sunshine dependencies" ON) -if(FFMPEG_CBS) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg_cbs.cmake) +# The shell command and prefix to use for running extra commands. +if(NOT DEFINED SHELL_CMD) + if(WIN32) + set(SHELL_CMD "C:\\msys64\\usr\\bin\\bash.exe" CACHE STRING "Shell to use" FORCE) + else() + set(SHELL_CMD "bash" CACHE STRING "Shell to use" FORCE) + endif() +endif() +if(NOT DEFINED SHELL_CMD_PREFIX) + if(WIN32) + set(SHELL_CMD_PREFIX -l -c CACHE STRING "Shell command prefix" FORCE) + set(MSYSTEM "UCRT64" CACHE STRING "MSYSTEM to use" FORCE) + set(ENV{MSYSTEM} ${MSYSTEM}) + else() + set(SHELL_CMD_PREFIX -c CACHE STRING "Shell command prefix" FORCE) + endif() +endif() +message(STATUS "Using shell command: ${SHELL_CMD}") +message(STATUS "Using shell command prefix: ${SHELL_CMD_PREFIX}") + +# FFmpeg +option(BUILD_FFMPEG "Build FFmpeg" ON) +option(BUILD_FFMPEG_ALL_PATCHES "Apply FFmpeg patches" ON) +option(BUILD_FFMPEG_AMF "Build FFmpeg AMF" ON) +option(BUILD_FFMPEG_AMF_PATCHES "Apply FFmpeg AMF patches" ON) +option(BUILD_FFMPEG_CBS "Build FFmpeg CBS" ON) +option(BUILD_FFMPEG_CBS_PATCHES "Apply FFmpeg CBS patches" ON) +option(BUILD_FFMPEG_MF "Build FFmpeg Media Foundation" ON) +option(BUILD_FFMPEG_MF_PATCHES "Apply FFmpeg Media Foundation patches" ON) +option(BUILD_FFMPEG_NV_CODEC_HEADERS "Build FFmpeg NV Codec Headers" ON) +option(BUILD_FFMPEG_NV_CODEC_HEADERS_PATCHES "Apply FFmpeg NV Codec Headers patches" ON) +option(BUILD_FFMPEG_SVT_AV1 "Build FFmpeg SVT-AV1" ON) +option(BUILD_FFMPEG_SVT_AV1_PATCHES "Apply FFmpeg SVT-AV1 patches" ON) +option(BUILD_FFMPEG_VAAPI "Build FFmpeg with VAAPI support" ON) +option(BUILD_FFMPEG_VAAPI_PATCHES "Apply FFmpeg VAAPI patches" ON) +option(BUILD_FFMPEG_X264 "Build FFmpeg x264" ON) +option(BUILD_FFMPEG_X264_PATCHES "Apply FFmpeg x264 patches" ON) +option(BUILD_FFMPEG_X265 "Build FFmpeg x265" ON) +option(BUILD_FFMPEG_X265_PATCHES "Apply FFmpeg x265 patches" ON) + +add_custom_target(${CMAKE_PROJECT_NAME} + COMMENT "Completed build-deps" +) + +# set architecture +string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} arch) + +# set generated source path +set(CMAKE_GENERATED_SRC_PATH ${CMAKE_CURRENT_BINARY_DIR}/generated-src) + +# common includes +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/apply_git_patch.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/unix_path.cmake) + +if(BUILD_ALL OR BUILD_ALL_SUNSHINE OR BUILD_FFMPEG) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg/_main.cmake) endif() diff --git a/README.md b/README.md index 953e5e89..b003f1cd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![GitHub Workflow Status (FFmpeg)](https://img.shields.io/github/actions/workflow/status/lizardbyte/build-deps/build-ffmpeg.yml.svg?branch=master&label=ffmpeg%20build&logo=github&style=for-the-badge)](https://github.com/LizardByte/build-deps/actions/workflows/build-ffmpeg.yml?query=branch%3Amaster) -This is a common set of pre-compiled dependencies for LizardByte/Sunshine. +This is a common set of pre-compiled dependencies for [LizardByte/Sunshine](https://github.com/LizardByte/Sunshine). - [FFmpeg](https://ffmpeg.org) @@ -19,7 +19,6 @@ This is a common set of pre-compiled dependencies for LizardByte/Sunshine. ## Plans -- [ ] Convert to a cmake project - [ ] Add more dependencies - [ ] boost - [ ] cuda (developer toolkit) @@ -29,3 +28,15 @@ This is a common set of pre-compiled dependencies for LizardByte/Sunshine. This repo is licensed under the MIT License, but this does not cover submodules or patches. Please see the individual projects for their respective licenses. + + +## Build + +On Windows, you must copy the `.gitattributes` file to `.git/modules/third-party/FFmpeg/x264/info/attributes`, +see https://stackoverflow.com/a/23671157/11214013 for more info. + +Then +```bash +cd third-party/FFmpeg/x264 +git checkout HEAD -- . +``` diff --git a/attributes b/attributes new file mode 100644 index 00000000..fe370823 --- /dev/null +++ b/attributes @@ -0,0 +1,2 @@ +# unix line endings +* text eol=lf diff --git a/cmake/ffmpeg/_main.cmake b/cmake/ffmpeg/_main.cmake new file mode 100644 index 00000000..e3361756 --- /dev/null +++ b/cmake/ffmpeg/_main.cmake @@ -0,0 +1,38 @@ +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/third-party/FFmpeg/FFmpeg DESTINATION ${CMAKE_GENERATED_SRC_PATH}) + +set(FFMPEG_GENERATED_SRC_PATH ${CMAKE_GENERATED_SRC_PATH}/FFmpeg) +set(AVCODEC_GENERATED_SRC_PATH ${CMAKE_GENERATED_SRC_PATH}/FFmpeg/libavcodec) + +if(APPLE) + set(BUILD_FFMPEG_AMF OFF) +endif() + +if(BUILD_FFMPEG_AMF) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg/amf.cmake) +endif() + +if(BUILD_FFMPEG_MF) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg/mf.cmake) +endif() + +if(BUILD_FFMPEG_NV_CODEC_HEADERS) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg/nv_codec_headers.cmake) +endif() + +if(BUILD_FFMPEG_SVT_AV1) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg/svt_av1.cmake) +endif() + +if(BUILD_FFMPEG_VAAPI) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg/vaapi.cmake) +endif() + +if(BUILD_FFMPEG_X264) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg/x264.cmake) +endif() + +if(BUILD_FFMPEG_X265) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg/x265.cmake) +endif() + +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg/ffmpeg.cmake) diff --git a/cmake/ffmpeg/amf.cmake b/cmake/ffmpeg/amf.cmake new file mode 100644 index 00000000..97c10c00 --- /dev/null +++ b/cmake/ffmpeg/amf.cmake @@ -0,0 +1,19 @@ +if(BUILD_FFMPEG_ALL_PATCHES OR BUILD_FFMPEG_AMF_PATCHES) + file(GLOB FFMPEG_AMF_PATCH_FILES ${CMAKE_CURRENT_SOURCE_DIR}/patches/FFmpeg/AMF/*.patch) + + foreach(patch_file ${FFMPEG_AMF_PATCH_FILES}) + APPLY_GIT_PATCH(${FFMPEG_GENERATED_SRC_PATH} ${patch_file}) + endforeach() +endif() + +set(AMF_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR}/usr/local/include/AMF) +add_custom_target(amf ALL + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${CMAKE_CURRENT_SOURCE_DIR}/third-party/FFmpeg/AMF/amf/public/include" + "${AMF_TARGET_DIR}" + COMMENT "Copying AMF headers" +) +add_dependencies(${CMAKE_PROJECT_NAME} amf) +install(DIRECTORY ${AMF_TARGET_DIR} + DESTINATION include +) diff --git a/cmake/ffmpeg/ffmpeg.cmake b/cmake/ffmpeg/ffmpeg.cmake new file mode 100644 index 00000000..c95ee7ae --- /dev/null +++ b/cmake/ffmpeg/ffmpeg.cmake @@ -0,0 +1,243 @@ +if(BUILD_FFMPEG_ALL_PATCHES OR BUILD_FFMPEG_CBS_PATCHES) + file(GLOB FFMPEG_CBS_PATCH_FILES ${CMAKE_CURRENT_SOURCE_DIR}/patches/FFmpeg/cbs/*.patch) + + foreach(patch_file ${FFMPEG_CBS_PATCH_FILES}) + APPLY_GIT_PATCH(${FFMPEG_GENERATED_SRC_PATH} ${patch_file}) + endforeach() +endif() + +set(CBS_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}/include/cbs) + +if(${arch} STREQUAL "aarch64" OR ${arch} STREQUAL "arm64") + set(CBS_ARCH_PATH arm) +elseif (${arch} STREQUAL "ppc64le") + set(CBS_ARCH_PATH ppc) +elseif (${arch} STREQUAL "amd64" OR ${arch} STREQUAL "x86_64") + set(CBS_ARCH_PATH x86) +elseif (${arch} STREQUAL "mips") + set(CBS_ARCH_PATH mips) +else() + message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) +endif() + +set(FFMPEG_EXTRA_CONFIGURE + ${FFMPEG_EXTRA_CONFIGURE} + --disable-all + --disable-autodetect + --disable-iconv + --enable-gpl + --enable-static + --enable-avcodec + --enable-avutil + --enable-bsfs # ensure config.h will have CONFIG_CBS_ flags + --enable-encoder=libsvtav1 + --enable-encoder=libx264,libx265 + --enable-libsvtav1 + --enable-libx264 + --enable-libx265 + --enable-swscale +) + +if(WIN32) + set(FFMPEG_EXTRA_CONFIGURE + ${FFMPEG_EXTRA_CONFIGURE} + --enable-amf + --enable-cuda + --enable-d3d11va + --enable-encoder=h264_amf,hevc_amf,av1_amf + --enable-encoder=h264_mf,hevc_mf + --enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc + --enable-encoder=h264_qsv,hevc_qsv,av1_qsv + --enable-ffnvcodec + --enable-libvpl + --enable-nvenc + --enable-mediafoundation + ) +elseif(APPLE) + set(FFMPEG_EXTRA_CONFIGURE + ${FFMPEG_EXTRA_CONFIGURE} + --enable-encoder=h264_videotoolbox,hevc_videotoolbox + --enable-videotoolbox + ) +elseif(UNIX) + set(FFMPEG_EXTRA_CONFIGURE + ${FFMPEG_EXTRA_CONFIGURE} + --enable-amf + --enable-cuda + --enable-cuda_llvm + --enable-encoder=h264_amf,hevc_amf,av1_amf + --enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc + --enable-encoder=h264_vaapi,hevc_vaapi,av1_vaapi + --enable-encoder=h264_v4l2m2m + --enable-ffnvcodec + --enable-nvenc + --enable-v4l2_m2m + --enable-vaapi + ) +endif() + +if(CMAKE_CROSSCOMPILING) + set(FFMPEG_EXTRA_CONFIGURE + ${FFMPEG_EXTRA_CONFIGURE} + --arch=${arch} + --enable-cross-compile + ) +endif() + +set(WORKING_DIR ${FFMPEG_GENERATED_SRC_PATH}) +UNIX_PATH(WORKING_DIR_UNIX ${WORKING_DIR}) +add_custom_target(ffmpeg + COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=${MSYSTEM} ${SHELL_CMD} ${SHELL_CMD_PREFIX} "cd ${WORKING_DIR_UNIX} && \ +./configure \ +--prefix=${CMAKE_CURRENT_BINARY_DIR_UNIX}/FFmpeg \ +--cc=${CMAKE_C_COMPILER} \ +--cxx=${CMAKE_CXX_COMPILER} \ +--ar=${CMAKE_AR} \ +--ranlib=${CMAKE_RANLIB} \ +--optflags=${CMAKE_C_FLAGS} \ +${FFMPEG_EXTRA_CONFIGURE}" + # TODO: make command fails, unable to find "cbs/config.h" +# COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=${MSYSTEM} ${SHELL_CMD} ${SHELL_CMD_PREFIX} "cd ${WORKING_DIR_UNIX} && \ +#make" +# COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=${MSYSTEM} ${SHELL_CMD} ${SHELL_CMD_PREFIX} "cd ${WORKING_DIR_UNIX} && \ +#make install" + WORKING_DIRECTORY ${WORKING_DIR} + COMMENT "Configuring ffmpeg" + COMMAND_EXPAND_LISTS + USES_TERMINAL +) +add_dependencies(${CMAKE_PROJECT_NAME} ffmpeg) +if(BUILD_FFMPEG_AMF) + add_dependencies(ffmpeg amf) +endif() +if(BUILD_FFMPEG_NV_CODEC_HEADERS) + add_dependencies(ffmpeg nv_codec_headers) +endif() +if(BUILD_FFMPEG_SVT_AV1) + add_dependencies(ffmpeg SvtAv1Enc) +endif() +if(BUILD_FFMPEG_X264) + add_dependencies(ffmpeg x264) +endif() +if(BUILD_FFMPEG_X265) + add_dependencies(ffmpeg x265-static) +endif() + + + + + + + + + +#set(FFMPEG_CBS_HEADERS +# ${AVCODEC_GENERATED_SRC_PATH}/av1.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_av1.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_bsf.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_h2645.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_h264.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_h265.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_jpeg.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_mpeg2.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_sei.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_vp8.h +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_vp9.h +# ${AVCODEC_GENERATED_SRC_PATH}/codec_desc.h +# ${AVCODEC_GENERATED_SRC_PATH}/codec_id.h +# ${AVCODEC_GENERATED_SRC_PATH}/codec_par.h +# ${AVCODEC_GENERATED_SRC_PATH}/defs.h +# ${AVCODEC_GENERATED_SRC_PATH}/get_bits.h +# ${AVCODEC_GENERATED_SRC_PATH}/h264_levels.h +# ${AVCODEC_GENERATED_SRC_PATH}/h2645_parse.h +# ${AVCODEC_GENERATED_SRC_PATH}/h264.h +# ${AVCODEC_GENERATED_SRC_PATH}/hevc/hevc.h +# ${AVCODEC_GENERATED_SRC_PATH}/mathops.h +# ${AVCODEC_GENERATED_SRC_PATH}/packet.h +# ${AVCODEC_GENERATED_SRC_PATH}/sei.h +# ${AVCODEC_GENERATED_SRC_PATH}/version_major.h +# ${AVCODEC_GENERATED_SRC_PATH}/vlc.h +# ${FFMPEG_GENERATED_SRC_PATH}/config.h +# ${FFMPEG_GENERATED_SRC_PATH}/libavutil/attributes.h +# ${FFMPEG_GENERATED_SRC_PATH}/libavutil/attributes_internal.h +# ${FFMPEG_GENERATED_SRC_PATH}/libavutil/intmath.h +#) +# +#set(CBS_SOURCE_FILES +# ${CBS_INCLUDE_PATH}/av1.h +# ${CBS_INCLUDE_PATH}/cbs_av1.h +# ${CBS_INCLUDE_PATH}/cbs_bsf.h +# ${CBS_INCLUDE_PATH}/cbs.h +# ${CBS_INCLUDE_PATH}/cbs_h2645.h +# ${CBS_INCLUDE_PATH}/cbs_h264.h +# ${CBS_INCLUDE_PATH}/cbs_h265.h +# ${CBS_INCLUDE_PATH}/cbs_jpeg.h +# ${CBS_INCLUDE_PATH}/cbs_mpeg2.h +# ${CBS_INCLUDE_PATH}/cbs_sei.h +# ${CBS_INCLUDE_PATH}/cbs_vp8.h +# ${CBS_INCLUDE_PATH}/cbs_vp9.h +# ${CBS_INCLUDE_PATH}/codec_desc.h +# ${CBS_INCLUDE_PATH}/codec_id.h +# ${CBS_INCLUDE_PATH}/codec_par.h +# ${CBS_INCLUDE_PATH}/defs.h +# ${CBS_INCLUDE_PATH}/get_bits.h +# ${CBS_INCLUDE_PATH}/h264_levels.h +# ${CBS_INCLUDE_PATH}/h2645_parse.h +# ${CBS_INCLUDE_PATH}/h264.h +# ${CBS_INCLUDE_PATH}/hevc/hevc.h +# ${CBS_INCLUDE_PATH}/mathops.h +# ${CBS_INCLUDE_PATH}/packet.h +# ${CBS_INCLUDE_PATH}/sei.h +# ${CBS_INCLUDE_PATH}/version_major.h +# ${CBS_INCLUDE_PATH}/vlc.h +# ${CMAKE_CURRENT_BINARY_DIR}/include/libavutil/intmath.h +# ${CBS_INCLUDE_PATH}/config.h +# +# ${AVCODEC_GENERATED_SRC_PATH}/cbs.c +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_h2645.c +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_av1.c +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_vp8.c +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_vp9.c +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_mpeg2.c +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_jpeg.c +# ${AVCODEC_GENERATED_SRC_PATH}/cbs_sei.c +# ${AVCODEC_GENERATED_SRC_PATH}/h264_levels.c +# ${AVCODEC_GENERATED_SRC_PATH}/h2645_parse.c +# ${AVCODEC_GENERATED_SRC_PATH}/vp8data.c +# ${FFMPEG_GENERATED_SRC_PATH}/libavutil/intmath.c) +# +## conditional headers based on architecture +#if (EXISTS ${AVCODEC_GENERATED_SRC_PATH}/${CBS_ARCH_PATH}/mathops.h) +# configure_file(${AVCODEC_GENERATED_SRC_PATH}/${CBS_ARCH_PATH}/mathops.h +# ${CBS_INCLUDE_PATH}/${CBS_ARCH_PATH}/mathops.h COPYONLY) +# list(APPEND CBS_SOURCE_FILES ${CBS_INCLUDE_PATH}/${CBS_ARCH_PATH}/mathops.h) +#endif() +#if (EXISTS ${FFMPEG_GENERATED_SRC_PATH}/libavutil/${CBS_ARCH_PATH}/asm.h) +# configure_file(${FFMPEG_GENERATED_SRC_PATH}/libavutil/${CBS_ARCH_PATH}/asm.h +# ${CMAKE_CURRENT_BINARY_DIR}/include/libavutil/${CBS_ARCH_PATH}/asm.h COPYONLY) +# list(APPEND CBS_SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/include/libavutil/${CBS_ARCH_PATH}/asm.h) +#endif() +#if (EXISTS ${FFMPEG_GENERATED_SRC_PATH}/libavutil/${CBS_ARCH_PATH}/intmath.h) +# configure_file(${FFMPEG_GENERATED_SRC_PATH}/libavutil/${CBS_ARCH_PATH}/intmath.h +# ${CMAKE_CURRENT_BINARY_DIR}/include/libavutil/${CBS_ARCH_PATH}/intmath.h COPYONLY) +# list(APPEND CBS_SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/include/libavutil/${CBS_ARCH_PATH}/intmath.h) +#endif() +# +#include_directories( +# ${CMAKE_CURRENT_BINARY_DIR}/include +# ${FFMPEG_GENERATED_SRC_PATH}) +# +#add_library(cbs ${CBS_SOURCE_FILES}) +#target_compile_options(cbs PRIVATE -Wall -Wno-incompatible-pointer-types -Wno-format -Wno-format-extra-args) +#add_dependencies(cbs cbs_configure) +#add_dependencies(${CMAKE_PROJECT_NAME} cbs) +# +#install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include +# DESTINATION ${CMAKE_INSTALL_PREFIX}) +#install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcbs.a +# DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) +#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libcbs.pc.in +# ${CMAKE_CURRENT_BINARY_DIR}/libcbs.pc @ONLY) +#install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcbs.pc +# DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) diff --git a/cmake/ffmpeg/mf.cmake b/cmake/ffmpeg/mf.cmake new file mode 100644 index 00000000..04268083 --- /dev/null +++ b/cmake/ffmpeg/mf.cmake @@ -0,0 +1,7 @@ +if(BUILD_FFMPEG_ALL_PATCHES OR BUILD_FFMPEG_MF_PATCHES) + file(GLOB FFMPEG_MF_FILES ${CMAKE_CURRENT_SOURCE_DIR}/patches/FFmpeg/MF/*.patch) + + foreach(patch_file ${FFMPEG_VAAPI_FILES}) + APPLY_GIT_PATCH(${FFMPEG_GENERATED_SRC_PATH} ${patch_file}) + endforeach() +endif() diff --git a/cmake/ffmpeg/nv_codec_headers.cmake b/cmake/ffmpeg/nv_codec_headers.cmake new file mode 100644 index 00000000..83e75f67 --- /dev/null +++ b/cmake/ffmpeg/nv_codec_headers.cmake @@ -0,0 +1,26 @@ +if(BUILD_FFMPEG_ALL_PATCHES OR BUILD_FFMPEG_NV_CODEC_HEADERS_PATCHES) + file(GLOB FFMPEG_NV_CODEC_HEADER_PATCH_FILES ${CMAKE_CURRENT_SOURCE_DIR}/patches/FFmpeg/nv-codec-headers/*.patch) + + foreach(patch_file ${FFMPEG_NV_CODEC_HEADER_PATCH_FILES}) + APPLY_GIT_PATCH(${FFMPEG_GENERATED_SRC_PATH} ${patch_file}) + endforeach() +endif() + +set(WORKING_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party/FFmpeg/nv-codec-headers") +UNIX_PATH(WORKING_DIR_UNIX ${WORKING_DIR}) +UNIX_PATH(DEST_DIR_UNIX ${CMAKE_CURRENT_BINARY_DIR}) +add_custom_target(nv_codec_headers + COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=${MSYSTEM} ${SHELL_CMD} ${SHELL_CMD_PREFIX} "cd ${WORKING_DIR_UNIX} && \ +make" + # this will install the headers to the CMAKE_CURRENT_BINARY_DIR/usr/local + COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=${MSYSTEM} ${SHELL_CMD} ${SHELL_CMD_PREFIX} "cd ${WORKING_DIR_UNIX} && \ +DESTDIR=${DEST_DIR_UNIX} make install" + WORKING_DIRECTORY ${WORKING_DIR} + COMMENT "Building nv-codec-headers" + COMMAND_EXPAND_LISTS + USES_TERMINAL +) +add_dependencies(${CMAKE_PROJECT_NAME} nv_codec_headers) +install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/usr/local/include/ffnvcodec" + DESTINATION include +) diff --git a/cmake/ffmpeg/svt_av1.cmake b/cmake/ffmpeg/svt_av1.cmake new file mode 100644 index 00000000..825b8ccc --- /dev/null +++ b/cmake/ffmpeg/svt_av1.cmake @@ -0,0 +1,20 @@ +if(BUILD_FFMPEG_ALL_PATCHES OR BUILD_FFMPEG_SVT_AV1_PATCHES) + file(GLOB FFMPEG_SVT_AV1_PATCH_FILES ${CMAKE_CURRENT_SOURCE_DIR}/patches/FFmpeg/SVT-AV1/*.patch) + + foreach(patch_file ${FFMPEG_SVT_AV1_PATCH_FILES}) + APPLY_GIT_PATCH(${FFMPEG_GENERATED_SRC_PATH} ${patch_file}) + endforeach() +endif() + +# options for SVT-AV1 +set(BUILD_APPS OFF CACHE BOOL "Build applications") +set(BUILD_DEC OFF CACHE BOOL "Build decoders") +set(ENABLE_AVX512 ON CACHE BOOL "Enable AVX512") +set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries") + +# build SVT-AV1 +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/FFmpeg/SVT-AV1 SVT-AV1 SYSTEM) +add_dependencies(${CMAKE_PROJECT_NAME} SvtAv1Enc) +install(TARGETS SvtAv1Enc + LIBRARY DESTINATION lib +) diff --git a/cmake/ffmpeg/vaapi.cmake b/cmake/ffmpeg/vaapi.cmake new file mode 100644 index 00000000..5232ad54 --- /dev/null +++ b/cmake/ffmpeg/vaapi.cmake @@ -0,0 +1,7 @@ +if(BUILD_FFMPEG_ALL_PATCHES OR BUILD_FFMPEG_VAAPI_PATCHES) + file(GLOB FFMPEG_VAAPI_FILES ${CMAKE_CURRENT_SOURCE_DIR}/patches/FFmpeg/VAAPI/*.patch) + + foreach(patch_file ${FFMPEG_VAAPI_FILES}) + APPLY_GIT_PATCH(${FFMPEG_GENERATED_SRC_PATH} ${patch_file}) + endforeach() +endif() diff --git a/cmake/ffmpeg/x264.cmake b/cmake/ffmpeg/x264.cmake new file mode 100644 index 00000000..d299dcf0 --- /dev/null +++ b/cmake/ffmpeg/x264.cmake @@ -0,0 +1,67 @@ +if(BUILD_FFMPEG_ALL_PATCHES OR BUILD_FFMPEG_X264_PATCHES) + file(GLOB FFMPEG_X264_FILES ${CMAKE_CURRENT_SOURCE_DIR}/patches/FFmpeg/x264/*.patch) + + foreach(patch_file ${FFMPEG_SVT_X264_FILES}) + APPLY_GIT_PATCH(${FFMPEG_GENERATED_SRC_PATH} ${patch_file}) + endforeach() +endif() + +if(${arch} STREQUAL "aarch64" OR ${arch} STREQUAL "arm64") + set(X264_ARCH aarch64) +elseif (${arch} STREQUAL "ppc64le") + set(X264_ARCH powerpc64le) +elseif (${arch} STREQUAL "amd64" OR ${arch} STREQUAL "x86_64") + set(X264_ARCH x86_64) +elseif (${arch} STREQUAL "mips") + set(X264_ARCH mips) # TODO: unknown if this is the correct value +else() + message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) +endif() + +if(WIN32) + set(X264_HOST ${X264_ARCH}-windows) +elseif(APPLE) + set(X264_HOST ${X264_ARCH}-macos) +elseif(UNIX) + set(X264_HOST ${X264_ARCH}-linux) +else() + message(FATAL_ERROR "Unsupported system name:" ${CMAKE_SYSTEM_NAME}) +endif() + +if(CMAKE_CROSSCOMPILING) + set(FFMPEG_X264_EXTRA_CONFIGURE + --cross-prefix=/usr/bin/${CMAKE_C_COMPILER_TARGET}- + --host=${X264_HOST} + ) +endif() + +# On Windows, the x264 submodule needs to have line endings converted to LF, see the README.md + +UNIX_PATH(CMAKE_CURRENT_BINARY_DIR_UNIX ${CMAKE_CURRENT_BINARY_DIR}) +set(WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/FFmpeg/x264) +UNIX_PATH(WORKING_DIR_UNIX ${WORKING_DIR}) +add_custom_target(x264 + COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=${MSYSTEM} ${SHELL_CMD} ${SHELL_CMD_PREFIX} "cd ${WORKING_DIR_UNIX} && \ +./configure \ +--prefix=${CMAKE_CURRENT_BINARY_DIR_UNIX}/x264 \ +--disable-cli \ +--enable-static \ +${FFMPEG_X264_EXTRA_CONFIGURE}" + COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=${MSYSTEM} ${SHELL_CMD} ${SHELL_CMD_PREFIX} "cd ${WORKING_DIR_UNIX} && \ +make" + COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=${MSYSTEM} ${SHELL_CMD} ${SHELL_CMD_PREFIX} "cd ${WORKING_DIR_UNIX} && \ +make install" + WORKING_DIRECTORY ${WORKING_DIR} + COMMENT "Building x264" + COMMAND_EXPAND_LISTS + USES_TERMINAL +) +add_dependencies(${CMAKE_PROJECT_NAME} x264) +set(X264_HEADER_FILES + ${CMAKE_CURRENT_BINARY_DIR}/x264/include/x264.h + ${CMAKE_CURRENT_BINARY_DIR}/x264/include/x264_config.h +) +install(FILES ${X264_HEADER_FILES} + DESTINATION include) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/x264/lib/libx264.a + DESTINATION lib) diff --git a/cmake/ffmpeg/x265.cmake b/cmake/ffmpeg/x265.cmake new file mode 100644 index 00000000..690b693f --- /dev/null +++ b/cmake/ffmpeg/x265.cmake @@ -0,0 +1,24 @@ +if(BUILD_FFMPEG_ALL_PATCHES OR BUILD_FFMPEG_X265_PATCHES) + file(GLOB FFMPEG_X265_FILES ${CMAKE_CURRENT_SOURCE_DIR}/patches/FFmpeg/x265/*.patch) + + foreach(patch_file ${FFMPEG_SVT_X265_FILES}) + APPLY_GIT_PATCH(${FFMPEG_GENERATED_SRC_PATH} ${patch_file}) + endforeach() +endif() + +# options for x265 +set(ENABLE_CLI OFF CACHE BOOL "Enable CLI") +set(ENABLE_SHARED OFF CACHE BOOL "Enable shared libraries") +set(STATIC_LINK_CRT ON CACHE BOOL "Static link CRT") + +# build x265 +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/FFmpeg/x265_git/source x265 SYSTEM) +add_dependencies(${CMAKE_PROJECT_NAME} x265-static) +set(X265_HEADER_FILES + ${CMAKE_CURRENT_BINARY_DIR}/x265/x265.h + ${CMAKE_CURRENT_BINARY_DIR}/x265/x265_config.h +) +set_target_properties(x265-static PROPERTIES PUBLIC_HEADER "${X265_HEADER_FILES}") +install(TARGETS x265-static + PUBLIC_HEADER DESTINATION include +) diff --git a/cmake/ffmpeg_cbs.cmake b/cmake/ffmpeg_cbs.cmake deleted file mode 100644 index 5276f5a2..00000000 --- a/cmake/ffmpeg_cbs.cmake +++ /dev/null @@ -1,179 +0,0 @@ -cmake_minimum_required(VERSION 3.2) - -project(cbs - DESCRIPTION "FFmpeg code subset to expose coded bitstream (CBS) internal APIs for Sunshine" - VERSION 0.1) - -set(CMAKE_GENERATED_SRC_PATH ${CMAKE_BINARY_DIR}/generated-src) - -# Apply patches -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/apply_git_patch.cmake) -APPLY_GIT_PATCH(${CMAKE_SOURCE_DIR}/ffmpeg_sources/ffmpeg - ${CMAKE_SOURCE_DIR}/ffmpeg_patches/cbs/01-explicit-intmath.patch) -APPLY_GIT_PATCH(${CMAKE_SOURCE_DIR}/ffmpeg_sources/ffmpeg - ${CMAKE_SOURCE_DIR}/ffmpeg_patches/cbs/02-include-cbs-config.patch) -APPLY_GIT_PATCH(${CMAKE_SOURCE_DIR}/ffmpeg_sources/ffmpeg - ${CMAKE_SOURCE_DIR}/ffmpeg_patches/cbs/03-remove-register.patch) -APPLY_GIT_PATCH(${CMAKE_SOURCE_DIR}/ffmpeg_sources/ffmpeg - ${CMAKE_SOURCE_DIR}/ffmpeg_patches/cbs/04-size-specifier.patch) - -file(COPY ${CMAKE_SOURCE_DIR}/ffmpeg_sources/ffmpeg DESTINATION ${CMAKE_GENERATED_SRC_PATH}) - -set(FFMPEG_GENERATED_SRC_PATH ${CMAKE_GENERATED_SRC_PATH}/ffmpeg) -set(AVCODEC_GENERATED_SRC_PATH ${CMAKE_GENERATED_SRC_PATH}/ffmpeg/libavcodec) -set(CBS_INCLUDE_PATH ${CMAKE_BINARY_DIR}/include/cbs) - -message("Running FFmpeg configure to generate platform config") - -# Explicit shell otherwise Windows runs outside the mingw environment -if (WIN32) - set(LEADING_SH_COMMAND sh) -endif () - -string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} arch) - -if (${arch} STREQUAL "aarch64" OR ${arch} STREQUAL "arm64") - set(CBS_ARCH_PATH arm) -elseif (${arch} STREQUAL "ppc64le") - set(CBS_ARCH_PATH ppc) -elseif (${arch} STREQUAL "amd64" OR ${arch} STREQUAL "x86_64") - set(CBS_ARCH_PATH x86) -else () - message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) -endif () - -if (CMAKE_CROSSCOMPILING) - set(FFMPEG_EXTRA_CONFIGURE --arch=${arch} --enable-cross-compile) -endif () - -# The generated config.h needs to have `CONFIG_CBS_` flags enabled (from `--enable-bsfs`) -execute_process( - COMMAND ${LEADING_SH_COMMAND} ./configure - --cc=${CMAKE_C_COMPILER} - --cxx=${CMAKE_CXX_COMPILER} - --ar=${CMAKE_AR} - --ranlib=${CMAKE_RANLIB} - --optflags=${CMAKE_C_FLAGS} - --disable-all - --disable-autodetect - --disable-iconv - --enable-avcodec - --enable-avutil - --enable-bsfs - --enable-gpl - --enable-static - ${FFMPEG_EXTRA_CONFIGURE} - WORKING_DIRECTORY ${FFMPEG_GENERATED_SRC_PATH} - COMMAND_ECHO STDOUT - COMMAND_ERROR_IS_FATAL ANY) - -# Headers needed to link for Sunshine -configure_file(${AVCODEC_GENERATED_SRC_PATH}/av1.h ${CBS_INCLUDE_PATH}/av1.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs_av1.h ${CBS_INCLUDE_PATH}/cbs_av1.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs_bsf.h ${CBS_INCLUDE_PATH}/cbs_bsf.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs.h ${CBS_INCLUDE_PATH}/cbs.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs_h2645.h ${CBS_INCLUDE_PATH}/cbs_h2645.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs_h264.h ${CBS_INCLUDE_PATH}/cbs_h264.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs_h265.h ${CBS_INCLUDE_PATH}/cbs_h265.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs_jpeg.h ${CBS_INCLUDE_PATH}/cbs_jpeg.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs_mpeg2.h ${CBS_INCLUDE_PATH}/cbs_mpeg2.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs_sei.h ${CBS_INCLUDE_PATH}/cbs_sei.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs_vp8.h ${CBS_INCLUDE_PATH}/cbs_vp8.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/cbs_vp9.h ${CBS_INCLUDE_PATH}/cbs_vp9.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/codec_desc.h ${CBS_INCLUDE_PATH}/codec_desc.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/codec_id.h ${CBS_INCLUDE_PATH}/codec_id.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/codec_par.h ${CBS_INCLUDE_PATH}/codec_par.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/defs.h ${CBS_INCLUDE_PATH}/defs.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/get_bits.h ${CBS_INCLUDE_PATH}/get_bits.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/h264_levels.h ${CBS_INCLUDE_PATH}/h264_levels.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/h2645_parse.h ${CBS_INCLUDE_PATH}/h2645_parse.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/h264.h ${CBS_INCLUDE_PATH}/h264.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/hevc/hevc.h ${CBS_INCLUDE_PATH}/hevc/hevc.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/mathops.h ${CBS_INCLUDE_PATH}/mathops.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/packet.h ${CBS_INCLUDE_PATH}/packet.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/sei.h ${CBS_INCLUDE_PATH}/sei.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/version_major.h ${CBS_INCLUDE_PATH}/version_major.h COPYONLY) -configure_file(${AVCODEC_GENERATED_SRC_PATH}/vlc.h ${CBS_INCLUDE_PATH}/vlc.h COPYONLY) -configure_file(${FFMPEG_GENERATED_SRC_PATH}/config.h ${CBS_INCLUDE_PATH}/config.h COPYONLY) -configure_file(${FFMPEG_GENERATED_SRC_PATH}/libavutil/attributes.h - ${CMAKE_BINARY_DIR}/include/libavutil/attributes.h COPYONLY) -configure_file(${FFMPEG_GENERATED_SRC_PATH}/libavutil/attributes_internal.h - ${CMAKE_BINARY_DIR}/include/libavutil/attributes_internal.h COPYONLY) -configure_file(${FFMPEG_GENERATED_SRC_PATH}/libavutil/intmath.h - ${CMAKE_BINARY_DIR}/include/libavutil/intmath.h COPYONLY) - -set(CBS_SOURCE_FILES - ${CBS_INCLUDE_PATH}/av1.h - ${CBS_INCLUDE_PATH}/cbs_av1.h - ${CBS_INCLUDE_PATH}/cbs_bsf.h - ${CBS_INCLUDE_PATH}/cbs.h - ${CBS_INCLUDE_PATH}/cbs_h2645.h - ${CBS_INCLUDE_PATH}/cbs_h264.h - ${CBS_INCLUDE_PATH}/cbs_h265.h - ${CBS_INCLUDE_PATH}/cbs_jpeg.h - ${CBS_INCLUDE_PATH}/cbs_mpeg2.h - ${CBS_INCLUDE_PATH}/cbs_sei.h - ${CBS_INCLUDE_PATH}/cbs_vp8.h - ${CBS_INCLUDE_PATH}/cbs_vp9.h - ${CBS_INCLUDE_PATH}/codec_desc.h - ${CBS_INCLUDE_PATH}/codec_id.h - ${CBS_INCLUDE_PATH}/codec_par.h - ${CBS_INCLUDE_PATH}/defs.h - ${CBS_INCLUDE_PATH}/get_bits.h - ${CBS_INCLUDE_PATH}/h264_levels.h - ${CBS_INCLUDE_PATH}/h2645_parse.h - ${CBS_INCLUDE_PATH}/h264.h - ${CBS_INCLUDE_PATH}/hevc/hevc.h - ${CBS_INCLUDE_PATH}/mathops.h - ${CBS_INCLUDE_PATH}/packet.h - ${CBS_INCLUDE_PATH}/sei.h - ${CBS_INCLUDE_PATH}/version_major.h - ${CBS_INCLUDE_PATH}/vlc.h - ${CMAKE_BINARY_DIR}/include/libavutil/intmath.h - ${CBS_INCLUDE_PATH}/config.h - - ${AVCODEC_GENERATED_SRC_PATH}/cbs.c - ${AVCODEC_GENERATED_SRC_PATH}/cbs_h2645.c - ${AVCODEC_GENERATED_SRC_PATH}/cbs_av1.c - ${AVCODEC_GENERATED_SRC_PATH}/cbs_vp8.c - ${AVCODEC_GENERATED_SRC_PATH}/cbs_vp9.c - ${AVCODEC_GENERATED_SRC_PATH}/cbs_mpeg2.c - ${AVCODEC_GENERATED_SRC_PATH}/cbs_jpeg.c - ${AVCODEC_GENERATED_SRC_PATH}/cbs_sei.c - ${AVCODEC_GENERATED_SRC_PATH}/h264_levels.c - ${AVCODEC_GENERATED_SRC_PATH}/h2645_parse.c - ${AVCODEC_GENERATED_SRC_PATH}/vp8data.c - ${FFMPEG_GENERATED_SRC_PATH}/libavutil/intmath.c) - -# conditional headers based on architecture -if (EXISTS ${AVCODEC_GENERATED_SRC_PATH}/${CBS_ARCH_PATH}/mathops.h) - configure_file(${AVCODEC_GENERATED_SRC_PATH}/${CBS_ARCH_PATH}/mathops.h - ${CBS_INCLUDE_PATH}/${CBS_ARCH_PATH}/mathops.h COPYONLY) - list(APPEND CBS_SOURCE_FILES ${CBS_INCLUDE_PATH}/${CBS_ARCH_PATH}/mathops.h) -endif() -if (EXISTS ${FFMPEG_GENERATED_SRC_PATH}/libavutil/${CBS_ARCH_PATH}/asm.h) - configure_file(${FFMPEG_GENERATED_SRC_PATH}/libavutil/${CBS_ARCH_PATH}/asm.h - ${CMAKE_BINARY_DIR}/include/libavutil/${CBS_ARCH_PATH}/asm.h COPYONLY) - list(APPEND CBS_SOURCE_FILES ${CMAKE_BINARY_DIR}/include/libavutil/${CBS_ARCH_PATH}/asm.h) -endif() -if (EXISTS ${FFMPEG_GENERATED_SRC_PATH}/libavutil/${CBS_ARCH_PATH}/intmath.h) - configure_file(${FFMPEG_GENERATED_SRC_PATH}/libavutil/${CBS_ARCH_PATH}/intmath.h - ${CMAKE_BINARY_DIR}/include/libavutil/${CBS_ARCH_PATH}/intmath.h COPYONLY) - list(APPEND CBS_SOURCE_FILES ${CMAKE_BINARY_DIR}/include/libavutil/${CBS_ARCH_PATH}/intmath.h) -endif() - -include_directories( - ${CMAKE_BINARY_DIR}/include - ${FFMPEG_GENERATED_SRC_PATH}) - -add_library(cbs ${CBS_SOURCE_FILES}) -target_compile_options(cbs PRIVATE -Wall -Wno-incompatible-pointer-types -Wno-format -Wno-format-extra-args) - -install(DIRECTORY ${CMAKE_BINARY_DIR}/include - DESTINATION ${CMAKE_INSTALL_PREFIX}) -install(FILES ${CMAKE_BINARY_DIR}/libcbs.a - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libcbs.pc.in - ${CMAKE_BINARY_DIR}/libcbs.pc @ONLY) -install(FILES ${CMAKE_BINARY_DIR}/libcbs.pc - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) diff --git a/cmake/toolchain/aarch64-linux/crosscompile.cmake b/cmake/toolchain/aarch64-linux/crosscompile.cmake deleted file mode 100644 index da8e77a4..00000000 --- a/cmake/toolchain/aarch64-linux/crosscompile.cmake +++ /dev/null @@ -1,9 +0,0 @@ -# CMake toolchain file for cross compiling to linux aarch64 - -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR aarch64) - -set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) -set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) - -SET(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) diff --git a/cmake/toolchain/powerpc64le-linux/crosscompile.cmake b/cmake/toolchain/powerpc64le-linux/crosscompile.cmake deleted file mode 100644 index 25077dd3..00000000 --- a/cmake/toolchain/powerpc64le-linux/crosscompile.cmake +++ /dev/null @@ -1,9 +0,0 @@ -# CMake toolchain file for cross compiling to linux powerpc64le - -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR ppc64le) - -set(CMAKE_C_COMPILER powerpc64le-linux-gnu-gcc) -set(CMAKE_CXX_COMPILER powerpc64le-linux-gnu-g++) - -SET(CMAKE_FIND_ROOT_PATH /usr/powerpc64le-linux-gnu) diff --git a/cmake/toolchains/aarch64-linux-gnu.cmake b/cmake/toolchains/aarch64-linux-gnu.cmake new file mode 100644 index 00000000..5ad20750 --- /dev/null +++ b/cmake/toolchains/aarch64-linux-gnu.cmake @@ -0,0 +1,12 @@ +# CMake toolchain file for cross compiling to linux aarch64 + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_C_COMPILER_TARGET aarch64-linux-gnu) +set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET}) +set(CCPREFIX ${CMAKE_C_COMPILER_TARGET}-) +set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc) +set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER_TARGET}-g++) + +SET(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_C_COMPILER_TARGET}) diff --git a/cmake/toolchain/aarch64-macos/crosscompile.cmake b/cmake/toolchains/arm64-apple-macosx.cmake similarity index 82% rename from cmake/toolchain/aarch64-macos/crosscompile.cmake rename to cmake/toolchains/arm64-apple-macosx.cmake index 78b6c4f5..6c22e068 100644 --- a/cmake/toolchain/aarch64-macos/crosscompile.cmake +++ b/cmake/toolchains/arm64-apple-macosx.cmake @@ -4,7 +4,8 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR arm64) set(CMAKE_OSX_ARCHITECTURES arm64) -set(CMAKE_C_COMPILER clang) set(CMAKE_C_COMPILER_TARGET arm64-apple-macosx) +set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET}) + +set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) -set(CMAKE_CXX_COMPILER_TARGET arm64-apple-macosx) diff --git a/cmake/toolchains/powerpc64le-linux-gnu.cmake b/cmake/toolchains/powerpc64le-linux-gnu.cmake new file mode 100644 index 00000000..ad1daf0f --- /dev/null +++ b/cmake/toolchains/powerpc64le-linux-gnu.cmake @@ -0,0 +1,12 @@ +# CMake toolchain file for cross compiling to linux powerpc64le + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR ppc64le) + +set(CMAKE_C_COMPILER_TARGET powerpc64le-linux-gnu) +set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET}) +set(CCPREFIX ${CMAKE_C_COMPILER_TARGET}-) +set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc) +set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER_TARGET}-g++) + +SET(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_C_COMPILER_TARGET}) diff --git a/cmake/unix_path.cmake b/cmake/unix_path.cmake new file mode 100644 index 00000000..55fd29e3 --- /dev/null +++ b/cmake/unix_path.cmake @@ -0,0 +1,21 @@ +# This macro converts the path to unix style for use in msys2 shells. +# Arguments are variable name and path + +# UNIX_PATH: args = `variable`, `path` +macro(UNIX_PATH variable path) + # replacements + string(REPLACE "\\" "/" temp_path "${path}") + string(REPLACE " " "\\ " temp_path "${temp_path}") + string(REPLACE "(" "\\(" temp_path "${temp_path}") + string(REPLACE ")" "\\)" temp_path "${temp_path}") + + # extract and convert the drive letter to lowercase + string(REGEX REPLACE "^([A-Za-z]):.*" "\\1" drive_letter "${temp_path}") + string(TOLOWER "${drive_letter}" drive_letter) + + # replace the drive letter in the path with / + string(REGEX REPLACE "^[A-Za-z]:" "/${drive_letter}" temp_path "${temp_path}") + + # set the output variable + set(${variable} "${temp_path}") +endmacro() diff --git a/ffmpeg_patches/ffmpeg/01-amf-colorspace.patch b/patches/FFmpeg/AMF/01-amf-colorspace.patch similarity index 100% rename from ffmpeg_patches/ffmpeg/01-amf-colorspace.patch rename to patches/FFmpeg/AMF/01-amf-colorspace.patch diff --git a/ffmpeg_patches/ffmpeg/02-idr-on-amf.patch b/patches/FFmpeg/AMF/02-idr-on-amf.patch similarity index 100% rename from ffmpeg_patches/ffmpeg/02-idr-on-amf.patch rename to patches/FFmpeg/AMF/02-idr-on-amf.patch diff --git a/ffmpeg_patches/ffmpeg/03-amfenc-disable-buffering.patch b/patches/FFmpeg/AMF/03-amfenc-disable-buffering.patch similarity index 100% rename from ffmpeg_patches/ffmpeg/03-amfenc-disable-buffering.patch rename to patches/FFmpeg/AMF/03-amfenc-disable-buffering.patch diff --git a/ffmpeg_patches/ffmpeg/06-amfenc-query-timeout.patch b/patches/FFmpeg/AMF/04-amfenc-query-timeout.patch similarity index 100% rename from ffmpeg_patches/ffmpeg/06-amfenc-query-timeout.patch rename to patches/FFmpeg/AMF/04-amfenc-query-timeout.patch diff --git a/ffmpeg_patches/ffmpeg/04-mfenc-lowlatency.patch b/patches/FFmpeg/MF/01-mfenc-lowlatency.patch similarity index 100% rename from ffmpeg_patches/ffmpeg/04-mfenc-lowlatency.patch rename to patches/FFmpeg/MF/01-mfenc-lowlatency.patch diff --git a/patches/FFmpeg/SVT-AV1/.keep b/patches/FFmpeg/SVT-AV1/.keep new file mode 100644 index 00000000..e69de29b diff --git a/ffmpeg_patches/ffmpeg/05-vaapi-customized-surface-alignment.patch b/patches/FFmpeg/VAAPI/01-vaapi-customized-surface-alignment.patch similarity index 100% rename from ffmpeg_patches/ffmpeg/05-vaapi-customized-surface-alignment.patch rename to patches/FFmpeg/VAAPI/01-vaapi-customized-surface-alignment.patch diff --git a/ffmpeg_patches/ffmpeg/07-vaapi-leak.patch b/patches/FFmpeg/VAAPI/02-vaapi-leak.patch similarity index 100% rename from ffmpeg_patches/ffmpeg/07-vaapi-leak.patch rename to patches/FFmpeg/VAAPI/02-vaapi-leak.patch diff --git a/ffmpeg_patches/cbs/01-explicit-intmath.patch b/patches/FFmpeg/cbs/01-explicit-intmath.patch similarity index 100% rename from ffmpeg_patches/cbs/01-explicit-intmath.patch rename to patches/FFmpeg/cbs/01-explicit-intmath.patch diff --git a/ffmpeg_patches/cbs/02-include-cbs-config.patch b/patches/FFmpeg/cbs/02-include-cbs-config.patch similarity index 100% rename from ffmpeg_patches/cbs/02-include-cbs-config.patch rename to patches/FFmpeg/cbs/02-include-cbs-config.patch diff --git a/ffmpeg_patches/cbs/03-remove-register.patch b/patches/FFmpeg/cbs/03-remove-register.patch similarity index 100% rename from ffmpeg_patches/cbs/03-remove-register.patch rename to patches/FFmpeg/cbs/03-remove-register.patch diff --git a/ffmpeg_patches/cbs/04-size-specifier.patch b/patches/FFmpeg/cbs/04-size-specifier.patch similarity index 100% rename from ffmpeg_patches/cbs/04-size-specifier.patch rename to patches/FFmpeg/cbs/04-size-specifier.patch diff --git a/patches/FFmpeg/nv-codec-headers/.keep b/patches/FFmpeg/nv-codec-headers/.keep new file mode 100644 index 00000000..e69de29b diff --git a/patches/FFmpeg/x264/.keep b/patches/FFmpeg/x264/.keep new file mode 100644 index 00000000..e69de29b diff --git a/patches/FFmpeg/x265/.keep b/patches/FFmpeg/x265/.keep new file mode 100644 index 00000000..e69de29b diff --git a/ffmpeg_sources/AMF b/third-party/FFmpeg/AMF similarity index 100% rename from ffmpeg_sources/AMF rename to third-party/FFmpeg/AMF diff --git a/ffmpeg_sources/ffmpeg b/third-party/FFmpeg/FFmpeg similarity index 100% rename from ffmpeg_sources/ffmpeg rename to third-party/FFmpeg/FFmpeg diff --git a/ffmpeg_sources/SVT-AV1 b/third-party/FFmpeg/SVT-AV1 similarity index 100% rename from ffmpeg_sources/SVT-AV1 rename to third-party/FFmpeg/SVT-AV1 diff --git a/ffmpeg_sources/nv-codec-headers b/third-party/FFmpeg/nv-codec-headers similarity index 100% rename from ffmpeg_sources/nv-codec-headers rename to third-party/FFmpeg/nv-codec-headers diff --git a/ffmpeg_sources/x264 b/third-party/FFmpeg/x264 similarity index 100% rename from ffmpeg_sources/x264 rename to third-party/FFmpeg/x264 diff --git a/ffmpeg_sources/x265_git b/third-party/FFmpeg/x265_git similarity index 100% rename from ffmpeg_sources/x265_git rename to third-party/FFmpeg/x265_git