x265
Before compiling and installing x265, obtain the x265-dev-sve.zip software package. The installation directory, source code directory, and compilation directory provided in the following procedure are all examples. Replace them with actual ones.
- Obtain the x265-dev-sve.zip software package (see Table 2), upload it to the/home/sourcecode directory on the server, decompress it, and grant the read, write, and execute permissions to the directory owner.
mkdir /home/sourcecode && chmod -R 700 /home/sourcecode && cd /home/sourcecode unzip x265-dev-sve.zip
- Create an installation directory.
mkdir -p /home/x265/install
- Create a source code directory.
mkdir -p /home/x265/src
- Copy the source code to the source code directory.
cp -r /home/sourcecode/x265-dev-sve/* /home/x265/src
- Create a compilation directory and go to the directory.
mkdir -p /home/x265/build && cd /home/x265/build
- Set compilation parameters. Table 1 describes the parameters.
cmake -S /home/x265/src/source/ -DCMAKE_BUILD_TYPE=Release -DENABLE_PIC=ON -DENABLE_ASSEMBLY=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_C_FLAGS=" $CMAKE_C_FLAGS -O3 -msve-vector-bits=256 -march=armv8.2-a+sve+f64mm -fPIC -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -ftrapv " -DCMAKE_CXX_FLAGS=" $CMAKE_CXX_FLAGS -O3 -msve-vector-bits=256 -march=armv8.2-a+sve+f64mm -fPIC -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -ftrapv " -DHIGH_BIT_DEPTH=off -DMAIN12=off -DENABLE_TESTS=on -DENABLE_SHARED=on -DENABLE_LIBNUMA=off -DCMAKE_INSTALL_PREFIX=/home/x265/install -DOPTIONAL_SVE_OPTIMIZE=on -DUSE_OPTIMAL_OPTIMIZE=on -DCMAKE_EXE_LINKER_FLAGS=" -pie -Wl,-z,relro,-z,now,-s " -DCMAKE_SHARED_LINKER_FLAGS=" -Wl,-z,relro,-z,now,-s "
Table 1 Compilation parameters Parameter
Description
-S /home/x265/src/source
Specifies the source code directory, that is, the directory where the project code to be built is located. Replace the example directory /home/x265/src/source with the actual one.
-DCMAKE_BUILD_TYPE=Release
Sets the build type to Release to optimize the compilation.
-DENABLE_PIC=ON
Generates position independent code to facilitate dynamic linking.
-DENABLE_ASSEMBLY=ON
Enables assembly optimization to use assembly code in performance optimization.
-DCMAKE_VERBOSE_MAKEFILE=ON
Outputs a detailed Makefile.
-DCMAKE_C_FLAGS=" $CMAKE_C_FLAGS -O3 -msve-vector-bits=256 -march=armv8.2-a+sve+f64mm -fPIC -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -ftrapv "
Sets the C language compiler parameters.
- -O3: enables optimization of the highest level.
- -msve-vector-bits=256: indicates that the Arm SVE bit width is 256 bits.
- -march=armv8.2-a+sve+f64mm: specifies the Arm architecture version, and enable SVE and floating-point 64-bit mathematical operations.
Compiler security options:
- -fPIC: generates position-independent code.
- -fPIE: generates position-independent executable files.
- -fstack-protector-strong: enables protection against stack overflow.
- -D_FORTIFY_SOURCE=2: enables buffer overflow check at compile time and runtime.
- -ftrapv: used for runtime error check.
-DCMAKE_CXX_FLAGS=" $CMAKE_CXX_FLAGS -O3 -msve-vector-bits=256 -march=armv8.2-a+sve+f64mm -fPIC -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -ftrapv "
Sets the C++ language compiler parameters. The parameter description is similar to that of -DCMAKE_C_FLAGS.
-DHIGH_BIT_DEPTH=off
Disables the higher-bit depth support, that is, disables the 10-bit support.
-DMAIN12=off
Disables the Main12 support, that is, disables the 12-bit support.
-DENABLE_TESTS=on
Enables test building to build test cases.
-DENABLE_SHARED=on
Enables shared library building.
-DENABLE_LIBNUMA=off
Disables the NUMA support library.
-DCMAKE_INSTALL_PREFIX=/home/x265/install
Specifies the installation directory, that is, the directory where the files generated by make install are stored.
Replace the example directory /home/x265/install/ with the actual one.
-DOPTIONAL_SVE_OPTIMIZE=on
Enables the SVE option. It will disable some operators that do not perform well on the Kunpeng 920 7280Z processor.
-DUSE_OPTIMAL_OPTIMIZE=on
Selects the optimal vectorization optimization. It will select the implementation with the optimal performance on the Kunpeng 920 7280Z processor for some operators.
-DCMAKE_EXE_LINKER_FLAGS=" -pie -Wl,-z,relro,-z,now,-s "
(Compiler security option) Enables memory security options to prevent memory attacks such as code injection.
-DCMAKE_SHARED_LINKER_FLAGS=" -Wl,-z,relro,-z,now,-s "
(Compiler security option) Enables memory security options to prevent memory attacks such as code injection.
Compiler security options are added to the preceding compilation parameters, which affect the encoding performance. In performance-preferred scenarios, you can remove compiler security options to achieve better performance.
- Perform the compilation using 256 parallel tasks (threads). You can determine the number based on the actual number of CPU cores.
make -j256
- Install the generated binary and library files to the specified installation path.
make install