• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    default_applicable_licenses: ["external_libopus_license"],
3}
4
5// Added automatically by a large-scale-change that took the approach of
6// 'apply every license found to every target'. While this makes sure we respect
7// every license restriction, it may not be entirely correct.
8//
9// e.g. GPL in an MIT project might only apply to the contrib/ directory.
10//
11// Please consider splitting the single license below into multiple licenses,
12// taking care not to lose any license_kind information, and overriding the
13// default license using the 'licenses: [...]' property on targets as needed.
14//
15// For unused files, consider creating a 'filegroup' with "//visibility:private"
16// to attach the license to, and including a comment whether the files may be
17// used in the current project.
18//
19// large-scale-change included anything that looked like it might be a license
20// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
21//
22// Please consider removing redundant or irrelevant files from 'license_text:'.
23// http://go/android-license-faq
24license {
25    name: "external_libopus_license",
26    visibility: [":__subpackages__"],
27    license_kinds: [
28        "SPDX-license-identifier-Apache-2.0",
29        "SPDX-license-identifier-BSD",
30    ],
31    license_text: [
32        "COPYING",
33        "NOTICE",
34    ],
35}
36
37cc_library {
38    name: "libopus",
39    vendor_available: true,
40    host_supported: true,
41
42    export_include_dirs: ["include"],
43
44    local_include_dirs: [
45        "src",
46        "silk",
47        "celt",
48        "silk/fixed",
49    ],
50
51    sanitize: {
52        integer_overflow: true,
53        misc_undefined: ["bounds"],
54        blocklist: "libopus_blocklist.txt",
55    },
56
57    srcs: [
58        // CELT_SOURCES
59        "celt/bands.c",
60        "celt/celt.c",
61        "celt/celt_encoder.c",
62        "celt/celt_decoder.c",
63        "celt/cwrs.c",
64        "celt/entcode.c",
65        "celt/entdec.c",
66        "celt/entenc.c",
67        "celt/kiss_fft.c",
68        "celt/laplace.c",
69        "celt/mathops.c",
70        "celt/mdct.c",
71        "celt/modes.c",
72        "celt/pitch.c",
73        "celt/celt_lpc.c",
74        "celt/quant_bands.c",
75        "celt/rate.c",
76        "celt/vq.c",
77
78        // SILK_SOURCES
79        "silk/CNG.c",
80        "silk/code_signs.c",
81        "silk/init_decoder.c",
82        "silk/decode_core.c",
83        "silk/decode_frame.c",
84        "silk/decode_parameters.c",
85        "silk/decode_indices.c",
86        "silk/decode_pulses.c",
87        "silk/decoder_set_fs.c",
88        "silk/dec_API.c",
89        "silk/enc_API.c",
90        "silk/encode_indices.c",
91        "silk/encode_pulses.c",
92        "silk/gain_quant.c",
93        "silk/interpolate.c",
94        "silk/LP_variable_cutoff.c",
95        "silk/NLSF_decode.c",
96        "silk/NSQ.c",
97        "silk/NSQ_del_dec.c",
98        "silk/PLC.c",
99        "silk/shell_coder.c",
100        "silk/tables_gain.c",
101        "silk/tables_LTP.c",
102        "silk/tables_NLSF_CB_NB_MB.c",
103        "silk/tables_NLSF_CB_WB.c",
104        "silk/tables_other.c",
105        "silk/tables_pitch_lag.c",
106        "silk/tables_pulses_per_block.c",
107        "silk/VAD.c",
108        "silk/control_audio_bandwidth.c",
109        "silk/quant_LTP_gains.c",
110        "silk/VQ_WMat_EC.c",
111        "silk/HP_variable_cutoff.c",
112        "silk/NLSF_encode.c",
113        "silk/NLSF_VQ.c",
114        "silk/NLSF_unpack.c",
115        "silk/NLSF_del_dec_quant.c",
116        "silk/process_NLSFs.c",
117        "silk/stereo_LR_to_MS.c",
118        "silk/stereo_MS_to_LR.c",
119        "silk/check_control_input.c",
120        "silk/control_SNR.c",
121        "silk/init_encoder.c",
122        "silk/control_codec.c",
123        "silk/A2NLSF.c",
124        "silk/ana_filt_bank_1.c",
125        "silk/biquad_alt.c",
126        "silk/bwexpander_32.c",
127        "silk/bwexpander.c",
128        "silk/debug.c",
129        "silk/decode_pitch.c",
130        "silk/inner_prod_aligned.c",
131        "silk/lin2log.c",
132        "silk/log2lin.c",
133        "silk/LPC_analysis_filter.c",
134        "silk/LPC_fit.c",
135        "silk/LPC_inv_pred_gain.c",
136        "silk/table_LSF_cos.c",
137        "silk/NLSF2A.c",
138        "silk/NLSF_stabilize.c",
139        "silk/NLSF_VQ_weights_laroia.c",
140        "silk/pitch_est_tables.c",
141        "silk/resampler.c",
142        "silk/resampler_down2_3.c",
143        "silk/resampler_down2.c",
144        "silk/resampler_private_AR2.c",
145        "silk/resampler_private_down_FIR.c",
146        "silk/resampler_private_IIR_FIR.c",
147        "silk/resampler_private_up2_HQ.c",
148        "silk/resampler_rom.c",
149        "silk/sigm_Q15.c",
150        "silk/sort.c",
151        "silk/sum_sqr_shift.c",
152        "silk/stereo_decode_pred.c",
153        "silk/stereo_encode_pred.c",
154        "silk/stereo_find_predictor.c",
155        "silk/stereo_quant_pred.c",
156
157        // SILK_SOURCES_FIXED
158        "silk/fixed/LTP_analysis_filter_FIX.c",
159        "silk/fixed/LTP_scale_ctrl_FIX.c",
160        "silk/fixed/corrMatrix_FIX.c",
161        "silk/fixed/encode_frame_FIX.c",
162        "silk/fixed/find_LPC_FIX.c",
163        "silk/fixed/find_LTP_FIX.c",
164        "silk/fixed/find_pitch_lags_FIX.c",
165        "silk/fixed/find_pred_coefs_FIX.c",
166        "silk/fixed/noise_shape_analysis_FIX.c",
167        "silk/fixed/process_gains_FIX.c",
168        "silk/fixed/regularize_correlations_FIX.c",
169        "silk/fixed/residual_energy16_FIX.c",
170        "silk/fixed/residual_energy_FIX.c",
171        "silk/fixed/warped_autocorrelation_FIX.c",
172        "silk/fixed/apply_sine_window_FIX.c",
173        "silk/fixed/autocorr_FIX.c",
174        "silk/fixed/burg_modified_FIX.c",
175        "silk/fixed/k2a_FIX.c",
176        "silk/fixed/k2a_Q16_FIX.c",
177        "silk/fixed/pitch_analysis_core_FIX.c",
178        "silk/fixed/vector_ops_FIX.c",
179        "silk/fixed/schur64_FIX.c",
180        "silk/fixed/schur_FIX.c",
181
182        // OPUS_SOURCES
183        "src/mapping_matrix.c",
184        "src/opus.c",
185        "src/opus_decoder.c",
186        "src/opus_encoder.c",
187        "src/opus_multistream.c",
188        "src/opus_multistream_encoder.c",
189        "src/opus_multistream_decoder.c",
190        "src/opus_projection_encoder.c",
191        "src/opus_projection_decoder.c",
192        "src/repacketizer.c",
193
194        // OPUS_SOURCES_FLOAT
195        "src/analysis.c",
196        "src/mlp.c",
197        "src/mlp_data.c",
198    ],
199
200    cflags: [
201        "-DNULL=0",
202        "-DSOCKLEN_T=socklen_t",
203        "-DLOCALE_NOT_USED",
204        "-D_LARGEFILE_SOURCE=1",
205        "-D_FILE_OFFSET_BITS=64",
206        "-Drestrict=",
207        "-D__EMX__",
208        "-DOPUS_BUILD",
209        "-DFIXED_POINT",
210        "-DUSE_ALLOCA",
211        "-DSIMD_EXTRA_ALLOC_BYTES=16",
212        "-DHAVE_LRINT",
213        "-DHAVE_LRINTF",
214        "-DENABLE_HARDENING",
215        "-O2",
216        "-fno-math-errno",
217        "-Wall",
218        "-Werror",
219    ],
220    cppflags: [
221        "-DBSD=1",
222        "-ffast-math",
223        "-O2",
224        "-funroll-loops",
225    ],
226
227    arch: {
228        arm: {
229            srcs: [
230                // CELT_SOURCES_ARM
231                "celt/arm/armcpu.c",
232                "celt/arm/arm_celt_map.c",
233
234                // DSP, MEDIA and NEON instructions are in the same assembler
235                // file - thus we need to include it even if NEON is not
236                // supported on target platform.
237                // CELT_SOURCES_ARM_ASM
238                "celt/arm/celt_pitch_xcorr_arm_gnu.s",
239
240                // CELT_AM_SOURCES_ARM_ASM
241                "celt/arm/armopts_gnu.s",
242            ],
243
244            cflags: [
245                "-DOPUS_ARM_ASM",
246                "-DOPUS_ARM_INLINE_ASM",
247                "-DOPUS_ARM_MAY_HAVE_EDSP",
248                "-DOPUS_ARM_INLINE_EDSP",
249                "-DOPUS_ARM_MAY_HAVE_MEDIA",
250                "-DOPUS_ARM_INLINE_MEDIA",
251                "-DOPUS_ARM_MAY_HAVE_NEON",
252                "-DOPUS_HAVE_RTCD",
253            ],
254
255            // Note: OPUS enhanced DSP/NEON implementation is not yet
256            // compatible with arm64.  Only add the appropriate defines for
257            // 32-bit arm architecture.
258            neon: {
259                srcs: [
260                    // CELT_SOURCES_ARM_NEON_INTR
261                    "celt/arm/celt_neon_intr.c",
262                    "celt/arm/pitch_neon_intr.c",
263
264                    // SILK_SOURCES_ARM_NEON_INTR,
265                    "silk/arm/arm_silk_map.c",
266                    "silk/arm/biquad_alt_neon_intr.c",
267                    "silk/arm/LPC_inv_pred_gain_neon_intr.c",
268                    "silk/arm/NSQ_del_dec_neon_intr.c",
269                    "silk/arm/NSQ_neon.c",
270
271                    // SILK_SOURCES_FIXED_ARM_NEON_INTR,
272                    "silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c",
273                ],
274
275                cflags: [
276                    "-DOPUS_ARM_MAY_HAVE_NEON",
277                    "-DOPUS_ARM_MAY_HAVE_NEON_INTR",
278                    "-DOPUS_ARM_PRESUME_NEON",
279                    "-DOPUS_ARM_INLINE_NEON",
280                ],
281            },
282
283        },
284
285        x86: {
286            ssse3: {
287                srcs: [
288                    // CELT_SOURCES_SSE
289                    "celt/x86/x86cpu.c",
290                    "celt/x86/x86_celt_map.c",
291                    "celt/x86/pitch_sse.c",
292
293                    // CELT_SOURCES_SSE2
294                    "celt/x86/pitch_sse2.c",
295                    "celt/x86/vq_sse2.c",
296                ],
297
298                cflags: [
299                    "-DOPUS_X86_MAY_HAVE_SSE",
300                    "-DOPUS_X86_PRESUME_SSE",
301                    "-DOPUS_X86_MAY_HAVE_SSE2",
302                    "-DOPUS_X86_PRESUME_SSE2",
303                ],
304            },
305
306            sse4_1: {
307                srcs: [
308                    // CELT_SOURCES_SSE4_1
309                    "celt/x86/celt_lpc_sse4_1.c",
310                    "celt/x86/pitch_sse4_1.c",
311
312                    // SILK_SOURCES_SSE4_1
313                    "silk/x86/NSQ_sse4_1.c",
314                    "silk/x86/NSQ_del_dec_sse4_1.c",
315                    "silk/x86/x86_silk_map.c",
316                    "silk/x86/VAD_sse4_1.c",
317                    "silk/x86/VQ_WMat_EC_sse4_1.c",
318
319                    // SILK_SOURCES_FIXED_SSE4_1
320                    "silk/fixed/x86/vector_ops_FIX_sse4_1.c",
321                    "silk/fixed/x86/burg_modified_FIX_sse4_1.c",
322                ],
323
324                cflags: [
325                    "-DOPUS_X86_MAY_HAVE_SSE4_1",
326                    "-DOPUS_X86_PRESUME_SSE4_1",
327                ],
328            },
329        },
330
331        x86_64: {
332            ssse3: {
333                srcs: [
334                    // CELT_SOURCES_SSE
335                    "celt/x86/x86cpu.c",
336                    "celt/x86/x86_celt_map.c",
337                    "celt/x86/pitch_sse.c",
338
339                    // CELT_SOURCES_SSE2
340                    "celt/x86/pitch_sse2.c",
341                    "celt/x86/vq_sse2.c",
342                ],
343
344                cflags: [
345                    "-DOPUS_X86_MAY_HAVE_SSE",
346                    "-DOPUS_X86_PRESUME_SSE",
347                    "-DOPUS_X86_MAY_HAVE_SSE2",
348                    "-DOPUS_X86_PRESUME_SSE2",
349                ],
350            },
351
352            sse4_1: {
353                srcs: [
354                    // CELT_SOURCES_SSE4_1
355                    "celt/x86/celt_lpc_sse4_1.c",
356                    "celt/x86/pitch_sse4_1.c",
357
358                    // SILK_SOURCES_SSE4_1
359                    "silk/x86/NSQ_sse4_1.c",
360                    "silk/x86/NSQ_del_dec_sse4_1.c",
361                    "silk/x86/x86_silk_map.c",
362                    "silk/x86/VAD_sse4_1.c",
363                    "silk/x86/VQ_WMat_EC_sse4_1.c",
364
365                    // SILK_SOURCES_FIXED_SSE4_1
366                    "silk/fixed/x86/vector_ops_FIX_sse4_1.c",
367                    "silk/fixed/x86/burg_modified_FIX_sse4_1.c",
368                ],
369
370                cflags: [
371                    "-DOPUS_X86_MAY_HAVE_SSE4_1",
372                    "-DOPUS_X86_PRESUME_SSE4_1",
373                ],
374            },
375        },
376    },
377
378    target: {
379        darwin: {
380            enabled: false,
381        },
382    },
383    apex_available: [
384        "//apex_available:platform", // used by libstagefright_soft_opusdec
385        "com.android.media.swcodec",
386        "com.android.bluetooth",
387    ],
388    min_sdk_version: "29",
389}
390