Add x265 and all its madness

This commit is contained in:
BtbN 2020-09-03 22:49:43 +02:00
parent 9ee8d5d019
commit 1b853bc960
11 changed files with 128 additions and 25 deletions

View file

@ -19,14 +19,16 @@ source "variants/${VARIANT}.sh"
source "variants/${TARGET}-${VARIANT}.sh" source "variants/${TARGET}-${VARIANT}.sh"
for script in scripts.d/*.sh; do for script in scripts.d/*.sh; do
CONFIGURE+=" $(get_output $script configure)" FF_CONFIGURE+=" $(get_output $script configure)"
CFLAGS+=" $(get_output $script cflags)" FF_CFLAGS+=" $(get_output $script cflags)"
LDFLAGS+=" $(get_output $script ldflags)" FF_CXXFLAGS+=" $(get_output $script cxxflags)"
FF_LDFLAGS+=" $(get_output $script ldflags)"
done done
CONFIGURE="$(xargs <<< "$CONFIGURE")" FF_CONFIGURE="$(xargs <<< "$FF_CONFIGURE")"
CFLAGS="$(xargs <<< "$CFLAGS")" FF_CFLAGS="$(xargs <<< "$FF_CFLAGS")"
LDFLAGS="$(xargs <<< "$LDFLAGS")" FF_CXXFLAGS="$(xargs <<< "$FF_CXXFLAGS")"
FF_LDFLAGS="$(xargs <<< "$FF_LDFLAGS")"
rm -rf ffbuild rm -rf ffbuild
mkdir ffbuild mkdir ffbuild
@ -40,7 +42,7 @@ docker run --rm -i -u "$(id -u):$(id -g)" -v $PWD/ffbuild:/ffbuild "$IMAGE" bash
cd ffmpeg cd ffmpeg
git checkout $GIT_BRANCH git checkout $GIT_BRANCH
./configure --prefix=/ffbuild/prefix --pkg-config-flags="--static" \$FFBUILD_TARGET_FLAGS $CONFIGURE --extra-cflags="$CFLAGS" --extra-ldflags="$LDFLAGS" ./configure --prefix=/ffbuild/prefix --pkg-config-flags="--static" \$FFBUILD_TARGET_FLAGS $FF_CONFIGURE --extra-cflags="$FF_CFLAGS" --extra-cxxflags="$FF_CXXFLAGS" --extra-ldflags="$FF_LDFLAGS"
make -j\$(nproc) make -j\$(nproc)
make install make install
EOF EOF

View file

@ -12,7 +12,6 @@ to_df() {
to_df "FROM $REPO:base-$TARGET" to_df "FROM $REPO:base-$TARGET"
to_df "ENV TARGET=$TARGET VARIANT=$VARIANT REPO=$REPO" to_df "ENV TARGET=$TARGET VARIANT=$VARIANT REPO=$REPO"
to_df "ENV FFBUILD_PREFIX=/opt/ffbuild PKG_CONFIG_LIBDIR=/opt/ffbuild/lib/pkgconfig"
for script in scripts.d/*.sh; do for script in scripts.d/*.sh; do
( (

View file

@ -4,8 +4,19 @@ ENV DEBIAN_FRONTEND noninteractive
RUN \ RUN \
apt-get -y install mingw-w64 && \ apt-get -y install mingw-w64 && \
apt-get -y clean apt-get -y clean && \
rm /usr/lib/gcc/*-w64-mingw32/*/libstdc++*.dll* && \
rm /usr/lib/gcc/*-w64-mingw32/*/libgcc_s* && \
mkdir /opt/ffbuild
ENV FFBUILD_TARGET_FLAGS "--pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=win32" ADD toolchain.cmake /toolchain.cmake
ENV FFBUILD_TOOLCHAIN x86_64-w64-mingw32
ENV FFBUILD_CROSS_PREFIX x86_64-w64-mingw32- ENV FFBUILD_TARGET_FLAGS="--pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=win32" \
FFBUILD_TOOLCHAIN=x86_64-w64-mingw32 \
FFBUILD_CROSS_PREFIX=x86_64-w64-mingw32- \
FFBUILD_PREFIX=/opt/ffbuild \
FFBUILD_CMAKE_TOOLCHAIN=/toolchain.cmake \
PKG_CONFIG_LIBDIR=/opt/ffbuild/lib/pkgconfig \
CFLAGS="-static-libgcc -static-libstdc++" \
CXXFLAGS="-static-libgcc -static-libstdc++" \
LDFLAGS="-static-libgcc -static-libstdc++"

View file

