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.
5 import("//build/config/arm.gni")
6 import("//build/config/mips.gni")
8 # If fixed point implementation shall be used (otherwise float).
9 # TODO(wtc): change "mipselx" to "mipsel" in this file when the compilation
10 # errors in the MIPS optimizations are fixed.
11 use_opus_fixed_point =
12 cpu_arch == "arm" || cpu_arch == "arm64" || cpu_arch == "mipselx"
14 # If ARM optimizations shall be used to accelerate performance.
15 use_opus_arm_optimization = cpu_arch == "arm"
17 # If MIPS optimizations shall be used to accelerate performance.
18 use_opus_mips_optimization = cpu_arch == "mipselx"
20 # If OPUS Run Time CPU Detections (RTCD) shall be used.
21 # Based on the conditions in celt/arm/armcpu.c:
22 # defined(_MSC_VER) || defined(__linux__).
23 use_opus_rtcd = cpu_arch == "arm" && (is_win || is_android || is_linux)
25 config("opus_config") {
26 include_dirs = [ "src/include" ]
30 action("convert_rtcd_assembler") {
31 script = "convert_rtcd_assembler.py"
33 "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S",
36 rebase_path("//third_party/opus/src/celt/arm/arm2gnu.pl", root_build_dir),
37 rebase_path("//third_party/opus/src/celt/arm/celt_pitch_xcorr_arm.s",
39 rebase_path("$target_gen_dir/celt_pitch_xcorr_arm_gnu.S", root_build_dir),
45 gypi_values = exec_script("//build/gypi_to_gn.py",
46 [ rebase_path("opus_srcs.gypi") ],
49 sources = gypi_values.opus_common_sources
61 configs -= [ "//build/config/compiler:chromium_code" ]
62 configs += [ "//build/config/compiler:no_chromium_code" ]
63 public_configs = [ ":opus_config" ]
72 "/wd4305", # Disable truncation warning in celt/pitch.c .
73 "/wd4334", # Disable 32-bit shift warning in src/opus_encoder.c .
83 if (is_posix && !is_android) {
84 # Suppress a warning given by opus_decoder.c that tells us
85 # optimizations are turned off.
86 cflags = [ "-Wno-#pragma-messages" ]
89 if (!is_debug && is_posix && (cpu_arch == "arm" || cpu_arch == "arm64")) {
90 configs -= [ "//build/config/compiler:optimize" ]
91 configs += [ "//build/config/compiler:optimize_max" ]
94 if (use_opus_fixed_point) {
95 sources += gypi_values.opus_fixed_sources
97 defines += [ "FIXED_POINT" ]
99 include_dirs += [ "src/silk/fixed" ]
101 sources += gypi_values.opus_float_sources
103 include_dirs += [ "src/silk/float" ]
106 if (use_opus_arm_optimization) {
108 "src/celt/arm/fixed_armv4.h",
109 "src/celt/arm/fixed_armv5e.h",
110 "src/celt/arm/kiss_fft_armv4.h",
111 "src/celt/arm/kiss_fft_armv5e.h",
112 "src/celt/pitch_arm.h",
113 "src/silk/arm/macro_armv4.h",
114 "src/silk/arm/macro_armv5e.h",
115 "src/silk/arm/SigProc_FIX_armv4.h",
116 "src/silk/arm/SigProc_FIX_armv5e.h",
121 "OPUS_ARM_INLINE_ASM",
122 "OPUS_ARM_INLINE_EDSP",
127 "src/celt/arm/arm_celt_map.c",
128 "src/celt/arm/armcpu.c",
129 "src/celt/arm/armcpu.h",
130 "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S",
134 "OPUS_ARM_MAY_HAVE_EDSP",
135 "OPUS_ARM_MAY_HAVE_MEDIA",
136 "OPUS_ARM_MAY_HAVE_NEON",
141 ":convert_rtcd_assembler",
146 if (use_opus_mips_optimization) {
148 "src/celt/mips/celt_mipsr1.h",
149 "src/celt/mips/fixed_generic_mipsr1.h",
150 "src/celt/mips/kiss_fft_mipsr1.h",
151 "src/celt/mips/mdct_mipsr1.h",
152 "src/celt/mips/pitch_mipsr1.h",
153 "src/celt/mips/vq_mipsr1.c",
154 "src/celt/mips/vq_mipsr1.h",
155 "src/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h",
156 "src/silk/fixed/mips/prefilter_FIX_mipsr1.h",
157 "src/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h",
158 "src/silk/mips/NSQ_del_dec_mipsr1.h",
159 "src/silk/mips/macros_mipsr1.h",
160 "src/silk/mips/sigproc_fix_mipsr1.h",
170 executable("opus_compare") {
172 "src/src/opus_compare.c",
175 configs -= [ "//build/config/compiler:chromium_code" ]
176 configs += [ "//build/config/compiler:no_chromium_code" ]
184 defines = [ "inline=__inline" ]
190 cflags = [ "-Wno-absolute-value" ]
198 executable("opus_demo") {
200 "src/src/opus_demo.c",
203 configs -= [ "//build/config/compiler:chromium_code" ]
204 configs += [ "//build/config/compiler:no_chromium_code" ]
212 defines = [ "inline=__inline" ]
218 cflags = [ "-Wno-absolute-value" ]