diff --git a/.gitignore b/.gitignore index e6f34ce..cb94f99 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ benchmark graphs rkmpp rkrga +x264 +x265 +vpx diff --git a/scripts/build.sh b/scripts/build.sh index f94be2a..0320373 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -10,6 +10,9 @@ DAV1D_DIR="$BASE_DIR/dav1d" OPUS_DIR="$BASE_DIR/opus" RKMPP_DIR="$BASE_DIR/rkmpp" RKRGA_DIR="$BASE_DIR/rkrga" +X264_DIR="$BASE_DIR/x264" +X265_DIR="$BASE_DIR/x265" +VPX_DIR="$BASE_DIR/vpx" # clone git clone --depth 1 https://gitlab.com/AOMediaCodec/SVT-AV1.git "$SVT_DIR" @@ -19,6 +22,9 @@ git clone --depth 1 https://github.com/Netflix/vmaf "$VMAF_DIR" git clone --depth 1 https://code.videolan.org/videolan/dav1d.git "$DAV1D_DIR" git clone --depth 1 https://github.com/xiph/opus.git "$OPUS_DIR" git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git "$FFMPEG_DIR" +git clone --depth 1 https://code.videolan.org/videolan/x264.git "$X264_DIR" +git clone --depth 1 https://github.com/videolan/x265.git "$X265_DIR" +git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git "$VPX_DIR" export ARCH=$(uname -m) export COMP_FLAGS="" @@ -31,6 +37,9 @@ then fi echo "COMP_FLAGS: $COMP_FLAGS" +# set optimization level +OPT_LVL="3" + # for ccache export PATH="/usr/lib/ccache/:$PATH" @@ -60,8 +69,8 @@ then cmake .. -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=ON \ -DBUILD_TEST=OFF \ - -DCMAKE_C_FLAGS="-O3 $COMP_FLAGS" \ - -DCMAKE_CXX_FLAGS="-O3 $COMP_FLAGS" || exit + -DCMAKE_C_FLAGS="-O${OPT_LVL} $COMP_FLAGS" \ + -DCMAKE_CXX_FLAGS="-O${OPT_LVL} $COMP_FLAGS" || exit make -j "$(nproc)" || exit sudo make install || exit @@ -87,8 +96,8 @@ mkdir build_svt.user cd build_svt.user || exit make clean cmake .. -DCMAKE_BUILD_TYPE=Release -DSVT_AV1_LTO=ON \ - -DCMAKE_C_FLAGS="-O3 $COMP_FLAGS" \ - -DCMAKE_CXX_FLAGS="-O3 $COMP_FLAGS" || exit + -DCMAKE_C_FLAGS="-O${OPT_LVL} $COMP_FLAGS" \ + -DCMAKE_CXX_FLAGS="-O${OPT_LVL} $COMP_FLAGS" || exit make -j "$(nproc)" || exit sudo make install || exit @@ -117,8 +126,8 @@ cd build_aom.user || exit make clean cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON \ -DENABLE_TESTS=OFF \ - -DCMAKE_C_FLAGS="-flto -O3 $COMP_FLAGS" \ - -DCMAKE_CXX_FLAGS="-flto -O3 $COMP_FLAGS" || exit + -DCMAKE_C_FLAGS="-flto -O${OPT_LVL} $COMP_FLAGS" \ + -DCMAKE_CXX_FLAGS="-flto -O${OPT_LVL} $COMP_FLAGS" || exit make -j "$(nproc)" || exit sudo make install || exit @@ -133,7 +142,7 @@ mkdir build.user cd build.user || exit pip install meson meson setup ../ build.user --buildtype release -Denable_float=true -Db_lto=true \ - --optimization=3 -Dc_args="$COMP_FLAGS" -Dcpp_args="$COMP_FLAGS" || exit + --optimization="$OPT_LVL" -Dc_args="$COMP_FLAGS" -Dcpp_args="$COMP_FLAGS" || exit ninja -vC build.user || exit sudo ninja -vC build.user install || exit @@ -154,12 +163,49 @@ cd "$OPUS_DIR" || exit git stash && git stash drop git pull ./autogen.sh || exit -export CFLAGS="-O3 -flto $COMP_FLAGS" +export CFLAGS="-O${OPT_LVL} -flto $COMP_FLAGS" ./configure || exit make -j "$(nproc)" || exit sudo make install || exit unset CFLAGS +# build x264 +cd "$X264_DIR" || exit +git stash && git stash drop +git pull +./configure --enable-static --enable-pic \ + --enable-shared --enable-lto \ + --extra-cflags="-O${OPT_LVL} $COMP_FLAGS" || exit +make -j "$(nproc)" || exit +sudo make install || exit + +# build x265 +cd "$X265_DIR" || exit +git stash && git stash drop +git pull +rm -rf build.user +mkdir build.user +cd build.user || exit +cmake ../source -DCMAKE_BUILD_TYPE=Release -DNATIVE_BUILD=ON \ + -DCMAKE_C_FLAGS="-flto -O${OPT_LVL} $COMP_FLAGS" \ + -DCMAKE_CXX_FLAGS="-flto -O${OPT_LVL} $COMP_FLAGS" || exit +make -j "$(nproc)" || exit +sudo make install || exit + +# build vpx +cd "$VPX_DIR" || exit +git stash && git stash drop +git pull +./configure --enable-pic --as=yasm \ + --extra-cflags="-O${OPT_LVL} $COMP_FLAGS" \ + --extra-cxxflags="-O${OPT_LVL} $COMP_FLAGS" \ + --disable-examples --disable-docs \ + --enable-better-hw-compatibility \ + --enable-vp9-highbitdepth \ + --enable-shared +make -j "$(nproc)" || exit +sudo make install || exit + # ldconfig for shared libs sudo mkdir /etc/ld.so.conf.d/ echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/ffmpeg.conf || exit 1 @@ -174,10 +220,12 @@ make clean ./configure --enable-libsvtav1 --enable-librav1e \ --enable-libaom --enable-libvmaf \ --enable-libdav1d --enable-libopus \ + --enable-gpl --enable-libx264 \ + --enable-libx265 --enable-libvpx \ --arch="$ARCH" --cpu=native \ --enable-lto $FFMPEG_ROCKCHIP \ - --extra-cflags="-O3 $COMP_FLAGS" \ - --extra-cxxflags="-O3 $COMP_FLAGS" \ + --extra-cflags="-O${OPT_LVL} $COMP_FLAGS" \ + --extra-cxxflags="-O${OPT_LVL} $COMP_FLAGS" \ --disable-doc --disable-htmlpages \ --disable-podpages --disable-txtpages || exit make -j "$(nproc)" || exit diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index d58fefa..62a102d 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -7,7 +7,7 @@ sudo "$PKG_MNG" upgrade -qy sudo "$PKG_MNG" install autoconf automake build-essential cmake git-core g++-12 \ libass-dev libfreetype6-dev libsdl2-dev libtool libva-dev libvdpau-dev gcc-12 \ - libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config bc \ + libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config bc libnuma-dev \ texinfo wget zlib1g-dev nasm yasm libssl-dev time python3 meson ninja-build gobjc++ \ doxygen xxd jq lshw gnuplot python3-pip curl clang valgrind ccache gawk mawk -y || exit 1