Skip to content

Commit d43cf11

Browse files
committed
Enable Kvazaar encoder support for FFmpeg
1 parent b0c8a07 commit d43cf11

2 files changed

Lines changed: 102 additions & 3 deletions

File tree

ffmpeg/LICENSE.kvazaar

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice, this
11+
list of conditions and the following disclaimer in the documentation and/or
12+
other materials provided with the distribution.
13+
14+
* Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ffmpeg/cppbuild.sh

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if [[ -z "$PLATFORM" ]]; then
88
fi
99

1010
DISABLE="--disable-iconv --disable-opencl --disable-sdl2 --disable-bzlib --disable-lzma --disable-linux-perf --disable-xlib"
11-
ENABLE="--enable-shared --enable-version3 --enable-runtime-cpudetect --enable-zlib --enable-libmp3lame --enable-libspeex --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-openssl --enable-libopenh264 --enable-libvpx --enable-libfreetype --enable-libharfbuzz --enable-libopus --enable-libxml2 --enable-libsrt --enable-libwebp --enable-libaom --enable-libsvtav1 --enable-libzimg"
11+
ENABLE="--enable-shared --enable-version3 --enable-runtime-cpudetect --enable-zlib --enable-libmp3lame --enable-libspeex --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-openssl --enable-libopenh264 --enable-libvpx --enable-libfreetype --enable-libharfbuzz --enable-libopus --enable-libxml2 --enable-libsrt --enable-libwebp --enable-libaom --enable-libsvtav1 --enable-libzimg --enable-libkvazaar"
1212
ENABLE_VULKAN="--enable-vulkan --enable-hwaccel=h264_vulkan --enable-hwaccel=hevc_vulkan --enable-hwaccel=av1_vulkan"
1313

1414
if [[ "$EXTENSION" == *gpl ]]; then
@@ -50,6 +50,7 @@ WEBP_VERSION=1.6.0
5050
AOMAV1_VERSION=3.14.1
5151
SVTAV1_VERSION=4.1.0
5252
ZIMG_VERSION=3.0.6
53+
KVAZAAR_VERSION=2.3.2
5354
FFMPEG_VERSION=8.1.1
5455

5556
# Vendored snapshot of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20847.patch
@@ -78,6 +79,7 @@ download https://github.com/webmproject/libwebp/archive/refs/tags/v$WEBP_VERSION
7879
download https://storage.googleapis.com/aom-releases/libaom-$AOMAV1_VERSION.tar.gz aom-$AOMAV1_VERSION.tar.gz
7980
download https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v$SVTAV1_VERSION/SVT-AV1-v$SVTAV1_VERSION.tar.gz SVT-AV1-$SVTAV1_VERSION.tar.gz
8081
download https://github.com/sekrit-twc/zimg/archive/refs/tags/release-$ZIMG_VERSION.tar.gz zimg-release-$ZIMG_VERSION.tar.gz
82+
download https://github.com/ultravideo/kvazaar/archive/refs/tags/v$KVAZAAR_VERSION.tar.gz kvazaar-$KVAZAAR_VERSION.tar.gz
8183
download https://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 ffmpeg-$FFMPEG_VERSION.tar.bz2
8284

8385
mkdir -p $PLATFORM$EXTENSION
@@ -106,6 +108,7 @@ tar --totals -xzf ../libwebp-$WEBP_VERSION.tar.gz
106108
tar --totals -xzf ../aom-$AOMAV1_VERSION.tar.gz
107109
tar --totals -xzf ../SVT-AV1-$SVTAV1_VERSION.tar.gz
108110
tar --totals -xzf ../zimg-release-$ZIMG_VERSION.tar.gz
111+
tar --totals -xzf ../kvazaar-$KVAZAAR_VERSION.tar.gz
109112
tar --totals -xjf ../ffmpeg-$FFMPEG_VERSION.tar.bz2
110113

