From e38c9d192505b76227acb8a645a405e986bfc696 Mon Sep 17 00:00:00 2001 From: Samuel Audet Date: Fri, 21 Jan 2022 10:52:14 +0900 Subject: [PATCH] * Introduce `macosx-arm64` builds to presets for FFmpeg (issue bytedeco/javacv#1696) --- .github/workflows/ffmpeg.yml | 9 ++- CHANGELOG.md | 2 +- ffmpeg/cppbuild.sh | 111 ++++++++++++++++++++++++++++++++++- ffmpeg/platform/pom.xml | 9 ++- pom.xml | 1 + 5 files changed, 128 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ffmpeg.yml b/.github/workflows/ffmpeg.yml index 13f4c3bd0f4..892c03a0e7d 100644 --- a/.github/workflows/ffmpeg.yml +++ b/.github/workflows/ffmpeg.yml @@ -88,6 +88,13 @@ jobs: ext: ["", -gpl] steps: - uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions + macosx-arm64: + runs-on: macos-10.15 + strategy: + matrix: + ext: ["", -gpl] + steps: + - uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions macosx-x86_64: runs-on: macos-10.15 strategy: @@ -110,7 +117,7 @@ jobs: steps: - uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions redeploy: - needs: [android-arm, android-arm64, android-x86, android-x86_64, linux-armhf, linux-arm64, linux-ppc64le, linux-x86, linux-x86_64, macosx-x86_64, windows-x86, windows-x86_64] + needs: [android-arm, android-arm64, android-x86, android-x86_64, linux-armhf, linux-arm64, linux-ppc64le, linux-x86, linux-x86_64, macosx-arm64, macosx-x86_64, windows-x86, windows-x86_64] runs-on: ubuntu-18.04 steps: - uses: bytedeco/javacpp-presets/.github/actions/redeploy@actions diff --git a/CHANGELOG.md b/CHANGELOG.md index 2908bd26656..119698a3406 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * Add to `torch.Tensor` convenient `create()`, `createBuffer()`, and `createIndexer()` factory methods for PyTorch * Upgrade requirements to Android 7.0 for camera support in OpenCV and FFmpeg ([issue bytedeco/javacv#1692](https://github.com/bytedeco/javacv/issues/1692)) * Include new `llvm-c/Transforms/PassBuilder.h` header file in presets for LLVM ([pull #1093](https://github.com/bytedeco/javacpp-presets/pull/1093)) - * Introduce `macosx-arm64` builds to presets for OpenBLAS, OpenCV ([issue #1069](https://github.com/bytedeco/javacpp-presets/issues/1069)), LLVM ([pull #1092](https://github.com/bytedeco/javacpp-presets/pull/1092)) + * Introduce `macosx-arm64` builds to presets for OpenCV, FFmpeg, OpenBLAS ([issue #1069](https://github.com/bytedeco/javacpp-presets/issues/1069)), LLVM ([pull #1092](https://github.com/bytedeco/javacpp-presets/pull/1092)) * Add presets for LZ4 1.9.3 ([pull #1094](https://github.com/bytedeco/javacpp-presets/pull/1094)), Triton Inference Server 2.17.0 ([pull #1085](https://github.com/bytedeco/javacpp-presets/pull/1085)) * Add presets for the NvToolsExt (NVTX) module of CUDA ([issue #1068](https://github.com/bytedeco/javacpp-presets/issues/1068)) * Increase the amount of function pointers available for callbacks in presets for Qt ([pull #1080](https://github.com/bytedeco/javacpp-presets/pull/1080)) diff --git a/ffmpeg/cppbuild.sh b/ffmpeg/cppbuild.sh index 4d816260661..ef4809e13fb 100755 --- a/ffmpeg/cppbuild.sh +++ b/ffmpeg/cppbuild.sh @@ -1319,7 +1319,116 @@ EOF make install ;; - macosx-*) + macosx-arm64) + export CFLAGS="-arch arm64 -I$INSTALL_PATH/include/" + export CXXFLAGS="$CFLAGS" + export CPPFLAGS="$CFLAGS" + echo "" + echo "--------------------" + echo "Building zlib" + echo "--------------------" + echo "" + cd $ZLIB + CC="clang -arch arm64 -fPIC" ./configure --prefix=$INSTALL_PATH --static + make -j $MAKEJ V=0 + make install + echo "" + echo "--------------------" + echo "Building LAME" + echo "--------------------" + echo "" + cd ../$LAME + ./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=aarch64-apple-darwin + make -j $MAKEJ V=0 + make install + echo "" + echo "--------------------" + echo "Building XML2" + echo "--------------------" + echo "" + cd ../$XML2 + ./configure --prefix=$INSTALL_PATH $LIBXML_CONFIG --host=aarch64-apple-darwin + make -j $MAKEJ V=0 + make install + echo "" + echo "--------------------" + echo "Building speex" + echo "--------------------" + echo "" + cd ../$SPEEX + ./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=aarch64-apple-darwin + make -j $MAKEJ V=0 + make install + cd ../$OPUS + ./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=aarch64-apple-darwin + make -j $MAKEJ V=0 + make install + cd ../$OPENCORE_AMR + ./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=aarch64-apple-darwin + make -j $MAKEJ V=0 + make install + cd ../$VO_AMRWBENC + ./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=aarch64-apple-darwin + make -j $MAKEJ V=0 + make install + cd ../$OPENSSL + ./Configure darwin64-arm64-cc -fPIC no-shared --prefix=$INSTALL_PATH + make -s -j $MAKEJ + make install_sw + cd ../srt-$LIBSRT_VERSION + CFLAGS="-I$INSTALL_PATH/include/" CXXFLAGS="-I$INSTALL_PATH/include/" LDFLAGS="-L$INSTALL_PATH/lib/" $CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH $SRT_CONFIG -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_SYSTEM_VERSION=1 -DCMAKE_SYSTEM_PROCESSOR=armv8 -DCMAKE_CXX_FLAGS="$CXXFLAGS" -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" . + + make -j $MAKEJ V=0 + make install + cd ../openh264-$OPENH264_VERSION + make -j $MAKEJ DESTDIR=./ PREFIX=.. OS=darwin ARCH=arm64 USE_ASM=No install-static CC="clang -arch arm64" CXX="clang++ -arch arm64" + cd ../$X264 + ./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --disable-asm --disable-cli --host=aarch64-apple-darwin --extra-cflags="$CFLAGS" + make -j $MAKEJ V=0 + make install + cd ../x265-$X265/build/linux + # from x265 multilib.sh + mkdir -p 8bit 10bit 12bit + + cd 12bit + $CMAKE ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON -DENABLE_LIBNUMA=OFF -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_SYSTEM_VERSION=1 -DCMAKE_SYSTEM_PROCESSOR=armv8 -DCMAKE_CXX_FLAGS="$CXXFLAGS -fPIC" -DCMAKE_C_FLAGS="$CFLAGS -fPIC" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_BUILD_TYPE=Release -DENABLE_ASSEMBLY=OFF + make -j $MAKEJ + + cd ../10bit + $CMAKE ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DENABLE_LIBNUMA=OFF -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_SYSTEM_VERSION=1 -DCMAKE_SYSTEM_PROCESSOR=armv8 -DCMAKE_CXX_FLAGS="$CXXFLAGS -fPIC" -DCMAKE_C_FLAGS="$CFLAGS -fPIC" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_BUILD_TYPE=Release -DENABLE_ASSEMBLY=OFF + make -j $MAKEJ + + cd ../8bit + ln -sf ../10bit/libx265.a libx265_main10.a + ln -sf ../12bit/libx265.a libx265_main12.a + $CMAKE ../../../source -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DENABLE_SHARED:BOOL=OFF -DENABLE_LIBNUMA=OFF -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_SYSTEM_VERSION=1 -DCMAKE_SYSTEM_PROCESSOR=armv8 -DCMAKE_CXX_FLAGS="$CXXFLAGS -fPIC" -DCMAKE_C_FLAGS="$CFLAGS -fPIC" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_BUILD_TYPE=Release -DENABLE_ASSEMBLY=OFF -DENABLE_CLI=OFF + make -j $MAKEJ + + # rename the 8bit library, then combine all three into libx265.a + mv libx265.a libx265_main.a + /usr/bin/libtool -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a 2>/dev/null + + make install + # ---- + cd ../../../ + cd ../libvpx-$VPX_VERSION + sedinplace '/avx512/d' configure + CC="clang -arch arm64" CXX="clang++ -arch arm64" ./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-examples --disable-unit-tests --target=generic-gnu + make -j $MAKEJ + sedinplace '/HAS_AVX512/d' vpx_dsp_rtcd.h + make install + cd ../freetype-$FREETYPE_VERSION + ./configure --prefix=$INSTALL_PATH --with-bzip2=no --with-harfbuzz=no --with-png=no --with-brotli=no --enable-static --disable-shared --with-pic --host=aarch64-apple-darwin + make -j $MAKEJ + make install + cd ../ffmpeg-$FFMPEG_VERSION + patch -Np1 < ../../../ffmpeg-macosx.patch + LDEXEFLAGS='-Wl,-rpath,@loader_path/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-pthreads --enable-indev=avfoundation --cc="clang -arch arm64" --extra-cflags="-I../include/ -I../include/libxml2" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl -lz -lm" --enable-cross-compile --arch=arm64 --target-os=darwin + make -j $MAKEJ + make install + ;; + + macosx-x86_64) export AS="nasm" echo "" echo "--------------------" diff --git a/ffmpeg/platform/pom.xml b/ffmpeg/platform/pom.xml index a763b9dec63..9bd9030e9cd 100644 --- a/ffmpeg/platform/pom.xml +++ b/ffmpeg/platform/pom.xml @@ -84,6 +84,12 @@ ${project.version} ${javacpp.platform.linux-ppc64le} + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.macosx-arm64} + ${project.groupId} ${javacpp.moduleId} @@ -114,7 +120,7 @@ - ${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-linux-armhf.jar ${javacpp.moduleId}-linux-arm64.jar ${javacpp.moduleId}-linux-ppc64le.jar ${javacpp.moduleId}-macosx-x86_64.jar ${javacpp.moduleId}-windows-x86.jar ${javacpp.moduleId}-windows-x86_64.jar + ${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-linux-armhf.jar ${javacpp.moduleId}-linux-arm64.jar ${javacpp.moduleId}-linux-ppc64le.jar ${javacpp.moduleId}-macosx-arm64.jar ${javacpp.moduleId}-macosx-x86_64.jar ${javacpp.moduleId}-windows-x86.jar ${javacpp.moduleId}-windows-x86_64.jar @@ -168,6 +174,7 @@ requires static org.bytedeco.${javacpp.moduleId}.linux.armhf; requires static org.bytedeco.${javacpp.moduleId}.linux.arm64; requires static org.bytedeco.${javacpp.moduleId}.linux.ppc64le; + requires static org.bytedeco.${javacpp.moduleId}.macosx.arm64; requires static org.bytedeco.${javacpp.moduleId}.macosx.x86_64; requires static org.bytedeco.${javacpp.moduleId}.windows.x86; requires static org.bytedeco.${javacpp.moduleId}.windows.x86_64; diff --git a/pom.xml b/pom.xml index d2d34fe4b8f..03c8c56368b 100644 --- a/pom.xml +++ b/pom.xml @@ -1435,6 +1435,7 @@ opencv + ffmpeg openblas llvm