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