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:optimize" ]
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/macro_armv4.h",
126 "src/silk/arm/macro_armv5e.h",
127 "src/silk/arm/SigProc_FIX_armv4.h",
128 "src/silk/arm/SigProc_FIX_armv5e.h",
133 "OPUS_ARM_INLINE_ASM",
134 "OPUS_ARM_INLINE_EDSP",
139 "src/celt/arm/arm_celt_map.c",
140 "src/celt/arm/armcpu.c",
141 "src/celt/arm/armcpu.h",
142 "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S",
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",
175 executable("opus_demo") {
177 "src/src/opus_demo.c",
180 configs -= [ "//build/config/compiler:chromium_code" ]
182 "//build/config/compiler:no_chromium_code",
191 test("test_opus_api") {
193 "src/tests/test_opus_api.c",
196 configs -= [ "//build/config/compiler:chromium_code" ]
198 "//build/config/compiler:no_chromium_code",
207 test("test_opus_encode") {
209 "src/tests/test_opus_encode.c",
212 configs -= [ "//build/config/compiler:chromium_code" ]
214 "//build/config/compiler:no_chromium_code",
223 test("test_opus_decode") {
225 "src/tests/test_opus_decode.c",
228 configs -= [ "//build/config/compiler:chromium_code" ]
230 "//build/config/compiler:no_chromium_code",
234 # test_opus_decode passes a null pointer to opus_decode() for an argument
235 # marked as requiring a non-null value by the nonnull function attribute,
236 # and expects opus_decode() to fail. Disable the -Wnonnull option to avoid
237 # a compilation error if -Werror is specified.
239 cflags = [ "-Wno-nonnull" ]
247 test("test_opus_padding") {
249 "src/tests/test_opus_padding.c",
252 configs -= [ "//build/config/compiler:chromium_code" ]
254 "//build/config/compiler:no_chromium_code",