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("//testing/test.gni")
8 # If fixed point implementation shall be used (otherwise float).
9 use_opus_fixed_point = current_cpu == "arm" || current_cpu == "arm64"
11 # If ARM optimizations shall be used to accelerate performance.
12 use_opus_arm_optimization = current_cpu == "arm"
14 # If OPUS Run Time CPU Detections (RTCD) shall be used.
15 # Based on the conditions in celt/arm/armcpu.c:
16 # defined(_MSC_VER) || defined(__linux__).
17 use_opus_rtcd = current_cpu == "arm" && (is_win || is_android || is_linux)
19 config("opus_config") {
20 include_dirs = [ "src/include" ]
23 config("opus_test_config") {
30 defines = [ "inline=__inline" ]
36 cflags = [ "-Wno-absolute-value" ]
41 action("convert_rtcd_assembler") {
42 script = "convert_rtcd_assembler.py"
44 "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S",
47 rebase_path("//third_party/opus/src/celt/arm/arm2gnu.pl", root_build_dir),
48 rebase_path("//third_party/opus/src/celt/arm/celt_pitch_xcorr_arm.s",
50 rebase_path("$target_gen_dir/celt_pitch_xcorr_arm_gnu.S", root_build_dir),
56 gypi_values = exec_script("//build/gypi_to_gn.py",
57 [ rebase_path("opus_srcs.gypi") ],
60 sources = gypi_values.opus_common_sources
72 configs -= [ "//build/config/compiler:chromium_code" ]
73 configs += [ "//build/config/compiler:no_chromium_code" ]
74 public_configs = [ ":opus_config" ]
83 "/wd4305", # Disable truncation warning in celt/pitch.c .
84 "/wd4334", # Disable 32-bit shift warning in src/opus_encoder.c .
94 if (is_posix && !is_android) {
95 # Suppress a warning given by opus_decoder.c that tells us
96 # optimizations are turned off.
97 cflags = [ "-Wno-#pragma-messages" ]
100 if (!is_debug && is_posix &&
101 (current_cpu == "arm" || current_cpu == "arm64")) {
102 configs -= [ "//build/config/compiler:default_optimization" ]
103 configs += [ "//build/config/compiler:optimize_max" ]
106 if (use_opus_fixed_point) {
107 sources += gypi_values.opus_fixed_sources
109 defines += [ "FIXED_POINT" ]
111 include_dirs += [ "src/silk/fixed" ]
113 sources += gypi_values.opus_float_sources
115 include_dirs += [ "src/silk/float" ]
118 if (use_opus_arm_optimization) {
120 "src/celt/arm/fixed_armv4.h",
121 "src/celt/arm/fixed_armv5e.h",
122 "src/celt/arm/kiss_fft_armv4.h",
123 "src/celt/arm/kiss_fft_armv5e.h",
124 "src/celt/pitch_arm.h",
125 "src/silk/arm/SigProc_FIX_armv4.h",
126 "src/silk/arm/SigProc_FIX_armv5e.h",
127 "src/silk/arm/macro_armv4.h",
128 "src/silk/arm/macro_armv5e.h",
133 "OPUS_ARM_INLINE_ASM",
134 "OPUS_ARM_INLINE_EDSP",
139 "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S",
140 "src/celt/arm/arm_celt_map.c",
141 "src/celt/arm/armcpu.c",
142 "src/celt/arm/armcpu.h",
146 "OPUS_ARM_MAY_HAVE_EDSP",
147 "OPUS_ARM_MAY_HAVE_MEDIA",
148 "OPUS_ARM_MAY_HAVE_NEON",
153 ":convert_rtcd_assembler",
159 executable("opus_compare") {
161 "src/src/opus_compare.c",
164 configs -= [ "//build/config/compiler:chromium_code" ]
166 "//build/config/compiler:no_chromium_code",
172 "//build/config/sanitizers:deps",
176 executable("opus_demo") {
178 "src/src/opus_demo.c",
181 configs -= [ "//build/config/compiler:chromium_code" ]
183 "//build/config/compiler:no_chromium_code",
189 "//build/config/sanitizers:deps",
193 test("test_opus_api") {
195 "src/tests/test_opus_api.c",
198 configs -= [ "//build/config/compiler:chromium_code" ]
200 "//build/config/compiler:no_chromium_code",
209 test("test_opus_encode") {
211 "src/tests/test_opus_encode.c",
214 configs -= [ "//build/config/compiler:chromium_code" ]
216 "//build/config/compiler:no_chromium_code",
225 test("test_opus_decode") {
227 "src/tests/test_opus_decode.c",
230 configs -= [ "//build/config/compiler:chromium_code" ]
232 "//build/config/compiler:no_chromium_code",
236 # test_opus_decode passes a null pointer to opus_decode() for an argument
237 # marked as requiring a non-null value by the nonnull function attribute,
238 # and expects opus_decode() to fail. Disable the -Wnonnull option to avoid
239 # a compilation error if -Werror is specified.
241 cflags = [ "-Wno-nonnull" ]
249 test("test_opus_padding") {
251 "src/tests/test_opus_padding.c",
254 configs -= [ "//build/config/compiler:chromium_code" ]
256 "//build/config/compiler:no_chromium_code",