Skip to content

Commit

Permalink
* Introduce macosx-arm64 builds to presets for FFmpeg (issue byted…
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed Jan 21, 2022
1 parent eeee3e7 commit e38c9d1
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 4 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
111 changes: 110 additions & 1 deletion ffmpeg/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "--------------------"
Expand Down
9 changes: 8 additions & 1 deletion ffmpeg/platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@
<version>${project.version}</version>
<classifier>${javacpp.platform.linux-ppc64le}</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.macosx-arm64}</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
Expand Down Expand Up @@ -114,7 +120,7 @@
<configuration>
<archive>
<manifestEntries>
<Class-Path>${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</Class-Path>
<Class-Path>${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</Class-Path>
</manifestEntries>
</archive>
</configuration>
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@
</activation>
<modules>
<module>opencv</module>
<module>ffmpeg</module>
<module>openblas</module>
<module>llvm</module>
</modules>
Expand Down

0 comments on commit e38c9d1

Please sign in to comment.