@ -0,0 +1,12 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
set(CMAKE_RANLIB x86_64-w64-mingw32-ranlib)
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 /opt/ffbuild)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View file

@ -5,5 +5,5 @@ ENV DEBIAN_FRONTEND noninteractive
RUN \ RUN \
apt-get -y update && \ apt-get -y update && \
apt-get -y dist-upgrade && \ apt-get -y dist-upgrade && \
apt-get -y install build-essential yasm nasm pkg-config git curl wget cmake unzip subversion autoconf automake libtool clang texinfo texi2html && \ apt-get -y install build-essential yasm nasm pkg-config git curl wget cmake unzip subversion autoconf automake libtool cmake clang texinfo texi2html && \
apt-get -y clean apt-get -y clean

67
scripts.d/50-x265.sh Executable file
View file

@ -0,0 +1,67 @@
#!/bin/bash
X265_REPO="https://github.com/videolan/x265.git"
X265_COMMIT="ac186359c3706f63579b2291cd2dc84f6e17a336"
ffbuild_enabled() {
[[ $VARIANT == gpl* ]] || return -1
return 0
}
ffbuild_dockerstage() {
to_df "ADD $SELF /root/x264.sh"
to_df "RUN bash -c 'source /root/x264.sh && ffbuild_dockerbuild && rm /root/x264.sh'"
}
ffbuild_dockerbuild() {
git clone "$X265_REPO" x265 || return -1
cd x265
git checkout "$X265_COMMIT" || return -1
mkdir 8bit 10bit 12bit
cd 12bit
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON ../source || return -1
make -j$(nproc) || return -1
cp libx265.a ../8bit/libx265_main12.a
cd ../10bit
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF ../source || return -1
make -j$(nproc) || return -1
cp libx265.a ../8bit/libx265_main10.a
cd ../8bit
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DENABLE_SHARED=OFF -DENABLE_CLI=OFF ../source || return -1
make -j$(nproc) || return -1
mv libx265.a libx265_main.a
${FFBUILD_CROSS_PREFIX}ar -M <<EOF
CREATE libx265.a
ADDLIB libx265_main.a
ADDLIB libx265_main10.a
ADDLIB libx265_main12.a
SAVE
END
EOF
make install || return -1
cd ../..
rm -rf x265
}
ffbuild_configure() {
echo --enable-libx265
}
ffbuild_unconfigure() {
echo --disable-libx265
}
ffbuild_cflags() {
return 0
}
ffbuild_ldflags() {
return 0
}

View file

@ -26,6 +26,14 @@ ffbuild_uncflags() {
return 0 return 0
} }
ffbuild_cxxflags() {
return 0
}
ffbuild_uncxxflags() {
return 0
}
ffbuild_ldflags() { ffbuild_ldflags() {
return 0 return 0
} }

View file

@ -1,4 +1,5 @@
CONFIGURE="--enable-gpl --enable-version3" FF_CONFIGURE="--enable-gpl --enable-version3"
CFLAGS="" FF_CFLAGS="-static-libgcc -static-libstdc++"
LDFLAGS="" FF_CXXFLAGS="-static-libgcc -static-libstdc++"
FF_LDFLAGS="-static-libgcc -static-libstdc++"
GIT_BRANCH="release/4.2" GIT_BRANCH="release/4.2"

View file

@ -1,4 +1,5 @@
CONFIGURE="--enable-gpl --enable-version3" FF_CONFIGURE="--enable-gpl --enable-version3"
CFLAGS="" FF_CFLAGS="-static-libgcc -static-libstdc++"
LDFLAGS="" FF_CXXFLAGS="-static-libgcc -static-libstdc++"
FF_LDFLAGS="-static-libgcc -static-libstdc++"
GIT_BRANCH="master" GIT_BRANCH="master"

View file

@ -1,4 +1,5 @@
CONFIGURE="--enable-version3" FF_CONFIGURE="--enable-version3"
CFLAGS="" FF_CFLAGS="-static-libgcc -static-libstdc++"
LDFLAGS="" FF_CXXFLAGS="-static-libgcc -static-libstdc++"
FF_LDFLAGS="-static-libgcc -static-libstdc++"
GIT_BRANCH="release/4.2" GIT_BRANCH="release/4.2"

View file

@ -1,4 +1,5 @@
CONFIGURE="--enable-version3" FF_CONFIGURE="--enable-version3"
CFLAGS="" FF_CFLAGS="-static-libgcc -static-libstdc++"
LDFLAGS="" FF_CXXFLAGS="-static-libgcc -static-libstdc++"
FF_LDFLAGS="-static-libgcc -static-libstdc++"
GIT_BRANCH="master" GIT_BRANCH="master"