Merge "Builds: Modular cmake scripts added"
This commit is contained in:
commit
6ff3e24351
15 changed files with 518 additions and 252 deletions
209
CMakeLists.txt
209
CMakeLists.txt
|
|
@ -1,4 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.9.1)
|
||||||
|
project(libavc C CXX)
|
||||||
|
enable_language(ASM)
|
||||||
|
|
||||||
set(AVC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
|
set(AVC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
set(AVC_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
set(AVC_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
|
@ -14,199 +16,30 @@ if("${AVC_ROOT}" STREQUAL "${AVC_CONFIG_DIR}")
|
||||||
"And re-run CMake from the build directory.")
|
"And re-run CMake from the build directory.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
set(CMAKE_STATIC_LIBRARY_PREFIX "")
|
set(CMAKE_STATIC_LIBRARY_PREFIX "")
|
||||||
|
|
||||||
if(SANITIZE)
|
if(${CMAKE_CROSSCOMPILING})
|
||||||
string(TOLOWER ${SANITIZE} SANITIZE)
|
set(THREADS_PTHREAD_ARG
|
||||||
|
"2"
|
||||||
set(CMAKE_SANITIZER_C_FLAGS "-fno-omit-frame-pointer -fsanitize=${SANITIZE}")
|
CACHE STRING
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SANITIZER_C_FLAGS}")
|
"Refer https://gitlab.kitware.com/cmake/cmake/-/issues/16920" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND LIBAVCDEC_SRCS
|
include("${AVC_ROOT}/cmake/utils.cmake")
|
||||||
"${AVC_ROOT}/common/ih264_buf_mgr.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_disp_mgr.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_inter_pred_filters.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_luma_intra_pred_filters.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_chroma_intra_pred_filters.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_padding.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_mem_fns.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_deblk_edge_filters.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_iquant_itrans_recon.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_ihadamard_scaling.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_weighted_pred.c"
|
|
||||||
"${AVC_ROOT}/common/ithread.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_cabac.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_parse_mb_header.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_parse_cabac.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_process_intra_mb.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_inter_pred.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_parse_bslice.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_parse_pslice.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_parse_islice.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_cabac_init_tables.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_bitstrm.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_compute_bs.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_deblocking.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_parse_headers.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_mb_utils.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_mvpred.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_utils.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_process_bslice.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_process_pslice.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_parse_slice.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_quant_scaling.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_parse_cavlc.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_dpb_mgr.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_nal.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_sei.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_tables.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_vui.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_format_conv.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_thread_parse_decode.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_api.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_thread_compute_bs.c"
|
|
||||||
"${AVC_ROOT}/decoder/ih264d_function_selector_generic.c")
|
|
||||||
|
|
||||||
list(APPEND LIBAVCDEC_X86_SRCS
|
libavc_add_compile_options()
|
||||||
"${AVC_ROOT}/decoder/x86/ih264d_function_selector.c"
|
libavc_add_definitions()
|
||||||
"${AVC_ROOT}/decoder/x86/ih264d_function_selector_sse42.c"
|
libavc_set_link_libraries()
|
||||||
"${AVC_ROOT}/decoder/x86/ih264d_function_selector_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_inter_pred_filters_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_deblk_luma_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_deblk_chroma_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_padding_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_mem_fns_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_dc_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_luma_intra_pred_filters_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_chroma_intra_pred_filters_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_sse42.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_weighted_pred_sse42.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_ihadamard_scaling_sse42.c")
|
|
||||||
|
|
||||||
set(LIBAVCDEC_INCLUDES ${AVC_ROOT}/common ${AVC_ROOT}/decoder)
|
include("${AVC_ROOT}/common/common.cmake")
|
||||||
|
include("${AVC_ROOT}/decoder/libavcdec.cmake")
|
||||||
|
include("${AVC_ROOT}/encoder/libavcenc.cmake")
|
||||||
|
|
||||||
set(LIBAVCDEC_X86_C_FLAGS
|
include("${AVC_ROOT}/test/decoder/avcdec.cmake")
|
||||||
"-DX86 -DDISABLE_AVX2 -msse4.2 -mno-avx -DDEFAULT_ARCH=D_ARCH_X86_SSE42")
|
include("${AVC_ROOT}/test/encoder/avcenc.cmake")
|
||||||
set(LIBAVCDEC_X86_INCLUDES ${AVC_ROOT}/common/x86 ${AVC_ROOT}/decoder/x86)
|
|
||||||
set(LIBAVCDEC_C_FLAGS "${LIBAVCDEC_X86_C_FLAGS}")
|
|
||||||
|
|
||||||
include_directories(${LIBAVCDEC_INCLUDES} ${LIBAVCDEC_X86_INCLUDES})
|
include("${AVC_ROOT}/fuzzer/avc_dec_fuzzer.cmake")
|
||||||
add_library(libavcdec ${LIBAVCDEC_SRCS} ${LIBAVCDEC_X86_SRCS})
|
include("${AVC_ROOT}/fuzzer/avc_enc_fuzzer.cmake")
|
||||||
set_target_properties(libavcdec PROPERTIES COMPILE_FLAGS "${LIBAVCDEC_C_FLAGS}")
|
|
||||||
|
|
||||||
list(APPEND AVCDEC_SRCS "${AVC_ROOT}/test/decoder/main.c")
|
|
||||||
|
|
||||||
add_executable(avcdec ${AVCDEC_SRCS})
|
|
||||||
set_target_properties(avcdec
|
|
||||||
PROPERTIES COMPILE_FLAGS "-DMD5_DISABLE -DPROFILE_ENABLE")
|
|
||||||
target_link_libraries(avcdec libavcdec Threads::Threads)
|
|
||||||
|
|
||||||
list(APPEND LIBAVCENC_SRCS
|
|
||||||
"${AVC_ROOT}/common/ih264_resi_trans_quant.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_iquant_itrans_recon.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_ihadamard_scaling.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_inter_pred_filters.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_luma_intra_pred_filters.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_chroma_intra_pred_filters.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_padding.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_mem_fns.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_deblk_edge_filters.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_deblk_tables.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_cavlc_tables.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_cabac_tables.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_common_tables.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_trans_data.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_buf_mgr.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_dpb_mgr.c"
|
|
||||||
"${AVC_ROOT}/common/ih264_list.c"
|
|
||||||
"${AVC_ROOT}/common/ithread.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_globals.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_intra_modes_eval.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_half_pel.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_mc.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_me.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_rc_mem_interface.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_time_stamp.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_modify_frm_rate.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_rate_control.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_core_coding.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_deblk.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_api.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_process.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_encode.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_utils.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_version.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_bitstream.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_cavlc.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_cabac_init.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_cabac.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_cabac_encode.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_encode_header.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_function_selector_generic.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_fmt_conv.c"
|
|
||||||
"${AVC_ROOT}/encoder/ih264e_sei.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_rate_control_api.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_bit_allocation.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_cbr_buffer_control.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_est_sad.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_fixed_point_error_bits.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_frame_info_collector.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_mb_model_based.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_picture_type.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_rd_model.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_vbr_storage_vbv.c"
|
|
||||||
"${AVC_ROOT}/encoder/irc_vbr_str_prms.c"
|
|
||||||
"${AVC_ROOT}/encoder/ime.c"
|
|
||||||
"${AVC_ROOT}/encoder/ime_distortion_metrics.c")
|
|
||||||
|
|
||||||
list(APPEND LIBAVCENC_X86_SRCS
|
|
||||||
"${AVC_ROOT}/encoder/x86/ih264e_function_selector.c"
|
|
||||||
"${AVC_ROOT}/encoder/x86/ih264e_function_selector_sse42.c"
|
|
||||||
"${AVC_ROOT}/encoder/x86/ih264e_function_selector_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_dc_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_ihadamard_scaling_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_inter_pred_filters_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_mem_fns_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_padding_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_luma_intra_pred_filters_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_chroma_intra_pred_filters_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_deblk_chroma_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_deblk_luma_ssse3.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_sse42.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_ihadamard_scaling_sse42.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_resi_trans_quant_sse42.c"
|
|
||||||
"${AVC_ROOT}/common/x86/ih264_weighted_pred_sse42.c"
|
|
||||||
"${AVC_ROOT}/encoder/x86/ih264e_half_pel_ssse3.c"
|
|
||||||
"${AVC_ROOT}/encoder/x86/ih264e_intra_modes_eval_ssse3.c"
|
|
||||||
"${AVC_ROOT}/encoder/x86/ime_distortion_metrics_sse42.c")
|
|
||||||
|
|
||||||
set(LIBAVCENC_INCLUDES ${AVC_ROOT}/common ${AVC_ROOT}/encoder)
|
|
||||||
|
|
||||||
set(LIBAVCENC_X86_C_FLAGS "-msse4.2 -mno-avx -UHP_PL -DN_MB_ENABLE")
|
|
||||||
set(LIBAVCENC_C_FLAGS "${LIBAVCENC_X86_C_FLAGS}")
|
|
||||||
set(LIBAVCENC_X86_INCLUDES ${AVC_ROOT}/common/x86 ${AVC_ROOT}/encoder/x86)
|
|
||||||
|
|
||||||
include_directories(${LIBAVCENC_INCLUDES} ${LIBAVCENC_X86_INCLUDES})
|
|
||||||
add_library(libavcenc ${LIBAVCENC_SRCS} ${LIBAVCENC_X86_SRCS})
|
|
||||||
set_target_properties(libavcenc PROPERTIES COMPILE_FLAGS "${LIBAVCENC_C_FLAGS}")
|
|
||||||
|
|
||||||
list(APPEND AVCENC_SRCS
|
|
||||||
"${AVC_ROOT}/test/encoder/main.c"
|
|
||||||
"${AVC_ROOT}/test/encoder/psnr.c"
|
|
||||||
"${AVC_ROOT}/test/encoder/input.c"
|
|
||||||
"${AVC_ROOT}/test/encoder/output.c"
|
|
||||||
"${AVC_ROOT}/test/encoder/recon.c")
|
|
||||||
|
|
||||||
add_executable(avcenc ${AVCENC_SRCS})
|
|
||||||
set_target_properties(avcenc
|
|
||||||
PROPERTIES COMPILE_FLAGS
|
|
||||||
"-DARM -DMD5_DISABLE -DPROFILE_ENABLE")
|
|
||||||
target_link_libraries(avcenc
|
|
||||||
libavcenc
|
|
||||||
Threads::Threads
|
|
||||||
m)
|
|
||||||
|
|
|
||||||
53
README.md
Normal file
53
README.md
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
# LIBAVC
|
||||||
|
## Getting Started Document
|
||||||
|
|
||||||
|
# LibAVC build steps
|
||||||
|
|
||||||
|
Supports:
|
||||||
|
- aarch32/aarch64 on Linux.
|
||||||
|
- aarch32/aarch64 on Android.
|
||||||
|
- x86_32/x86_64 on Linux.
|
||||||
|
|
||||||
|
## Native Builds
|
||||||
|
Use the following commands for building on the target machine
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cd external/libavc
|
||||||
|
$ mkdir build
|
||||||
|
$ cd build
|
||||||
|
$ cmake ..
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cross-compiler based builds
|
||||||
|
|
||||||
|
### Building for x86_32 on a x86_64 Linux machine
|
||||||
|
```
|
||||||
|
$ cd external/libavc
|
||||||
|
$ mkdir build
|
||||||
|
$ cd build
|
||||||
|
$ CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32" cmake ..
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
### Building for aarch32/aarch64
|
||||||
|
Update 'CMAKE_C_COMPILER', 'CMAKE_CXX_COMPILER', 'CMAKE_C_COMPILER_AR', and
|
||||||
|
'CMAKE_CXX_COMPILER_AR' in CMAKE_TOOLCHAIN_FILE passed below
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cd external/libavc
|
||||||
|
$ mkdir build
|
||||||
|
$ cd build
|
||||||
|
```
|
||||||
|
|
||||||
|
#### For aarch64
|
||||||
|
```
|
||||||
|
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
#### For aarch32
|
||||||
|
```
|
||||||
|
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake
|
||||||
|
$ make
|
||||||
|
```
|
||||||
7
cmake/toolchains/aarch32_toolchain.cmake
Normal file
7
cmake/toolchains/aarch32_toolchain.cmake
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
set(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR aarch32)
|
||||||
|
|
||||||
|
# Modify these variables with paths to appropriate compilers that can produce
|
||||||
|
# armv7 targets
|
||||||
|
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
|
||||||
13
cmake/toolchains/aarch64_toolchain.cmake
Normal file
13
cmake/toolchains/aarch64_toolchain.cmake
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
set(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||||
|
|
||||||
|
# Modify these variables with paths to appropriate compilers that can produce
|
||||||
|
# armv8 targets
|
||||||
|
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
|
||||||
|
set(CMAKE_C_COMPILER_AR
|
||||||
|
aarch64-linux-gnu-gcc-ar
|
||||||
|
CACHE FILEPATH "Archiver")
|
||||||
|
set(CMAKE_CXX_COMPILER_AR
|
||||||
|
aarch64-linux-gnu-gcc-ar
|
||||||
|
CACHE FILEPATH "Archiver")
|
||||||
112
cmake/utils.cmake
Normal file
112
cmake/utils.cmake
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
|
# Adds compiler options for all targets
|
||||||
|
function(libavc_add_compile_options)
|
||||||
|
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
|
||||||
|
add_compile_options(-march=armv8-a)
|
||||||
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch32")
|
||||||
|
add_compile_options(-march=armv7-a -mfpu=neon)
|
||||||
|
else()
|
||||||
|
add_compile_options(-msse4.2 -mno-avx)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_FLAGS -fsanitize=fuzzer-no-link)
|
||||||
|
check_cxx_compiler_flag(-fsanitize=fuzzer-no-link
|
||||||
|
COMPILER_HAS_SANITIZE_FUZZER)
|
||||||
|
unset(CMAKE_REQUIRED_FLAGS)
|
||||||
|
|
||||||
|
if(DEFINED SANITIZE)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS -fsanitize=${SANITIZE})
|
||||||
|
check_cxx_compiler_flag(-fsanitize=${SANITIZE} COMPILER_HAS_SANITIZER)
|
||||||
|
unset(CMAKE_REQUIRED_FLAGS)
|
||||||
|
|
||||||
|
if(NOT COMPILER_HAS_SANITIZER)
|
||||||
|
message(
|
||||||
|
FATAL_ERROR "ERROR: Compiler doesn't support -fsanitize=${SANITIZE}")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
add_compile_options(-fno-omit-frame-pointer -fsanitize=${SANITIZE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Adds defintions for all targets
|
||||||
|
function(libavc_add_definitions)
|
||||||
|
add_definitions(-DPROFILE_ENABLE -DMD5_DISABLE)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
|
||||||
|
add_definitions(-DARMV8 -DDEFAULT_ARCH=D_ARCH_ARMV8_GENERIC)
|
||||||
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch32")
|
||||||
|
add_definitions(-DARMV7 -DDEFAULT_ARCH=D_ARCH_ARM_A9Q)
|
||||||
|
else()
|
||||||
|
add_definitions(-DX86 -DX86_LINUX=1 -DDISABLE_AVX2
|
||||||
|
-DDEFAULT_ARCH=D_ARCH_X86_SSE42)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Adds libraries needed for executables
|
||||||
|
function(libavc_set_link_libraries)
|
||||||
|
link_libraries(Threads::Threads m)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# cmake-format: off
|
||||||
|
# Adds a target for an executable
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# NAME: Name of the executatble
|
||||||
|
# LIB: Library that executable depends on
|
||||||
|
# SOURCES: Source files
|
||||||
|
#
|
||||||
|
# Optional Arguments:
|
||||||
|
# INCLUDES: Include paths
|
||||||
|
# LIBS: Additional libraries
|
||||||
|
# FUZZER: flag to specify if the target is a fuzzer binary
|
||||||
|
# cmake-format: on
|
||||||
|
|
||||||
|
function(libavc_add_executable NAME LIB)
|
||||||
|
set(multi_value_args SOURCES INCLUDES LIBS)
|
||||||
|
set(optional_args FUZZER)
|
||||||
|
cmake_parse_arguments(ARG "${optional_args}" "${single_value_args}"
|
||||||
|
"${multi_value_args}" ${ARGN})
|
||||||
|
|
||||||
|
# Check if compiler supports -fsanitize=fuzzer. If not, skip building fuzzer
|
||||||
|
# binary
|
||||||
|
if(ARG_FUZZER)
|
||||||
|
if(NOT COMPILER_HAS_SANITIZE_FUZZER)
|
||||||
|
message("Compiler doesn't support -fsanitize=fuzzer. Skipping ${NAME}")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(${NAME} ${ARG_SOURCES})
|
||||||
|
target_include_directories(${NAME} PRIVATE ${ARG_INCLUDES})
|
||||||
|
add_dependencies(${NAME} ${LIB} ${ARG_LIBS})
|
||||||
|
|
||||||
|
target_link_libraries(${NAME} ${LIB} ${ARG_LIBS})
|
||||||
|
if(ARG_FUZZER)
|
||||||
|
target_compile_options(${NAME}
|
||||||
|
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>)
|
||||||
|
if(DEFINED SANITIZE)
|
||||||
|
set_target_properties(${NAME} PROPERTIES LINK_FLAGS
|
||||||
|
-fsanitize=fuzzer,${SANITIZE})
|
||||||
|
else()
|
||||||
|
set_target_properties(${NAME} PROPERTIES LINK_FLAGS -fsanitize=fuzzer)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if(DEFINED SANITIZE)
|
||||||
|
set_target_properties(${NAME} PROPERTIES LINK_FLAGS
|
||||||
|
-fsanitize=${SANITIZE})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# cmake-format: off
|
||||||
|
# Adds a target for a fuzzer binary
|
||||||
|
# Calls libavc_add_executable with all arguments with FUZZER set to 1
|
||||||
|
# Arguments:
|
||||||
|
# Refer to libavc_add_executable's arguments
|
||||||
|
# cmake-format: on
|
||||||
|
|
||||||
|
function(libavc_add_fuzzer NAME LIB)
|
||||||
|
libavc_add_executable(${NAME} ${LIB} FUZZER 1 ${ARGV})
|
||||||
|
endfunction()
|
||||||
113
common/common.cmake
Normal file
113
common/common.cmake
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
# src files
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
LIBAVC_COMMON_SRCS
|
||||||
|
"${AVC_ROOT}/common/ih264_buf_mgr.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_cabac_tables.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_cavlc_tables.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_chroma_intra_pred_filters.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_common_tables.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_deblk_edge_filters.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_deblk_tables.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_disp_mgr.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_dpb_mgr.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_ihadamard_scaling.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_inter_pred_filters.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_iquant_itrans_recon.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_list.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_luma_intra_pred_filters.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_mem_fns.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_padding.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_resi_trans_quant.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_trans_data.c"
|
||||||
|
"${AVC_ROOT}/common/ih264_weighted_pred.c"
|
||||||
|
"${AVC_ROOT}/common/ithread.c")
|
||||||
|
|
||||||
|
include_directories(${AVC_ROOT}/common)
|
||||||
|
|
||||||
|
# arm/x86 sources
|
||||||
|
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
LIBAVC_COMMON_ASMS
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_deblk_chroma_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_deblk_luma_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_default_weighted_pred_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_ihadamard_scaling_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_inter_pred_chroma_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_inter_pred_filters_luma_horz_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_inter_pred_filters_luma_vert_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_inter_pred_luma_copy_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_inter_pred_luma_horz_hpel_vert_hpel_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_inter_pred_luma_horz_hpel_vert_qpel_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_inter_pred_luma_horz_qpel_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_inter_pred_luma_horz_qpel_vert_hpel_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_inter_pred_luma_horz_qpel_vert_qpel_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_inter_pred_luma_vert_qpel_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_intra_pred_chroma_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_intra_pred_luma_16x16_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_intra_pred_luma_4x4_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_intra_pred_luma_8x8_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_iquant_itrans_recon_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_iquant_itrans_recon_dc_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_mem_fns_neon_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_padding_neon_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_resi_trans_quant_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_weighted_bi_pred_av8.s"
|
||||||
|
"${AVC_ROOT}/common/armv8/ih264_weighted_pred_av8.s")
|
||||||
|
|
||||||
|
include_directories(${AVC_ROOT}/common/arm)
|
||||||
|
include_directories(${AVC_ROOT}/common/armv8)
|
||||||
|
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch32")
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
LIBAVC_COMMON_ASMS
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_deblk_chroma_a9.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_deblk_luma_a9.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_default_weighted_pred_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_ihadamard_scaling_a9.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_chroma_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_filters_luma_horz_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_filters_luma_vert_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_luma_bilinear_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_luma_copy_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_luma_horz_hpel_vert_hpel_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_luma_horz_hpel_vert_qpel_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_luma_horz_qpel_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_luma_horz_qpel_vert_hpel_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_luma_horz_qpel_vert_qpel_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_inter_pred_luma_vert_qpel_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_intra_pred_chroma_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_intra_pred_luma_16x16_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_intra_pred_luma_4x4_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_intra_pred_luma_8x8_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_iquant_itrans_recon_a9.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_iquant_itrans_recon_dc_a9.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_mem_fns_neon.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_padding_neon.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_resi_trans_quant_a9.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_weighted_bi_pred_a9q.s"
|
||||||
|
"${AVC_ROOT}/common/arm/ih264_weighted_pred_a9q.s")
|
||||||
|
|
||||||
|
include_directories(${AVC_ROOT}/common/arm)
|
||||||
|
else()
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
LIBAVC_COMMON_SRCS
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_chroma_intra_pred_filters_ssse3.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_deblk_chroma_ssse3.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_deblk_luma_ssse3.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_ihadamard_scaling_sse42.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_ihadamard_scaling_ssse3.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_inter_pred_filters_ssse3.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_dc_ssse3.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_sse42.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_ssse3.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_luma_intra_pred_filters_ssse3.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_mem_fns_ssse3.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_padding_ssse3.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_resi_trans_quant_sse42.c"
|
||||||
|
"${AVC_ROOT}/common/x86/ih264_weighted_pred_sse42.c")
|
||||||
|
|
||||||
|
include_directories(${AVC_ROOT}/common/x86)
|
||||||
|
endif()
|
||||||
53
decoder/libavcdec.cmake
Normal file
53
decoder/libavcdec.cmake
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
# src files
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
LIBAVCDEC_SRCS
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_api.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_bitstrm.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_cabac.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_cabac_init_tables.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_compute_bs.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_deblocking.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_dpb_mgr.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_format_conv.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_function_selector_generic.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_inter_pred.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_mb_utils.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_mvpred.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_nal.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_parse_bslice.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_parse_cabac.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_parse_cavlc.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_parse_headers.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_parse_islice.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_parse_mb_header.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_parse_pslice.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_parse_slice.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_process_bslice.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_process_intra_mb.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_process_pslice.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_quant_scaling.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_sei.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_tables.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_thread_compute_bs.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_thread_parse_decode.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_utils.c"
|
||||||
|
"${AVC_ROOT}/decoder/ih264d_vui.c")
|
||||||
|
|
||||||
|
include_directories(${AVC_ROOT}/decoder)
|
||||||
|
|
||||||
|
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}"
|
||||||
|
STREQUAL "aarch32")
|
||||||
|
list(
|
||||||
|
APPEND LIBAVCDEC_ASMS "${AVC_ROOT}/decoder/arm/ih264d_function_selector.c"
|
||||||
|
"${AVC_ROOT}/decoder/arm/ih264d_function_selector_a9q.c"
|
||||||
|
"${AVC_ROOT}/decoder/arm/ih264d_function_selector_av8.c")
|
||||||
|
else()
|
||||||
|
list(
|
||||||
|
APPEND LIBAVCDEC_SRCS "${AVC_ROOT}/decoder/x86/ih264d_function_selector.c"
|
||||||
|
"${AVC_ROOT}/decoder/x86/ih264d_function_selector_sse42.c"
|
||||||
|
"${AVC_ROOT}/decoder/x86/ih264d_function_selector_ssse3.c")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(libavcdec STATIC ${LIBAVC_COMMON_SRCS} ${LIBAVC_COMMON_ASMS}
|
||||||
|
${LIBAVCDEC_SRCS} ${LIBAVCDEC_ASMS})
|
||||||
91
encoder/libavcenc.cmake
Normal file
91
encoder/libavcenc.cmake
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
# src files
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
LIBAVCENC_SRCS
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_api.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_bitstream.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_cabac.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_cabac_encode.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_cabac_init.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_cavlc.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_core_coding.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_deblk.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_encode.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_encode_header.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_fmt_conv.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_function_selector_generic.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_globals.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_half_pel.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_intra_modes_eval.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_mc.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_me.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_modify_frm_rate.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_process.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_rate_control.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_rc_mem_interface.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_sei.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_time_stamp.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_utils.c"
|
||||||
|
"${AVC_ROOT}/encoder/ih264e_version.c"
|
||||||
|
"${AVC_ROOT}/encoder/ime.c"
|
||||||
|
"${AVC_ROOT}/encoder/ime_distortion_metrics.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_bit_allocation.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_cbr_buffer_control.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_est_sad.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_fixed_point_error_bits.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_frame_info_collector.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_mb_model_based.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_picture_type.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_rate_control_api.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_rd_model.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_vbr_storage_vbv.c"
|
||||||
|
"${AVC_ROOT}/encoder/irc_vbr_str_prms.c")
|
||||||
|
|
||||||
|
include_directories(${AVC_ROOT}/encoder)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
LIBAVCENC_ASMS
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_function_selector.c"
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_function_selector_a9q.c"
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_function_selector_av8.c"
|
||||||
|
"${AVC_ROOT}/encoder/armv8/ih264e_evaluate_intra16x16_modes_av8.s"
|
||||||
|
"${AVC_ROOT}/encoder/armv8/ih264e_evaluate_intra_chroma_modes_av8.s"
|
||||||
|
"${AVC_ROOT}/encoder/armv8/ih264e_half_pel_av8.s"
|
||||||
|
"${AVC_ROOT}/encoder/armv8/ime_distortion_metrics_av8.s")
|
||||||
|
|
||||||
|
include_directories(${AVC_ROOT}/encoder/armv8)
|
||||||
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch32")
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
LIBAVCENC_ASMS
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_function_selector.c"
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_function_selector_a9q.c"
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_function_selector_av8.c"
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_evaluate_intra16x16_modes_a9q.s"
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_evaluate_intra4x4_modes_a9q.s"
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_evaluate_intra_chroma_modes_a9q.s"
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_fmt_conv.s"
|
||||||
|
"${AVC_ROOT}/encoder/arm/ih264e_half_pel.s"
|
||||||
|
"${AVC_ROOT}/encoder/arm/ime_distortion_metrics_a9q.s")
|
||||||
|
|
||||||
|
include_directories(${AVC_ROOT}/encoder/armv8)
|
||||||
|
else()
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
LIBAVCENC_SRCS
|
||||||
|
"${AVC_ROOT}/encoder/x86/ih264e_function_selector.c"
|
||||||
|
"${AVC_ROOT}/encoder/x86/ih264e_function_selector_sse42.c"
|
||||||
|
"${AVC_ROOT}/encoder/x86/ih264e_function_selector_ssse3.c"
|
||||||
|
"${AVC_ROOT}/encoder/x86/ih264e_half_pel_ssse3.c"
|
||||||
|
"${AVC_ROOT}/encoder/x86/ih264e_intra_modes_eval_ssse3.c"
|
||||||
|
"${AVC_ROOT}/encoder/x86/ime_distortion_metrics_sse42.c")
|
||||||
|
|
||||||
|
include_directories(${AVC_ROOT}/encoder/x86)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(libavcenc STATIC ${LIBAVC_COMMON_SRCS} ${LIBAVC_COMMON_ASMS}
|
||||||
|
${LIBAVCENC_SRCS} ${LIBAVCENC_ASMS})
|
||||||
|
|
||||||
|
target_compile_definitions(libavcenc PRIVATE N_MB_ENABLE)
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
# Fuzzer for libavc decoder
|
# Fuzzer for libavc decoder and encoder
|
||||||
|
|
||||||
This describes steps to build avc_dec_fuzzer binary.
|
This describes steps to build avc_dec_fuzzer and avc_enc_fuzzer.
|
||||||
|
|
||||||
## Linux x86/x64
|
## Linux x86/x64
|
||||||
|
|
||||||
### Requirements
|
### Requirements
|
||||||
- cmake (3.5 or above)
|
- cmake (3.9.1 or above)
|
||||||
- make
|
- make
|
||||||
- clang (6.0 or above)
|
- clang (6.0 or above)
|
||||||
needs to support -fsanitize=fuzzer, -fsanitize=fuzzer-no-link
|
needs to support -fsanitize=fuzzer, -fsanitize=fuzzer-no-link
|
||||||
|
|
@ -21,51 +21,62 @@ Create a directory inside libavc and change directory
|
||||||
$ mkdir build
|
$ mkdir build
|
||||||
$ cd build
|
$ cd build
|
||||||
```
|
```
|
||||||
Build libavc using cmake
|
Build fuzzer with required sanitizers (-DSANITIZE=fuzzer-no-link is mandatory
|
||||||
|
to enable fuzzers)
|
||||||
```
|
```
|
||||||
$ CC=clang CXX=clang++ cmake ../ \
|
$ cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
|
||||||
-DSANITIZE=fuzzer-no-link,address,signed-integer-overflow
|
-DCMAKE_BUILD_TYPE=Debug -DSANITIZE=fuzzer-no-link,address
|
||||||
$ make
|
$ make
|
||||||
```
|
```
|
||||||
Build the fuzzer
|
|
||||||
```
|
|
||||||
$ clang++ -std=c++11 -fsanitize=fuzzer,address -I. -I../ -I../common \
|
|
||||||
-I../decoder -Wl,--start-group ../fuzzer/avc_dec_fuzzer.cpp \
|
|
||||||
-o ./avc_dec_fuzzer ./libavcdec.a -Wl,--end-group
|
|
||||||
```
|
|
||||||
|
|
||||||
### Steps to run
|
### Steps to run
|
||||||
Create a directory CORPUS_DIR and copy some elementary h264 files to that folder
|
Create a directory CORPUS_DIR and copy some elementary h264 files
|
||||||
To run the fuzzer
|
(for avc_dec_fuzzer) or yuv files (for avc_enc_fuzzer) to that directory
|
||||||
|
|
||||||
|
To run the fuzzers
|
||||||
```
|
```
|
||||||
$ ./avc_dec_fuzzer CORPUS_DIR
|
$ ./avc_dec_fuzzer CORPUS_DIR
|
||||||
|
$ ./avc_enc_fuzzer CORPUS_DIR
|
||||||
```
|
```
|
||||||
|
|
||||||
## Android
|
## Android
|
||||||
|
|
||||||
### Steps to build
|
### Steps to build
|
||||||
Build the fuzzer
|
Build the fuzzers
|
||||||
```
|
```
|
||||||
$ SANITIZE_TARGET=address SANITIZE_HOST=address mmma -j$(nproc) \
|
$ mm -j$(nproc) avc_dec_fuzzer
|
||||||
external/libavc/fuzzer
|
$ mm -j$(nproc) avc_enc_fuzzer
|
||||||
```
|
```
|
||||||
|
|
||||||
### Steps to run
|
### Steps to run
|
||||||
Create a directory CORPUS_DIR and copy some elementary h264 files to that folder
|
Create a directory CORPUS_DIR and copy some elementary h264 files
|
||||||
Push this directory to device.
|
(for avc_dec_fuzzer) or yuv files (for avc_enc_fuzzer) to that folder
|
||||||
|
Push this directory to device
|
||||||
|
|
||||||
To run on device
|
To run avc_dec_fuzzer on device
|
||||||
```
|
```
|
||||||
$ adb sync data
|
$ adb sync data
|
||||||
$ adb shell /data/fuzz/avc_dec_fuzzer CORPUS_DIR
|
$ adb shell /data/fuzz/arm64/avc_dec_fuzzer/avc_dec_fuzzer CORPUS_DIR
|
||||||
```
|
```
|
||||||
To run on host
|
To run avc_enc_fuzzer on device
|
||||||
```
|
```
|
||||||
$ $ANDROID_HOST_OUT/fuzz/avc_dec_fuzzer CORPUS_DIR
|
$ adb sync data
|
||||||
|
$ adb shell /data/fuzz/arm64/avc_enc_fuzzer/avc_enc_fuzzer CORPUS_DIR
|
||||||
|
```
|
||||||
|
|
||||||
|
To run avc_dec_fuzzer on host
|
||||||
|
```
|
||||||
|
$ $ANDROID_HOST_OUT/fuzz/x86_64/avc_dec_fuzzer/avc_dec_fuzzer CORPUS_DIR
|
||||||
|
```
|
||||||
|
|
||||||
|
To run avc_enc_fuzzer on host
|
||||||
|
```
|
||||||
|
$ $ANDROID_HOST_OUT/fuzz/x86_64/avc_enc_fuzzer/avc_enc_fuzzer CORPUS_DIR
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# Fuzzer for libavc encoder
|
# Appendix
|
||||||
|
## libavc encoder fuzzer
|
||||||
|
|
||||||
## Plugin Design Considerations
|
## Plugin Design Considerations
|
||||||
The fuzzer plugin for AVC is designed based on the understanding of the
|
The fuzzer plugin for AVC is designed based on the understanding of the
|
||||||
|
|
@ -170,31 +181,6 @@ This ensures that the plugin tolerates any kind of input (empty, huge,
|
||||||
malformed, etc) and doesnt `exit()` on any input and thereby increasing the
|
malformed, etc) and doesnt `exit()` on any input and thereby increasing the
|
||||||
chance of identifying vulnerabilities.
|
chance of identifying vulnerabilities.
|
||||||
|
|
||||||
## Build
|
|
||||||
|
|
||||||
This describes steps to build avc_enc_fuzzer binary.
|
|
||||||
|
|
||||||
### Android
|
|
||||||
|
|
||||||
#### Steps to build
|
|
||||||
Build the fuzzer
|
|
||||||
```
|
|
||||||
$ mm -j$(nproc) avc_enc_fuzzer
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Steps to run
|
|
||||||
Create a directory CORPUS_DIR and copy some yuv files to that folder
|
|
||||||
Push this directory to device.
|
|
||||||
|
|
||||||
To run on device
|
|
||||||
```
|
|
||||||
$ adb sync data
|
|
||||||
$ adb shell /data/fuzz/arm64/avc_enc_fuzzer/avc_enc_fuzzer CORPUS_DIR
|
|
||||||
```
|
|
||||||
To run on host
|
|
||||||
```
|
|
||||||
$ $ANDROID_HOST_OUT/fuzz/x86_64/avc_enc_fuzzer/avc_enc_fuzzer CORPUS_DIR
|
|
||||||
```
|
|
||||||
|
|
||||||
## References:
|
## References:
|
||||||
* http://llvm.org/docs/LibFuzzer.html
|
* http://llvm.org/docs/LibFuzzer.html
|
||||||
|
|
|
||||||
2
fuzzer/avc_dec_fuzzer.cmake
Normal file
2
fuzzer/avc_dec_fuzzer.cmake
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
libavc_add_fuzzer(avc_dec_fuzzer libavcdec SOURCES
|
||||||
|
${AVC_ROOT}/fuzzer/avc_dec_fuzzer.cpp)
|
||||||
2
fuzzer/avc_enc_fuzzer.cmake
Normal file
2
fuzzer/avc_enc_fuzzer.cmake
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
libavc_add_fuzzer(avc_enc_fuzzer libavcenc SOURCES
|
||||||
|
${AVC_ROOT}/fuzzer/avc_enc_fuzzer.cpp)
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <string.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "ih264_defs.h"
|
#include "ih264_defs.h"
|
||||||
|
|
|
||||||
|
|
@ -22,23 +22,12 @@ test "${OUT}" != "" || exit 1
|
||||||
build_dir=$WORK/build
|
build_dir=$WORK/build
|
||||||
rm -rf ${build_dir}
|
rm -rf ${build_dir}
|
||||||
mkdir -p ${build_dir}
|
mkdir -p ${build_dir}
|
||||||
|
|
||||||
pushd ${build_dir}
|
pushd ${build_dir}
|
||||||
|
cmake ${SRC}/libavc
|
||||||
cmake $SRC/libavc
|
make -j$(nproc) avc_dec_fuzzer
|
||||||
make -j$(nproc)
|
cp ${build_dir}/avc_dec_fuzzer $OUT/avc_dec_fuzzer
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# build fuzzers
|
|
||||||
$CXX $CXXFLAGS -std=c++11 \
|
|
||||||
-I$SRC/libavc \
|
|
||||||
-I$SRC/libavc/common \
|
|
||||||
-I$SRC/libavc/decoder \
|
|
||||||
-I${build_dir} \
|
|
||||||
-Wl,--start-group \
|
|
||||||
$LIB_FUZZING_ENGINE \
|
|
||||||
$SRC/libavc/fuzzer/avc_dec_fuzzer.cpp -o $OUT/avc_dec_fuzzer \
|
|
||||||
${build_dir}/libavcdec.a \
|
|
||||||
-Wl,--end-group
|
|
||||||
|
|
||||||
cp $SRC/avc_dec_fuzzer_seed_corpus.zip $OUT/avc_dec_fuzzer_seed_corpus.zip
|
cp $SRC/avc_dec_fuzzer_seed_corpus.zip $OUT/avc_dec_fuzzer_seed_corpus.zip
|
||||||
cp $SRC/libavc/fuzzer/avc_dec_fuzzer.dict $OUT/avcdec_fuzzer.dict
|
cp $SRC/libavc/fuzzer/avc_dec_fuzzer.dict $OUT/avcdec_fuzzer.dict
|
||||||
|
|
|
||||||
1
test/decoder/avcdec.cmake
Normal file
1
test/decoder/avcdec.cmake
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
libavc_add_executable(avcdec libavcdec SOURCES ${AVC_ROOT}/test/decoder/main.c)
|
||||||
10
test/encoder/avcenc.cmake
Normal file
10
test/encoder/avcenc.cmake
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
AVCENC_SRCS
|
||||||
|
"${AVC_ROOT}/test/encoder/input.c"
|
||||||
|
"${AVC_ROOT}/test/encoder/main.c"
|
||||||
|
"${AVC_ROOT}/test/encoder/output.c"
|
||||||
|
"${AVC_ROOT}/test/encoder/psnr.c"
|
||||||
|
"${AVC_ROOT}/test/encoder/recon.c")
|
||||||
|
|
||||||
|
libavc_add_executable(avcenc libavcenc SOURCES ${AVCENC_SRCS})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue