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 # TODO(scottmg): Disabled on Fuchsia for now, see https://crbug.com/775272.
13 use_opus_arm_optimization =
14 current_cpu == "arm" || (current_cpu == "arm64" && is_ios)
16 # If OPUS Run Time CPU Detections (RTCD) shall be used.
17 # Based on the conditions in celt/arm/armcpu.c:
18 # defined(_MSC_VER) || defined(__linux__).
19 use_opus_rtcd = current_cpu == "arm" && (is_win || is_android || is_linux ||
22 config("opus_config") {
23 include_dirs = [ "src/include" ]
25 if (use_opus_fixed_point) {
26 defines = [ "OPUS_FIXED_POINT" ]
30 config("opus_test_config") {
37 defines = [ "inline=__inline" ]
43 cflags = [ "-Wno-absolute-value" ]
48 action("convert_rtcd_assembler") {
49 script = "convert_rtcd_assembler.py"
51 "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S",
54 rebase_path("//third_party/opus/src/celt/arm/arm2gnu.pl", root_build_dir),
55 rebase_path("//third_party/opus/src/celt/arm/celt_pitch_xcorr_arm.s",
57 rebase_path("$target_gen_dir/celt_pitch_xcorr_arm_gnu.S", root_build_dir),
62 static_library("opus") {
64 "src/celt/_kiss_fft_guts.h",
70 "src/celt/celt_decoder.c",
71 "src/celt/celt_encoder.c",
72 "src/celt/celt_lpc.c",
73 "src/celt/celt_lpc.h",
74 "src/celt/cpu_support.h",
77 "src/celt/ecintrin.h",
84 "src/celt/fixed_debug.h",
85 "src/celt/fixed_generic.h",
86 "src/celt/float_cast.h",
87 "src/celt/kiss_fft.c",
88 "src/celt/kiss_fft.h",
95 "src/celt/mfrngcod.h",
98 "src/celt/os_support.h",
101 "src/celt/quant_bands.c",
102 "src/celt/quant_bands.h",
105 "src/celt/stack_alloc.h",
106 "src/celt/static_modes_fixed.h",
107 "src/celt/static_modes_float.h",
110 "src/include/opus.h",
111 "src/include/opus_custom.h",
112 "src/include/opus_defines.h",
113 "src/include/opus_multistream.h",
114 "src/include/opus_types.h",
118 "src/silk/HP_variable_cutoff.c",
119 "src/silk/Inlines.h",
120 "src/silk/LPC_analysis_filter.c",
121 "src/silk/LPC_fit.c",
122 "src/silk/LPC_inv_pred_gain.c",
123 "src/silk/LP_variable_cutoff.c",
124 "src/silk/MacroCount.h",
125 "src/silk/MacroDebug.h",
127 "src/silk/NLSF_VQ.c",
128 "src/silk/NLSF_VQ_weights_laroia.c",
129 "src/silk/NLSF_decode.c",
130 "src/silk/NLSF_del_dec_quant.c",
131 "src/silk/NLSF_encode.c",
132 "src/silk/NLSF_stabilize.c",
133 "src/silk/NLSF_unpack.c",
136 "src/silk/NSQ_del_dec.c",
139 "src/silk/SigProc_FIX.h",
141 "src/silk/VQ_WMat_EC.c",
142 "src/silk/ana_filt_bank_1.c",
143 "src/silk/biquad_alt.c",
144 "src/silk/bwexpander.c",
145 "src/silk/bwexpander_32.c",
146 "src/silk/check_control_input.c",
147 "src/silk/code_signs.c",
148 "src/silk/control.h",
149 "src/silk/control_SNR.c",
150 "src/silk/control_audio_bandwidth.c",
151 "src/silk/control_codec.c",
154 "src/silk/dec_API.c",
155 "src/silk/decode_core.c",
156 "src/silk/decode_frame.c",
157 "src/silk/decode_indices.c",
158 "src/silk/decode_parameters.c",
159 "src/silk/decode_pitch.c",
160 "src/silk/decode_pulses.c",
161 "src/silk/decoder_set_fs.c",
163 "src/silk/enc_API.c",
164 "src/silk/encode_indices.c",
165 "src/silk/encode_pulses.c",
167 "src/silk/gain_quant.c",
168 "src/silk/init_decoder.c",
169 "src/silk/init_encoder.c",
170 "src/silk/inner_prod_aligned.c",
171 "src/silk/interpolate.c",
172 "src/silk/lin2log.c",
173 "src/silk/log2lin.c",
176 "src/silk/pitch_est_defines.h",
177 "src/silk/pitch_est_tables.c",
178 "src/silk/process_NLSFs.c",
179 "src/silk/quant_LTP_gains.c",
180 "src/silk/resampler.c",
181 "src/silk/resampler_down2.c",
182 "src/silk/resampler_down2_3.c",
183 "src/silk/resampler_private.h",
184 "src/silk/resampler_private_AR2.c",
185 "src/silk/resampler_private_IIR_FIR.c",
186 "src/silk/resampler_private_down_FIR.c",
187 "src/silk/resampler_private_up2_HQ.c",
188 "src/silk/resampler_rom.c",
189 "src/silk/resampler_rom.h",
190 "src/silk/resampler_structs.h",
191 "src/silk/shell_coder.c",
192 "src/silk/sigm_Q15.c",
194 "src/silk/stereo_LR_to_MS.c",
195 "src/silk/stereo_MS_to_LR.c",
196 "src/silk/stereo_decode_pred.c",
197 "src/silk/stereo_encode_pred.c",
198 "src/silk/stereo_find_predictor.c",
199 "src/silk/stereo_quant_pred.c",
200 "src/silk/structs.h",
201 "src/silk/sum_sqr_shift.c",
202 "src/silk/table_LSF_cos.c",
204 "src/silk/tables_LTP.c",
205 "src/silk/tables_NLSF_CB_NB_MB.c",
206 "src/silk/tables_NLSF_CB_WB.c",
207 "src/silk/tables_gain.c",
208 "src/silk/tables_other.c",
209 "src/silk/tables_pitch_lag.c",
210 "src/silk/tables_pulses_per_block.c",
211 "src/silk/tuning_parameters.h",
212 "src/silk/typedef.h",
213 "src/src/analysis.c",
214 "src/src/analysis.h",
217 "src/src/mlp_data.c",
219 "src/src/opus_decoder.c",
220 "src/src/opus_encoder.c",
221 "src/src/opus_multistream.c",
222 "src/src/opus_multistream_decoder.c",
223 "src/src/opus_multistream_encoder.c",
224 "src/src/repacketizer.c",
225 "src/src/tansig_table.h",
239 configs -= [ "//build/config/compiler:chromium_code" ]
240 configs += [ "//build/config/compiler:no_chromium_code" ]
241 public_configs = [ ":opus_config" ]
251 "/wd4305", # Disable truncation warning in celt/pitch.c .
252 "/wd4334", # Disable 32-bit shift warning in src/opus_encoder.c .
263 # Turn off a warning in opus_decoder.c when compiling without optimization.
264 defines += [ "OPUS_WILL_BE_SLOW" ]
267 if (!is_debug && (current_cpu == "arm" || current_cpu == "arm64")) {
268 configs -= [ "//build/config/compiler:default_optimization" ]
270 # TODO(crbug.com/621335) Rework this so that we don't have the confusion
271 # between "optimize_speed" and "optimize_max".
272 configs += [ "//build/config/compiler:optimize_speed" ]
275 if (use_opus_fixed_point) {
277 "src/silk/fixed/LTP_analysis_filter_FIX.c",
278 "src/silk/fixed/LTP_scale_ctrl_FIX.c",
279 "src/silk/fixed/apply_sine_window_FIX.c",
280 "src/silk/fixed/autocorr_FIX.c",
281 "src/silk/fixed/burg_modified_FIX.c",
282 "src/silk/fixed/corrMatrix_FIX.c",
283 "src/silk/fixed/encode_frame_FIX.c",
284 "src/silk/fixed/find_LPC_FIX.c",
285 "src/silk/fixed/find_LTP_FIX.c",
286 "src/silk/fixed/find_pitch_lags_FIX.c",
287 "src/silk/fixed/find_pred_coefs_FIX.c",
288 "src/silk/fixed/k2a_FIX.c",
289 "src/silk/fixed/k2a_Q16_FIX.c",
290 "src/silk/fixed/main_FIX.h",
291 "src/silk/fixed/noise_shape_analysis_FIX.c",
292 "src/silk/fixed/pitch_analysis_core_FIX.c",
293 "src/silk/fixed/process_gains_FIX.c",
294 "src/silk/fixed/regularize_correlations_FIX.c",
295 "src/silk/fixed/residual_energy16_FIX.c",
296 "src/silk/fixed/residual_energy_FIX.c",
297 "src/silk/fixed/schur64_FIX.c",
298 "src/silk/fixed/schur_FIX.c",
299 "src/silk/fixed/structs_FIX.h",
300 "src/silk/fixed/vector_ops_FIX.c",
301 "src/silk/fixed/warped_autocorrelation_FIX.c",
304 defines += [ "FIXED_POINT" ]
306 include_dirs += [ "src/silk/fixed" ]
309 "src/silk/float/LPC_analysis_filter_FLP.c",
310 "src/silk/float/LPC_inv_pred_gain_FLP.c",
311 "src/silk/float/LTP_analysis_filter_FLP.c",
312 "src/silk/float/LTP_scale_ctrl_FLP.c",
313 "src/silk/float/SigProc_FLP.h",
314 "src/silk/float/apply_sine_window_FLP.c",
315 "src/silk/float/autocorrelation_FLP.c",
316 "src/silk/float/burg_modified_FLP.c",
317 "src/silk/float/bwexpander_FLP.c",
318 "src/silk/float/corrMatrix_FLP.c",
319 "src/silk/float/encode_frame_FLP.c",
320 "src/silk/float/energy_FLP.c",
321 "src/silk/float/find_LPC_FLP.c",
322 "src/silk/float/find_LTP_FLP.c",
323 "src/silk/float/find_pitch_lags_FLP.c",
324 "src/silk/float/find_pred_coefs_FLP.c",
325 "src/silk/float/inner_product_FLP.c",
326 "src/silk/float/k2a_FLP.c",
327 "src/silk/float/main_FLP.h",
328 "src/silk/float/noise_shape_analysis_FLP.c",
329 "src/silk/float/pitch_analysis_core_FLP.c",
330 "src/silk/float/process_gains_FLP.c",
331 "src/silk/float/regularize_correlations_FLP.c",
332 "src/silk/float/residual_energy_FLP.c",
333 "src/silk/float/scale_copy_vector_FLP.c",
334 "src/silk/float/scale_vector_FLP.c",
335 "src/silk/float/schur_FLP.c",
336 "src/silk/float/sort_FLP.c",
337 "src/silk/float/structs_FLP.h",
338 "src/silk/float/warped_autocorrelation_FLP.c",
339 "src/silk/float/wrappers_FLP.c",
342 include_dirs += [ "src/silk/float" ]
345 if (use_opus_arm_optimization) {
347 "src/celt/arm/fixed_arm64.h",
348 "src/celt/arm/fixed_armv4.h",
349 "src/celt/arm/fixed_armv5e.h",
350 "src/celt/arm/kiss_fft_armv4.h",
351 "src/celt/arm/kiss_fft_armv5e.h",
352 "src/celt/arm/pitch_arm.h",
353 "src/silk/arm/SigProc_FIX_armv4.h",
354 "src/silk/arm/SigProc_FIX_armv5e.h",
355 "src/silk/arm/macros_arm64.h",
356 "src/silk/arm/macros_armv4.h",
357 "src/silk/arm/macros_armv5e.h",
360 if (current_cpu == "arm") {
363 "OPUS_ARM_INLINE_ASM",
364 "OPUS_ARM_INLINE_EDSP",
370 "$target_gen_dir/celt_pitch_xcorr_arm_gnu.S",
371 "src/celt/arm/arm_celt_map.c",
372 "src/celt/arm/armcpu.c",
373 "src/celt/arm/armcpu.h",
374 "src/celt/arm/fft_arm.h",
375 "src/celt/arm/mdct_arm.h",
376 "src/celt/arm/pitch_arm.h",
377 "src/silk/arm/arm_silk_map.c",
381 "OPUS_ARM_MAY_HAVE_EDSP",
382 "OPUS_ARM_MAY_HAVE_MEDIA",
387 ":convert_rtcd_assembler",
393 "src/celt/arm/celt_neon_intr.c",
394 "src/celt/arm/pitch_neon_intr.c",
395 "src/silk/arm/LPC_inv_pred_gain_arm.h",
396 "src/silk/arm/LPC_inv_pred_gain_neon_intr.c",
397 "src/silk/arm/NSQ_del_dec_arm.h",
398 "src/silk/arm/NSQ_del_dec_neon_intr.c",
399 "src/silk/arm/NSQ_neon.c",
400 "src/silk/arm/NSQ_neon.h",
401 "src/silk/arm/biquad_alt_arm.h",
402 "src/silk/arm/biquad_alt_neon_intr.c",
403 "src/silk/fixed/arm/warped_autocorrelation_FIX_arm.h",
404 "src/silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c",
408 "OPUS_ARM_MAY_HAVE_NEON",
409 "OPUS_ARM_MAY_HAVE_NEON_INTR",
413 if (is_ios && current_cpu == "arm64") {
414 # Runtime detection of CPU features not available on iOS.
416 "OPUS_ARM_PRESUME_NEON_INTR",
417 "OPUS_ARM_PRESUME_AARCH64_NEON_INTR",
423 executable("opus_compare") {
425 "src/src/opus_compare.c",
428 configs -= [ "//build/config/compiler:chromium_code" ]
430 "//build/config/compiler:no_chromium_code",
436 "//build/config:exe_and_shlib_deps",
437 "//build/win:default_exe_manifest",
441 executable("opus_demo") {
443 "src/src/opus_demo.c",
446 configs -= [ "//build/config/compiler:chromium_code" ]
448 "//build/config/compiler:no_chromium_code",
454 "//build/config:exe_and_shlib_deps",
455 "//build/win:default_exe_manifest",
459 test("test_opus_api") {
461 "src/tests/test_opus_api.c",
464 configs -= [ "//build/config/compiler:chromium_code" ]
466 "//build/config/compiler:no_chromium_code",
475 test("test_opus_encode") {
477 "src/tests/opus_encode_regressions.c",
478 "src/tests/test_opus_encode.c",
481 configs -= [ "//build/config/compiler:chromium_code" ]
483 "//build/config/compiler:no_chromium_code",
492 # GN orders flags on a target before flags from configs. The default config
493 # adds -Wall, and this flag have to be after -Wall -- so they need to
494 # come from a config and can't be on the target directly.
495 config("test_opus_decode_config") {
496 # test_opus_decode passes a null pointer to opus_decode() for an argument
497 # marked as requiring a non-null value by the nonnull function attribute,
498 # and expects opus_decode() to fail. Disable the -Wnonnull option to avoid
499 # a compilation error if -Werror is specified.
501 cflags = [ "-Wno-nonnull" ]
505 test("test_opus_decode") {
507 "src/tests/test_opus_decode.c",
510 configs -= [ "//build/config/compiler:chromium_code" ]
512 "//build/config/compiler:no_chromium_code",
514 ":test_opus_decode_config",
522 test("test_opus_padding") {
524 "src/tests/test_opus_padding.c",
527 configs -= [ "//build/config/compiler:chromium_code" ]
529 "//build/config/compiler:no_chromium_code",