Installation
The Kunpeng Image Library optimizes image encoding performance based on open source libwebp and libavif. You can use this library after applying optimization patches and compiling and installing the library.
- Prepare the basic environment.
1yum install make zlib-devel cmake gcc gcc-c++ zip unzip which wget expect man pcre-devel autoconf automake libtool nasm bzip2-devel libtool-ltdl-devel gettext-devel texinfo git vim zip perl-IPC-Cmd gdb file -y
- Save the software packages libwebp-master.zip, libavif-master.zip, libwebp-1.2.1.tar.gz, libjpeg-turbo-1.5.2.tar.gz, giflib-5.1.4.tar.gz, zlib-1.2.11.tar.gz, libpng-1.6.38.tar.gz, GraphicsMagick-1.3.38.tar.gz, aom, SVT-AV1-v0.8.7.tar.gz, libyuv, and libavif-0.9.3.tar.gz obtained in Software Packages to the /home/software directory and decompress the packages.
- Decompress libwebp-master.zip to obtain huawei_libwebp-1.2.1_opt.patch that contains code for optimizing libwebp. Decompress libavif-master.zip to obtain huawei_libavif-0.9.3_opt.patch and huawei_aom-v3.2.0_opt.patch that contain code for optimizing libavif.
- For small images, such as 50x50 images, applying the preceding patches may cause performance deterioration. In this case, you can choose not to apply these patches.
- Copy huawei_libwebp-1.2.1_opt.patch to the libwebp source code directory and apply the patch.
1 2 3 4 5
cd /home/software/libwebp-1.2.1/ cp /home/software/libwebp-master/huawei_libwebp-1.2.1_opt.patch /home/software/libwebp-1.2.1/ git config --global --add safe.directory /home/software/libwebp-1.2.1 git init && git add . && git commit -m "init" git apply huawei_libwebp-1.2.1_opt.patch
- Copy huawei_aom-v3.2.0_opt.patch to the AOM source code directory and apply the patch.
1 2 3
cd /home/software/aom/ cp /home/software/libavif-master/huawei_aom-v3.2.0_opt.patch /home/software/aom/ git apply huawei_aom-v3.2.0_opt.patch
- Copy huawei_libavif-0.9.3_opt.patch to the libavif source code directory and apply the patch.
1 2 3 4 5
cd /home/software/libavif-0.9.3 cp /home/software/libavif-master/huawei_libavif-0.9.3_opt.patch /home/software/libavif-0.9.3 git config --global --add safe.directory /home/software/libavif-0.9.3 git init && git add . && git commit -m "init" git apply huawei_libavif-0.9.3_opt.patch
- Switch to the /home/software directory and save the following code to the build.sh script:
#!/bin/bash # Define the installation location. JDIMG_PATH="/opt/jdimg" echo "$JDIMG_PATH/lib" > /etc/ld.so.conf.d/jdimg.conf echo "$JDIMG_PATH/lib64" > /etc/ld.so.conf.d/jdimg_lib64.conf export PKG_CONFIG_PATH="$JDIMG_PATH/lib/pkgconfig:$PKG_CONFIG_PATH" pushd libwebp-1.2.1/ && rm -rf build && mkdir build && pushd build && \ cmake -DCMAKE_INSTALL_PREFIX:PATH=$JDIMG_PATH -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_FULL_LIBDIR=/lib -DBUILD_SHARED_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=OFF -DCMAKE_C_FLAGS="-ffp-contract=off" .. && \ make -j8 && make install && popd && popd && \ pushd libjpeg-turbo-1.5.2 && chmod +x ./configure && rm -rf build && mkdir build && pushd build && \ ../configure --prefix=$JDIMG_PATH CFLAGS="-O3 -ffp-contract=off" CPPFLAGS="-Wall -ffp-contract=off" && \ make -j8 && make install && popd && popd && \ pushd giflib-5.1.4/ && chmod +x ./configure && rm -rf build && mkdir build && pushd build && \ ../configure --prefix=$JDIMG_PATH CPPFLAGS="-Wall -ffp-contract=off" && \ make -j8 && make install && popd && popd && \ pushd zlib-1.2.11 && chmod +x ./configure && rm -rf build && mkdir build && pushd build && \ ../configure --prefix=$JDIMG_PATH && make -j8 && make install && popd && popd && \ pushd libpng-1.6.38 && chmod +x ./configure && rm -rf build && mkdir build && pushd build && \ ../configure --prefix=$JDIMG_PATH LDFLAGS="-L$JDIMG_PATH/lib/ -lz" CFLAGS="-g -O2 -ffp-contract=off -I$JDIMG_PATH/include" CPPFLAGS="-ffp-contract=off" && \ make -j8 && make install && popd && popd && \ pushd GraphicsMagick-1.3.38 && chmod +x ./configure && rm -rf build && mkdir build && pushd build && \ ../configure --prefix=$JDIMG_PATH --disable-openmp --enable-shared --without-tiff --without-x LDFLAGS="-L$JDIMG_PATH/lib" CPPFLAGS="-I$JDIMG_PATH/include -ffp-contract=off " CFLAGS="-g -Ofast -Wall -ffp-contract=off " && make -j8 && make install && popd && popd && \ pushd aom && rm -rf aom_build && mkdir aom_build && pushd aom_build && cmake -DCMAKE_INSTALL_PREFIX:PATH=$JDIMG_PATH -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_FULL_LIBDIR=/lib -DBUILD_SHARED_LIBS=1 -DENABLE_TESTS=ON -DENABLE_EXAMPLES=ON -DENABLE_DOCS=OFF -DCMAKE_C_FLAGS="-Ofast -ffp-contract=off -fPIC" .. && make -j8 && make install && popd && popd && \ pushd SVT-AV1-v0.8.7/Build/linux && chmod +x ./build.sh && ./build.sh release shared install prefix=$JDIMG_PATH cc=gcc cxx=g++ && popd && \ pushd libyuv && rm -rf build && mkdir build && pushd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=$JDIMG_PATH -DCMAKE_CXX_STANDARD=11 -DBUILD_SHARED_LIBS=1 .. && make -j8 && make install && popd && popd && \ mkdir -p $JDIMG_PATH/lib64 && cp $JDIMG_PATH/lib/libaom.so $JDIMG_PATH/lib64/ && pushd libavif-0.9.3 && rm -rf build && mkdir build && pushd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=$JDIMG_PATH -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_FULL_LIBDIR=/lib -DCMAKE_LIBRARY_ARCHITECTURE=ON -DBUILD_SHARED_LIBS=1 -DAVIF_CODEC_AOM=ON -DAVIF_CODEC_DAV1D=OFF -DAVIF_CODEC_LIBGAV1=OFF -DAVIF_CODEC_RAV1E=OFF -DAVIF_CODEC_SVT=ON -DAVIF_BUILD_EXAMPLES=OFF -DCMAKE_VERBOSE_MAKEFILE=OFF -DAVIF_BUILD_APPS=ON -DDAV1D_INCLUDE_DIR=$JDIMG_PATH/include -DCMAKE_C_FLAGS=" -fopenmp" .. && make -j8 && make install && popd && popd
- Run the script and wait until the execution is complete.
1sh build.sh - Check whether the installation is successful.
1 2 3
export LD_LIBRARY_PATH=/opt/jdimg/lib/:/opt/jdimg/lib64/:$LD_LIBRARY_PATH /opt/jdimg/bin/avifenc --version /opt/jdimg/bin/webpmux -version
If the AVIF and WebP version numbers are displayed in the command output, the installation is successful.
Parent topic: Installing and Using libwebp and libavif