111114
if [[ "${ACLOCAL_PATH:-}" == C:\\msys64\\* ]]; then
@@ -308,6 +311,11 @@ EOF
308311
make -j $MAKEJ
309312
make install
310313
cd ..
314+
cd ../kvazaar-$KVAZAAR_VERSION
315+
./autogen.sh
316+
CFLAGS="$ANDROID_FLAGS" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic --host=arm-linux
317+
make -j $MAKEJ V=0
318+
make install
311319
cd ../ffmpeg-$FFMPEG_VERSION
312320
sedinplace 's/unsigned long int/unsigned int/g' libavdevice/v4l2.c
313321
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' ./configure --prefix=.. $DISABLE $ENABLE --enable-jni --enable-mediacodec --enable-pthreads --enable-cross-compile --cross-prefix="$ANDROID_PREFIX-" --ar="$AR" --ranlib="$RANLIB" --cc="$CC" --cxx="$CXX" --strip="$STRIP" --sysroot="$ANDROID_ROOT" --target-os=android --arch=arm --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1 $ANDROID_FLAGS" --extra-ldflags="-L../lib/ $ANDROID_FLAGS" --extra-libs="$ANDROID_LIBS -lz -latomic" --disable-symver --pkg-config=/usr/bin/pkg-config || cat ffbuild/config.log
@@ -482,6 +490,11 @@ EOF
482490
make -j $MAKEJ
483491
make install
484492
cd ..
493+
cd ../kvazaar-$KVAZAAR_VERSION
494+
./autogen.sh
495+
CFLAGS="$ANDROID_FLAGS" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic --host=aarch64-linux
496+
make -j $MAKEJ V=0
497+
make install
485498
cd ../ffmpeg-$FFMPEG_VERSION
486499
sedinplace 's/unsigned long int/unsigned int/g' libavdevice/v4l2.c
487500
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' ./configure --prefix=.. $DISABLE $ENABLE --enable-jni --enable-mediacodec --enable-pthreads --enable-cross-compile --cross-prefix="$ANDROID_PREFIX-" --ar="$AR" --ranlib="$RANLIB" --cc="$CC" --cxx="$CXX" --strip="$STRIP" --sysroot="$ANDROID_ROOT" --target-os=android --arch=aarch64 --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1 $ANDROID_FLAGS" --extra-ldflags="-L../lib/ $ANDROID_FLAGS" --extra-libs="$ANDROID_LIBS -lz -latomic" --disable-symver --pkg-config=/usr/bin/pkg-config || cat ffbuild/config.log
@@ -653,6 +666,11 @@ EOF
653666
make -j $MAKEJ
654667
make install
655668
cd ..
669+
cd ../kvazaar-$KVAZAAR_VERSION
670+
./autogen.sh
671+
CFLAGS="$ANDROID_FLAGS" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic --host=i686-linux
672+
make -j $MAKEJ V=0
673+
make install
656674
cd ../ffmpeg-$FFMPEG_VERSION
657675
sedinplace 's/unsigned long int/unsigned int/g' libavdevice/v4l2.c
658676
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' ./configure --prefix=.. $DISABLE $ENABLE --enable-jni --enable-mediacodec --enable-pthreads --enable-cross-compile --cross-prefix="$ANDROID_PREFIX-" --ar="$AR" --ranlib="$RANLIB" --cc="$CC" --cxx="$CXX" --strip="$STRIP" --sysroot="$ANDROID_ROOT" --target-os=android --arch=atom --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1 $ANDROID_FLAGS" --extra-ldflags="-L../lib/ $ANDROID_FLAGS" --extra-libs="$ANDROID_LIBS -lz -latomic" --disable-symver --pkg-config=/usr/bin/pkg-config || cat ffbuild/config.log
@@ -823,6 +841,11 @@ EOF
823841
make -j $MAKEJ
824842
make install
825843
cd ..
844+
cd ../kvazaar-$KVAZAAR_VERSION
845+
./autogen.sh
846+
CFLAGS="$ANDROID_FLAGS" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic --host=x86_64-linux
847+
make -j $MAKEJ V=0
848+
make install
826849
cd ../ffmpeg-$FFMPEG_VERSION
827850
sedinplace 's/unsigned long int/unsigned int/g' libavdevice/v4l2.c
828851
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' ./configure --prefix=.. $DISABLE $ENABLE --enable-jni --enable-mediacodec --enable-pthreads --enable-cross-compile --cross-prefix="$ANDROID_PREFIX-" --ar="$AR" --ranlib="$RANLIB" --cc="$CC" --cxx="$CXX" --strip="$STRIP" --sysroot="$ANDROID_ROOT" --target-os=android --arch=atom --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1 $ANDROID_FLAGS" --extra-ldflags="-L../lib/ $ANDROID_FLAGS" --extra-libs="$ANDROID_LIBS -lz -latomic" --disable-symver --pkg-config=/usr/bin/pkg-config || cat ffbuild/config.log
@@ -979,6 +1002,11 @@ EOF
9791002
make -j $MAKEJ
9801003
make install
9811004
cd ..
1005+
cd ../kvazaar-$KVAZAAR_VERSION
1006+
./autogen.sh
1007+
CC="gcc -m32" CFLAGS="-m32 -fPIC" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic --host=i686-linux
1008+
make -j $MAKEJ V=0
1009+
make install
9821010
cd ../ffmpeg-$FFMPEG_VERSION
9831011
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-libdrm --enable-cuda --enable-cuvid --enable-nvenc --enable-pthreads --enable-libxcb --enable-libpulse --cc="gcc -m32 -D__ILP32__" --cxx="g++ -m32 -D__ILP32__" --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -lpthread -ldl -lz -lm $LIBS" || cat ffbuild/config.log
9841012
make -j $MAKEJ
@@ -1135,6 +1163,11 @@ EOF
11351163
make -j $MAKEJ
11361164
make install
11371165
cd ..
1166+
cd ../kvazaar-$KVAZAAR_VERSION
1167+
./autogen.sh
1168+
CC="gcc -m64" CFLAGS="-m64 -fPIC" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic --host=x86_64-linux
1169+
make -j $MAKEJ V=0
1170+
make install
11381171
cd ../ffmpeg-$FFMPEG_VERSION
11391172
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-libdrm --enable-cuda --enable-cuvid --enable-nvenc --enable-pthreads --enable-libxcb --enable-libpulse --cc="gcc -m64" --cxx="g++ -m64" --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -lpthread -ldl -lz -lm $LIBS" || cat ffbuild/config.log
11401173
make -j $MAKEJ
@@ -1371,6 +1404,11 @@ EOF
13711404
make -j $MAKEJ
13721405
make install
13731406
cd ..
1407+
cd ../kvazaar-$KVAZAAR_VERSION
1408+
./autogen.sh
1409+
CFLAGS="$CFLAGS -fPIC" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic --host=arm-linux-gnueabihf
1410+
make -j $MAKEJ V=0
1411+
make install
13741412
cd ../ffmpeg-$FFMPEG_VERSION
13751413
if [ $CROSSCOMPILE -eq 1 ]
13761414
then
@@ -1552,6 +1590,11 @@ EOF
15521590
make -j $MAKEJ
15531591
make install
15541592
cd ..
1593+
cd ../kvazaar-$KVAZAAR_VERSION
1594+
./autogen.sh
1595+
CFLAGS="$CFLAGS -fPIC" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic --host=aarch64-linux-gnu
1596+
make -j $MAKEJ V=0
1597+
make install
15551598
cd ../ffmpeg-$FFMPEG_VERSION
15561599
if [[ ! -d $USERLAND_PATH ]]; then
15571600
USERLAND_PATH="$(which aarch64-linux-gnu-gcc | grep -o '.*/tools/')../userland"
@@ -1800,6 +1843,15 @@ EOF
18001843
make -j $MAKEJ
18011844
make install
18021845
cd ..
1846+
cd ../kvazaar-$KVAZAAR_VERSION
1847+
./autogen.sh
1848+
if [[ "$MACHINE_TYPE" =~ ppc64 ]]; then
1849+
CC="gcc -m64" CFLAGS="-m64 -fPIC" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic
1850+
else
1851+
CFLAGS="-m64 -fPIC" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic --host=powerpc64le-linux-gnu
1852+
fi
1853+
make -j $MAKEJ V=0
1854+
make install
18031855
cd ../ffmpeg-$FFMPEG_VERSION
18041856
if [[ "$MACHINE_TYPE" =~ ppc64 ]]; then
18051857
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-cuda --enable-cuvid --enable-nvenc --enable-pthreads --enable-libxcb --enable-libpulse --cc="gcc -m64" --cxx="g++ -m64" --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl -lz -lm" --disable-altivec || cat ffbuild/config.log
@@ -1968,6 +2020,11 @@ EOF
19682020
make -j $MAKEJ
19692021
make install
19702022
cd ..
2023+
cd ../kvazaar-$KVAZAAR_VERSION
2024+
./autogen.sh
2025+
CC="clang -arch arm64" CFLAGS="-arch arm64 -fPIC" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic --host=aarch64-apple-darwin
2026+
make -j $MAKEJ V=0
2027+
make install
19712028
cd ../ffmpeg-$FFMPEG_VERSION
19722029
patch -Np1 < ../../../ffmpeg-macosx.patch
19732030
LDEXEFLAGS='-Wl,-rpath,@loader_path/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-pthreads --enable-indev=avfoundation --disable-libxcb --cc="clang -arch arm64" --cxx="clang++ -arch arm64" --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl -lz -lm" --enable-cross-compile --arch=arm64 --target-os=darwin || cat ffbuild/config.log
@@ -2108,6 +2165,11 @@ EOF
21082165
make -j $MAKEJ
21092166
make install
21102167
cd ..
2168+
cd ../kvazaar-$KVAZAAR_VERSION
2169+
./autogen.sh
2170+
CC="clang" CFLAGS="-fPIC" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --with-pic
2171+
make -j $MAKEJ V=0
2172+
make install
21112173
cd ../ffmpeg-$FFMPEG_VERSION
21122174
patch -Np1 < ../../../ffmpeg-macosx.patch
21132175
LDEXEFLAGS='-Wl,-rpath,@loader_path/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-pthreads --enable-indev=avfoundation --disable-libxcb --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl -lz -lm" || cat ffbuild/config.log
@@ -2262,8 +2324,13 @@ EOF
22622324
make -j $MAKEJ
22632325
make install
22642326
cd ..
2327+
cd ../kvazaar-$KVAZAAR_VERSION
2328+
./autogen.sh
2329+
CC="gcc -m32" CFLAGS="-m32 -DKVZ_STATIC_LIB" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --host=i686-w64-mingw32
2330+
make -j $MAKEJ V=0
2331+
make install
22652332
cd ../ffmpeg-$FFMPEG_VERSION
2266-
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc="gcc -m32" --cxx="g++ -m32" --extra-cflags="-DLIBXML_STATIC -I../include/ -I../include/libxml2 -I../include/mfx/ -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc_eh -lWs2_32 -lcrypt32 -lpthread -lz -lm -Wl,-Bdynamic -lole32 -luuid" || cat ffbuild/config.log
2333+
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc="gcc -m32" --cxx="g++ -m32" --extra-cflags="-DLIBXML_STATIC -DKVZ_STATIC_LIB -I../include/ -I../include/libxml2 -I../include/mfx/ -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc_eh -lWs2_32 -lcrypt32 -lpthread -lz -lm -Wl,-Bdynamic -lole32 -luuid" || cat ffbuild/config.log
22672334
make -j $MAKEJ
22682335
make install
22692336
;;
@@ -2415,8 +2482,13 @@ EOF
24152482
make -j $MAKEJ
24162483
make install
24172484
cd ..
2485+
cd ../kvazaar-$KVAZAAR_VERSION
2486+
./autogen.sh
2487+
CC="gcc -m64" CFLAGS="-m64 -DKVZ_STATIC_LIB" ./configure --prefix=$INSTALL_PATH --disable-shared --enable-static --host=x86_64-w64-mingw32
2488+
make -j $MAKEJ V=0
2489+
make install
24182490
cd ../ffmpeg-$FFMPEG_VERSION
2419-
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc="gcc -m64" --cxx="g++ -m64" --extra-cflags="-DLIBXML_STATIC -I../include/ -I../include/libxml2 -I../include/mfx/ -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc_eh -lWs2_32 -lcrypt32 -lpthread -lz -lm -Wl,-Bdynamic -lole32 -luuid" || cat ffbuild/config.log
2491+
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc="gcc -m64" --cxx="g++ -m64" --extra-cflags="-DLIBXML_STATIC -DKVZ_STATIC_LIB -I../include/ -I../include/libxml2 -I../include/mfx/ -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc_eh -lWs2_32 -lcrypt32 -lpthread -lz -lm -Wl,-Bdynamic -lole32 -luuid" || cat ffbuild/config.log
24202492
make -j $MAKEJ
24212493
make install
24222494
;;

0 commit comments

Comments
 (0)