Harish Mahendrakar | 7508e0f | 2019-08-15 17:33:18 -0700 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.5) |
| 2 | |
| 3 | set(HEVC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") |
| 4 | set(HEVC_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}") |
| 5 | |
| 6 | if("${HEVC_ROOT}" STREQUAL "${HEVC_CONFIG_DIR}") |
Harish Mahendrakar | 7483c9c | 2019-08-20 15:18:27 -0700 | [diff] [blame] | 7 | message( |
| 8 | FATAL_ERROR |
| 9 | "Building from within the libhevc 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.") |
Harish Mahendrakar | 7508e0f | 2019-08-15 17:33:18 -0700 | [diff] [blame] | 15 | endif() |
| 16 | |
| 17 | set(THREADS_PREFER_PTHREAD_FLAG ON) |
| 18 | find_package(Threads REQUIRED) |
| 19 | set(CMAKE_STATIC_LIBRARY_PREFIX "") |
| 20 | |
Harish Mahendrakar | 7483c9c | 2019-08-20 15:18:27 -0700 | [diff] [blame] | 21 | if(SANITIZE) |
Harish Mahendrakar | 7508e0f | 2019-08-15 17:33:18 -0700 | [diff] [blame] | 22 | string(TOLOWER ${SANITIZE} SANITIZE) |
| 23 | |
Harish Mahendrakar | 7483c9c | 2019-08-20 15:18:27 -0700 | [diff] [blame] | 24 | set(CMAKE_SANITIZER_C_FLAGS "-fno-omit-frame-pointer -fsanitize=${SANITIZE}") |
| 25 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SANITIZER_C_FLAGS}") |
Harish Mahendrakar | 7508e0f | 2019-08-15 17:33:18 -0700 | [diff] [blame] | 26 | endif() |
| 27 | |
| 28 | list(APPEND LIBHEVCDEC_SRCS |
Harish Mahendrakar | 7483c9c | 2019-08-20 15:18:27 -0700 | [diff] [blame] | 29 | "${HEVC_ROOT}/common/ithread.c" |
| 30 | "${HEVC_ROOT}/decoder/ihevcd_api.c" |
| 31 | "${HEVC_ROOT}/common/ihevc_quant_tables.c" |
| 32 | "${HEVC_ROOT}/common/ihevc_inter_pred_filters.c" |
| 33 | "${HEVC_ROOT}/common/ihevc_weighted_pred.c" |
| 34 | "${HEVC_ROOT}/common/ihevc_padding.c" |
| 35 | "${HEVC_ROOT}/common/ihevc_deblk_edge_filter.c" |
| 36 | "${HEVC_ROOT}/common/ihevc_deblk_tables.c" |
| 37 | "${HEVC_ROOT}/common/ihevc_cabac_tables.c" |
| 38 | "${HEVC_ROOT}/common/ihevc_common_tables.c" |
| 39 | "${HEVC_ROOT}/common/ihevc_intra_pred_filters.c" |
| 40 | "${HEVC_ROOT}/common/ihevc_chroma_intra_pred_filters.c" |
| 41 | "${HEVC_ROOT}/common/ihevc_mem_fns.c" |
| 42 | "${HEVC_ROOT}/common/ihevc_sao.c" |
| 43 | "${HEVC_ROOT}/common/ihevc_trans_tables.c" |
| 44 | "${HEVC_ROOT}/common/ihevc_recon.c" |
| 45 | "${HEVC_ROOT}/common/ihevc_itrans.c" |
| 46 | "${HEVC_ROOT}/common/ihevc_itrans_recon.c" |
| 47 | "${HEVC_ROOT}/common/ihevc_iquant_recon.c" |
| 48 | "${HEVC_ROOT}/common/ihevc_iquant_itrans_recon.c" |
| 49 | "${HEVC_ROOT}/common/ihevc_itrans_recon_32x32.c" |
| 50 | "${HEVC_ROOT}/common/ihevc_itrans_recon_16x16.c" |
| 51 | "${HEVC_ROOT}/common/ihevc_itrans_recon_8x8.c" |
| 52 | "${HEVC_ROOT}/common/ihevc_chroma_itrans_recon.c" |
| 53 | "${HEVC_ROOT}/common/ihevc_chroma_iquant_recon.c" |
| 54 | "${HEVC_ROOT}/common/ihevc_chroma_iquant_itrans_recon.c" |
| 55 | "${HEVC_ROOT}/common/ihevc_chroma_recon.c" |
| 56 | "${HEVC_ROOT}/common/ihevc_chroma_itrans_recon_16x16.c" |
| 57 | "${HEVC_ROOT}/common/ihevc_chroma_itrans_recon_8x8.c" |
| 58 | "${HEVC_ROOT}/common/ihevc_buf_mgr.c" |
| 59 | "${HEVC_ROOT}/common/ihevc_disp_mgr.c" |
| 60 | "${HEVC_ROOT}/common/ihevc_dpb_mgr.c" |
| 61 | "${HEVC_ROOT}/common/ithread.c" |
| 62 | "${HEVC_ROOT}/decoder/ihevcd_version.c" |
| 63 | "${HEVC_ROOT}/decoder/ihevcd_api.c" |
| 64 | "${HEVC_ROOT}/decoder/ihevcd_decode.c" |
| 65 | "${HEVC_ROOT}/decoder/ihevcd_nal.c" |
| 66 | "${HEVC_ROOT}/decoder/ihevcd_bitstream.c" |
| 67 | "${HEVC_ROOT}/decoder/ihevcd_parse_headers.c" |
| 68 | "${HEVC_ROOT}/decoder/ihevcd_parse_slice_header.c" |
| 69 | "${HEVC_ROOT}/decoder/ihevcd_parse_slice.c" |
| 70 | "${HEVC_ROOT}/decoder/ihevcd_parse_residual.c" |
| 71 | "${HEVC_ROOT}/decoder/ihevcd_cabac.c" |
| 72 | "${HEVC_ROOT}/decoder/ihevcd_intra_pred_mode_prediction.c" |
| 73 | "${HEVC_ROOT}/decoder/ihevcd_process_slice.c" |
| 74 | "${HEVC_ROOT}/decoder/ihevcd_utils.c" |
| 75 | "${HEVC_ROOT}/decoder/ihevcd_job_queue.c" |
| 76 | "${HEVC_ROOT}/decoder/ihevcd_ref_list.c" |
| 77 | "${HEVC_ROOT}/decoder/ihevcd_get_mv.c" |
| 78 | "${HEVC_ROOT}/decoder/ihevcd_mv_pred.c" |
| 79 | "${HEVC_ROOT}/decoder/ihevcd_mv_merge.c" |
| 80 | "${HEVC_ROOT}/decoder/ihevcd_iquant_itrans_recon_ctb.c" |
| 81 | "${HEVC_ROOT}/decoder/ihevcd_itrans_recon_dc.c" |
| 82 | "${HEVC_ROOT}/decoder/ihevcd_common_tables.c" |
| 83 | "${HEVC_ROOT}/decoder/ihevcd_boundary_strength.c" |
| 84 | "${HEVC_ROOT}/decoder/ihevcd_deblk.c" |
| 85 | "${HEVC_ROOT}/decoder/ihevcd_inter_pred.c" |
| 86 | "${HEVC_ROOT}/decoder/ihevcd_sao.c" |
| 87 | "${HEVC_ROOT}/decoder/ihevcd_ilf_padding.c" |
| 88 | "${HEVC_ROOT}/decoder/ihevcd_fmt_conv.c") |
Harish Mahendrakar | 7508e0f | 2019-08-15 17:33:18 -0700 | [diff] [blame] | 89 | |
Harish Mahendrakar | 7483c9c | 2019-08-20 15:18:27 -0700 | [diff] [blame] | 90 | list( |
| 91 | APPEND LIBHEVCDEC_X86_SRCS |
| 92 | "${HEVC_ROOT}/decoder/x86/ihevcd_function_selector.c" |
| 93 | "${HEVC_ROOT}/decoder/x86/ihevcd_function_selector_generic.c" |
| 94 | "${HEVC_ROOT}/decoder/x86/ihevcd_function_selector_ssse3.c" |
| 95 | "${HEVC_ROOT}/decoder/x86/ihevcd_function_selector_sse42.c" |
| 96 | "${HEVC_ROOT}/common/x86/ihevc_inter_pred_filters_ssse3_intr.c" |
| 97 | "${HEVC_ROOT}/common/x86/ihevc_weighted_pred_ssse3_intr.c" |
| 98 | "${HEVC_ROOT}/common/x86/ihevc_intra_pred_filters_ssse3_intr.c" |
| 99 | "${HEVC_ROOT}/common/x86/ihevc_chroma_intra_pred_filters_ssse3_intr.c" |
| 100 | "${HEVC_ROOT}/common/x86/ihevc_itrans_recon_ssse3_intr.c" |
| 101 | "${HEVC_ROOT}/common/x86/ihevc_itrans_recon_16x16_ssse3_intr.c" |
| 102 | "${HEVC_ROOT}/common/x86/ihevc_itrans_recon_32x32_ssse3_intr.c" |
| 103 | "${HEVC_ROOT}/common/x86/ihevc_sao_ssse3_intr.c" |
| 104 | "${HEVC_ROOT}/common/x86/ihevc_deblk_ssse3_intr.c" |
| 105 | "${HEVC_ROOT}/common/x86/ihevc_padding_ssse3_intr.c" |
| 106 | "${HEVC_ROOT}/common/x86/ihevc_mem_fns_ssse3_intr.c" |
| 107 | "${HEVC_ROOT}/decoder/x86/ihevcd_fmt_conv_ssse3_intr.c" |
| 108 | "${HEVC_ROOT}/decoder/x86/ihevcd_it_rec_dc_ssse3_intr.c" |
| 109 | "${HEVC_ROOT}/common/x86/ihevc_inter_pred_filters_sse42_intr.c" |
| 110 | "${HEVC_ROOT}/common/x86/ihevc_weighted_pred_sse42_intr.c" |
| 111 | "${HEVC_ROOT}/common/x86/ihevc_intra_pred_filters_sse42_intr.c" |
| 112 | "${HEVC_ROOT}/common/x86/ihevc_chroma_intra_pred_filters_sse42_intr.c" |
| 113 | "${HEVC_ROOT}/common/x86/ihevc_itrans_recon_sse42_intr.c" |
| 114 | "${HEVC_ROOT}/common/x86/ihevc_16x16_itrans_recon_sse42_intr.c" |
| 115 | "${HEVC_ROOT}/common/x86/ihevc_32x32_itrans_recon_sse42_intr.c" |
| 116 | "${HEVC_ROOT}/decoder/x86/ihevcd_it_rec_dc_sse42_intr.c" |
| 117 | "${HEVC_ROOT}/common/x86/ihevc_tables_x86_intr.c") |
Harish Mahendrakar | 7508e0f | 2019-08-15 17:33:18 -0700 | [diff] [blame] | 118 | |
Harish Mahendrakar | 7483c9c | 2019-08-20 15:18:27 -0700 | [diff] [blame] | 119 | set(LIBHEVCDEC_INCLUDES ${HEVC_ROOT}/common ${HEVC_ROOT}/decoder) |
Harish Mahendrakar | 7508e0f | 2019-08-15 17:33:18 -0700 | [diff] [blame] | 120 | |
Harish Mahendrakar | 7483c9c | 2019-08-20 15:18:27 -0700 | [diff] [blame] | 121 | set(LIBHEVCDEC_X86_C_FLAGS "-DX86 -DDISABLE_AVX2 -msse4.2 -mno-avx \ |
| 122 | -DDEFAULT_ARCH=D_ARCH_X86_SSE42 -DMULTICORE") |
| 123 | set(LIBHEVCDEC_X86_INCLUDES ${HEVC_ROOT}/common/x86 ${HEVC_ROOT}/decoder/x86) |
| 124 | set(LIBHEVCDEC_C_FLAGS "${LIBHEVCDEC_X86_C_FLAGS}") |
Harish Mahendrakar | 7508e0f | 2019-08-15 17:33:18 -0700 | [diff] [blame] | 125 | |
| 126 | include_directories(${LIBHEVCDEC_INCLUDES} ${LIBHEVCDEC_X86_INCLUDES}) |
| 127 | add_library(libhevcdec ${LIBHEVCDEC_SRCS} ${LIBHEVCDEC_X86_SRCS}) |
Harish Mahendrakar | 7483c9c | 2019-08-20 15:18:27 -0700 | [diff] [blame] | 128 | set_target_properties(libhevcdec |
| 129 | PROPERTIES COMPILE_FLAGS "${LIBHEVCDEC_C_FLAGS}") |
Harish Mahendrakar | 7508e0f | 2019-08-15 17:33:18 -0700 | [diff] [blame] | 130 | |
Harish Mahendrakar | 7483c9c | 2019-08-20 15:18:27 -0700 | [diff] [blame] | 131 | list(APPEND HEVCDEC_SRCS "${HEVC_ROOT}/test/decoder/main.c") |
Harish Mahendrakar | 7508e0f | 2019-08-15 17:33:18 -0700 | [diff] [blame] | 132 | |
| 133 | add_executable(hevcdec ${HEVCDEC_SRCS}) |
| 134 | set_target_properties(hevcdec PROPERTIES COMPILE_FLAGS "-DMD5_DISABLE \ |
| 135 | -DPROFILE_ENABLE") |
| 136 | target_link_libraries(hevcdec libhevcdec Threads::Threads) |