1cmake_minimum_required(VERSION 3.5) 2 3set(AVC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") 4set(AVC_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}") 5 6if("${AVC_ROOT}" STREQUAL "${AVC_CONFIG_DIR}") 7 message( 8 FATAL_ERROR 9 "Building from within the libavc source tree is not supported.\n" 10 "Hint: Run these commands\n" 11 "$ rm -rf CMakeCache.txt CMakeFiles\n" 12 "$ mkdir -p ./build\n" 13 "$ cd ./build\n" 14 "And re-run CMake from the build directory.") 15endif() 16 17set(THREADS_PREFER_PTHREAD_FLAG ON) 18find_package(Threads REQUIRED) 19set(CMAKE_STATIC_LIBRARY_PREFIX "") 20 21if(SANITIZE) 22 string(TOLOWER ${SANITIZE} SANITIZE) 23 24 set(CMAKE_SANITIZER_C_FLAGS "-fno-omit-frame-pointer -fsanitize=${SANITIZE}") 25 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SANITIZER_C_FLAGS}") 26endif() 27 28list(APPEND LIBAVCDEC_SRCS 29 "${AVC_ROOT}/common/ih264_buf_mgr.c" 30 "${AVC_ROOT}/common/ih264_disp_mgr.c" 31 "${AVC_ROOT}/common/ih264_inter_pred_filters.c" 32 "${AVC_ROOT}/common/ih264_luma_intra_pred_filters.c" 33 "${AVC_ROOT}/common/ih264_chroma_intra_pred_filters.c" 34 "${AVC_ROOT}/common/ih264_padding.c" 35 "${AVC_ROOT}/common/ih264_mem_fns.c" 36 "${AVC_ROOT}/common/ih264_deblk_edge_filters.c" 37 "${AVC_ROOT}/common/ih264_iquant_itrans_recon.c" 38 "${AVC_ROOT}/common/ih264_ihadamard_scaling.c" 39 "${AVC_ROOT}/common/ih264_weighted_pred.c" 40 "${AVC_ROOT}/common/ithread.c" 41 "${AVC_ROOT}/decoder/ih264d_cabac.c" 42 "${AVC_ROOT}/decoder/ih264d_parse_mb_header.c" 43 "${AVC_ROOT}/decoder/ih264d_parse_cabac.c" 44 "${AVC_ROOT}/decoder/ih264d_process_intra_mb.c" 45 "${AVC_ROOT}/decoder/ih264d_inter_pred.c" 46 "${AVC_ROOT}/decoder/ih264d_parse_bslice.c" 47 "${AVC_ROOT}/decoder/ih264d_parse_pslice.c" 48 "${AVC_ROOT}/decoder/ih264d_parse_islice.c" 49 "${AVC_ROOT}/decoder/ih264d_cabac_init_tables.c" 50 "${AVC_ROOT}/decoder/ih264d_bitstrm.c" 51 "${AVC_ROOT}/decoder/ih264d_compute_bs.c" 52 "${AVC_ROOT}/decoder/ih264d_deblocking.c" 53 "${AVC_ROOT}/decoder/ih264d_parse_headers.c" 54 "${AVC_ROOT}/decoder/ih264d_mb_utils.c" 55 "${AVC_ROOT}/decoder/ih264d_mvpred.c" 56 "${AVC_ROOT}/decoder/ih264d_utils.c" 57 "${AVC_ROOT}/decoder/ih264d_process_bslice.c" 58 "${AVC_ROOT}/decoder/ih264d_process_pslice.c" 59 "${AVC_ROOT}/decoder/ih264d_parse_slice.c" 60 "${AVC_ROOT}/decoder/ih264d_quant_scaling.c" 61 "${AVC_ROOT}/decoder/ih264d_parse_cavlc.c" 62 "${AVC_ROOT}/decoder/ih264d_dpb_mgr.c" 63 "${AVC_ROOT}/decoder/ih264d_nal.c" 64 "${AVC_ROOT}/decoder/ih264d_sei.c" 65 "${AVC_ROOT}/decoder/ih264d_tables.c" 66 "${AVC_ROOT}/decoder/ih264d_vui.c" 67 "${AVC_ROOT}/decoder/ih264d_format_conv.c" 68 "${AVC_ROOT}/decoder/ih264d_thread_parse_decode.c" 69 "${AVC_ROOT}/decoder/ih264d_api.c" 70 "${AVC_ROOT}/decoder/ih264d_thread_compute_bs.c" 71 "${AVC_ROOT}/decoder/ih264d_function_selector_generic.c") 72 73list(APPEND LIBAVCDEC_X86_SRCS 74 "${AVC_ROOT}/decoder/x86/ih264d_function_selector.c" 75 "${AVC_ROOT}/decoder/x86/ih264d_function_selector_sse42.c" 76 "${AVC_ROOT}/decoder/x86/ih264d_function_selector_ssse3.c" 77 "${AVC_ROOT}/common/x86/ih264_inter_pred_filters_ssse3.c" 78 "${AVC_ROOT}/common/x86/ih264_deblk_luma_ssse3.c" 79 "${AVC_ROOT}/common/x86/ih264_deblk_chroma_ssse3.c" 80 "${AVC_ROOT}/common/x86/ih264_padding_ssse3.c" 81 "${AVC_ROOT}/common/x86/ih264_mem_fns_ssse3.c" 82 "${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_dc_ssse3.c" 83 "${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_ssse3.c" 84 "${AVC_ROOT}/common/x86/ih264_luma_intra_pred_filters_ssse3.c" 85 "${AVC_ROOT}/common/x86/ih264_chroma_intra_pred_filters_ssse3.c" 86 "${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_sse42.c" 87 "${AVC_ROOT}/common/x86/ih264_weighted_pred_sse42.c" 88 "${AVC_ROOT}/common/x86/ih264_ihadamard_scaling_sse42.c") 89 90set(LIBAVCDEC_INCLUDES ${AVC_ROOT}/common ${AVC_ROOT}/decoder) 91 92set(LIBAVCDEC_X86_C_FLAGS 93 "-DX86 -DDISABLE_AVX2 -msse4.2 -mno-avx -DDEFAULT_ARCH=D_ARCH_X86_SSE42") 94set(LIBAVCDEC_X86_INCLUDES ${AVC_ROOT}/common/x86 ${AVC_ROOT}/decoder/x86) 95set(LIBAVCDEC_C_FLAGS "${LIBAVCDEC_X86_C_FLAGS}") 96 97include_directories(${LIBAVCDEC_INCLUDES} ${LIBAVCDEC_X86_INCLUDES}) 98add_library(libavcdec ${LIBAVCDEC_SRCS} ${LIBAVCDEC_X86_SRCS}) 99set_target_properties(libavcdec PROPERTIES COMPILE_FLAGS "${LIBAVCDEC_C_FLAGS}") 100 101list(APPEND AVCDEC_SRCS "${AVC_ROOT}/test/decoder/main.c") 102 103add_executable(avcdec ${AVCDEC_SRCS}) 104set_target_properties(avcdec 105 PROPERTIES COMPILE_FLAGS "-DMD5_DISABLE -DPROFILE_ENABLE") 106target_link_libraries(avcdec libavcdec Threads::Threads) 107 108list(APPEND LIBAVCENC_SRCS 109 "${AVC_ROOT}/common/ih264_resi_trans_quant.c" 110 "${AVC_ROOT}/common/ih264_iquant_itrans_recon.c" 111 "${AVC_ROOT}/common/ih264_ihadamard_scaling.c" 112 "${AVC_ROOT}/common/ih264_inter_pred_filters.c" 113 "${AVC_ROOT}/common/ih264_luma_intra_pred_filters.c" 114 "${AVC_ROOT}/common/ih264_chroma_intra_pred_filters.c" 115 "${AVC_ROOT}/common/ih264_padding.c" 116 "${AVC_ROOT}/common/ih264_mem_fns.c" 117 "${AVC_ROOT}/common/ih264_deblk_edge_filters.c" 118 "${AVC_ROOT}/common/ih264_deblk_tables.c" 119 "${AVC_ROOT}/common/ih264_cavlc_tables.c" 120 "${AVC_ROOT}/common/ih264_cabac_tables.c" 121 "${AVC_ROOT}/common/ih264_common_tables.c" 122 "${AVC_ROOT}/common/ih264_trans_data.c" 123 "${AVC_ROOT}/common/ih264_buf_mgr.c" 124 "${AVC_ROOT}/common/ih264_dpb_mgr.c" 125 "${AVC_ROOT}/common/ih264_list.c" 126 "${AVC_ROOT}/common/ithread.c" 127 "${AVC_ROOT}/encoder/ih264e_globals.c" 128 "${AVC_ROOT}/encoder/ih264e_intra_modes_eval.c" 129 "${AVC_ROOT}/encoder/ih264e_half_pel.c" 130 "${AVC_ROOT}/encoder/ih264e_mc.c" 131 "${AVC_ROOT}/encoder/ih264e_me.c" 132 "${AVC_ROOT}/encoder/ih264e_rc_mem_interface.c" 133 "${AVC_ROOT}/encoder/ih264e_time_stamp.c" 134 "${AVC_ROOT}/encoder/ih264e_modify_frm_rate.c" 135 "${AVC_ROOT}/encoder/ih264e_rate_control.c" 136 "${AVC_ROOT}/encoder/ih264e_core_coding.c" 137 "${AVC_ROOT}/encoder/ih264e_deblk.c" 138 "${AVC_ROOT}/encoder/ih264e_api.c" 139 "${AVC_ROOT}/encoder/ih264e_process.c" 140 "${AVC_ROOT}/encoder/ih264e_encode.c" 141 "${AVC_ROOT}/encoder/ih264e_utils.c" 142 "${AVC_ROOT}/encoder/ih264e_version.c" 143 "${AVC_ROOT}/encoder/ih264e_bitstream.c" 144 "${AVC_ROOT}/encoder/ih264e_cavlc.c" 145 "${AVC_ROOT}/encoder/ih264e_cabac_init.c" 146 "${AVC_ROOT}/encoder/ih264e_cabac.c" 147 "${AVC_ROOT}/encoder/ih264e_cabac_encode.c" 148 "${AVC_ROOT}/encoder/ih264e_encode_header.c" 149 "${AVC_ROOT}/encoder/ih264e_function_selector_generic.c" 150 "${AVC_ROOT}/encoder/ih264e_fmt_conv.c" 151 "${AVC_ROOT}/encoder/ih264e_sei.c" 152 "${AVC_ROOT}/encoder/irc_rate_control_api.c" 153 "${AVC_ROOT}/encoder/irc_bit_allocation.c" 154 "${AVC_ROOT}/encoder/irc_cbr_buffer_control.c" 155 "${AVC_ROOT}/encoder/irc_est_sad.c" 156 "${AVC_ROOT}/encoder/irc_fixed_point_error_bits.c" 157 "${AVC_ROOT}/encoder/irc_frame_info_collector.c" 158 "${AVC_ROOT}/encoder/irc_mb_model_based.c" 159 "${AVC_ROOT}/encoder/irc_picture_type.c" 160 "${AVC_ROOT}/encoder/irc_rd_model.c" 161 "${AVC_ROOT}/encoder/irc_vbr_storage_vbv.c" 162 "${AVC_ROOT}/encoder/irc_vbr_str_prms.c" 163 "${AVC_ROOT}/encoder/ime.c" 164 "${AVC_ROOT}/encoder/ime_distortion_metrics.c") 165 166list(APPEND LIBAVCENC_X86_SRCS 167 "${AVC_ROOT}/encoder/x86/ih264e_function_selector.c" 168 "${AVC_ROOT}/encoder/x86/ih264e_function_selector_sse42.c" 169 "${AVC_ROOT}/encoder/x86/ih264e_function_selector_ssse3.c" 170 "${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_ssse3.c" 171 "${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_dc_ssse3.c" 172 "${AVC_ROOT}/common/x86/ih264_ihadamard_scaling_ssse3.c" 173 "${AVC_ROOT}/common/x86/ih264_inter_pred_filters_ssse3.c" 174 "${AVC_ROOT}/common/x86/ih264_mem_fns_ssse3.c" 175 "${AVC_ROOT}/common/x86/ih264_padding_ssse3.c" 176 "${AVC_ROOT}/common/x86/ih264_luma_intra_pred_filters_ssse3.c" 177 "${AVC_ROOT}/common/x86/ih264_chroma_intra_pred_filters_ssse3.c" 178 "${AVC_ROOT}/common/x86/ih264_deblk_chroma_ssse3.c" 179 "${AVC_ROOT}/common/x86/ih264_deblk_luma_ssse3.c" 180 "${AVC_ROOT}/common/x86/ih264_iquant_itrans_recon_sse42.c" 181 "${AVC_ROOT}/common/x86/ih264_ihadamard_scaling_sse42.c" 182 "${AVC_ROOT}/common/x86/ih264_resi_trans_quant_sse42.c" 183 "${AVC_ROOT}/common/x86/ih264_weighted_pred_sse42.c" 184 "${AVC_ROOT}/encoder/x86/ih264e_half_pel_ssse3.c" 185 "${AVC_ROOT}/encoder/x86/ih264e_intra_modes_eval_ssse3.c" 186 "${AVC_ROOT}/encoder/x86/ime_distortion_metrics_sse42.c") 187 188set(LIBAVCENC_INCLUDES ${AVC_ROOT}/common ${AVC_ROOT}/encoder) 189 190set(LIBAVCENC_X86_C_FLAGS "-msse4.2 -mno-avx -UHP_PL -DN_MB_ENABLE") 191set(LIBAVCENC_C_FLAGS "${LIBAVCENC_X86_C_FLAGS}") 192set(LIBAVCENC_X86_INCLUDES ${AVC_ROOT}/common/x86 ${AVC_ROOT}/encoder/x86) 193 194include_directories(${LIBAVCENC_INCLUDES} ${LIBAVCENC_X86_INCLUDES}) 195add_library(libavcenc ${LIBAVCENC_SRCS} ${LIBAVCENC_X86_SRCS}) 196set_target_properties(libavcenc PROPERTIES COMPILE_FLAGS "${LIBAVCENC_C_FLAGS}") 197 198list(APPEND AVCENC_SRCS 199 "${AVC_ROOT}/test/encoder/main.c" 200 "${AVC_ROOT}/test/encoder/psnr.c" 201 "${AVC_ROOT}/test/encoder/input.c" 202 "${AVC_ROOT}/test/encoder/output.c" 203 "${AVC_ROOT}/test/encoder/recon.c") 204 205add_executable(avcenc ${AVCENC_SRCS}) 206set_target_properties(avcenc 207 PROPERTIES COMPILE_FLAGS 208 "-DARM -DMD5_DISABLE -DPROFILE_ENABLE") 209target_link_libraries(avcenc 210 libavcenc 211 Threads::Threads 212 m) 213