1 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 import("//build/config/arm.gni") 6 7 # If fixed point implementation shall be used (otherwise float). 8 use_opus_fixed_point = ((is_android || is_chromeos || 9 (is_ios && arm_version == 7)) && cpu_arch == "arm") 10 11 # If ARM optimizations shall be used to accelerate performance. 12 use_opus_arm_optimization = use_opus_fixed_point 13 14 # If OPUS Run Time CPU Detections (RTCD) shall be used. 15 use_opus_rtcd = ((is_android || is_chromeos) && cpu_arch == "arm") 16 17 config("opus_config") { 18 include_dirs = [ 19 "src/include", 20 ] 21 } 22 23 if (use_opus_rtcd) { 24 action("convert_rtcd_assembler") { 25 script = "convert_rtcd_assembler.py" 26 outputs = [ "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S" ] 27 args = [ 28 rebase_path("//third_party/opus/src/celt/arm/arm2gnu.pl", 29 root_build_dir), 30 rebase_path("//third_party/opus/src/celt/arm/celt_pitch_xcorr_arm.s", 31 root_build_dir), 32 rebase_path("$target_gen_dir/celt_pitch_xcorr_arm_gnu.S", 33 root_build_dir), 34 ] 35 } 36 } 37 38 source_set("opus") { 39 gypi_values = exec_script( 40 "//build/gypi_to_gn.py", 41 [ rebase_path("opus_srcs.gypi") ], 42 "scope", 43 [ "opus_srcs.gypi" ]) 44 sources = gypi_values.opus_common_sources 45 46 defines = [ 47 "OPUS_BUILD", 48 "OPUS_EXPORT=", 49 ] 50 51 include_dirs = [ 52 "src/celt", 53 "src/silk", 54 ] 55 56 configs -= [ "//build/config/compiler:chromium_code" ] 57 configs += [ "//build/config/compiler:no_chromium_code" ] 58 public_configs = [ ":opus_config" ] 59 60 if (is_win) { 61 defines += [ 62 "USE_ALLOCA", 63 "inline=__inline", 64 ] 65 66 cflags = [ 67 "/wd4305", # Disable truncation warning in celt/pitch.c . 68 "/wd4334", # Disable 32-bit shift warning in src/opus_encoder.c . 69 ] 70 } else { 71 defines += [ 72 "HAVE_LRINT", 73 "HAVE_LRINTF", 74 "VAR_ARRAYS", 75 ] 76 } 77 78 if (is_posix && !is_android) { 79 # Suppress a warning given by opus_decoder.c that tells us 80 # optimizations are turned off. 81 cflags = [ 82 "-Wno-#pragma-messages", 83 ] 84 } 85 86 if (use_opus_fixed_point) { 87 sources += gypi_values.opus_fixed_sources 88 89 defines += [ "FIXED_POINT" ] 90 91 include_dirs += [ 92 "src/silk/fixed", 93 ] 94 } else { 95 sources += gypi_values.opus_float_sources 96 97 include_dirs += [ 98 "src/silk/float", 99 ] 100 } 101 102 if (use_opus_arm_optimization) { 103 sources += [ 104 "src/celt/arm/fixed_armv4.h", 105 "src/celt/arm/fixed_armv5e.h", 106 "src/celt/arm/kiss_fft_armv4.h", 107 "src/celt/arm/kiss_fft_armv5e.h", 108 "src/celt/pitch_arm.h", 109 "src/silk/arm/macro_armv4.h", 110 "src/silk/arm/macro_armv5e.h", 111 "src/silk/arm/SigProc_FIX_armv4.h", 112 "src/silk/arm/SigProc_FIX_armv5e.h", 113 ] 114 115 defines += [ 116 "OPUS_ARM_ASM", 117 "OPUS_ARM_INLINE_ASM", 118 "OPUS_ARM_INLINE_EDSP", 119 ] 120 121 if (use_opus_rtcd) { 122 sources += [ 123 "src/celt/arm/arm_celt_map.c", 124 "src/celt/arm/armcpu.c", 125 "src/celt/arm/armcpu.h", 126 "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S", 127 ] 128 129 defines += [ 130 "OPUS_ARM_MAY_HAVE_EDSP", 131 "OPUS_ARM_MAY_HAVE_MEDIA", 132 "OPUS_ARM_MAY_HAVE_NEON", 133 "OPUS_HAVE_RTCD", 134 ] 135 136 deps = [ ":convert_rtcd_assembler" ] 137 } 138 } 139 } 140 141 executable("opus_demo") { 142 sources = [ 143 "src/src/opus_demo.c", 144 ] 145 146 configs -= [ "//build/config/compiler:chromium_code" ] 147 configs += [ "//build/config/compiler:no_chromium_code" ] 148 149 include_dirs = [ 150 "src/celt", 151 "src/silk", 152 ] 153 154 if (is_win) { 155 defines = [ "inline=__inline" ] 156 } 157 if (is_android) { 158 libs = [ "log" ] 159 } 160 if (is_clang) { 161 cflags = [ "-Wno-absolute-value" ] 162 } 163 164 deps = [ ":opus" ] 165 } 166