Skip to content

Commit 73ec642

Browse files
committed
[TF][REFACTOR] build libopus from source
Set OUTPUT_NAME opus on the libopus target so the archive is named libopus.a (CMake prepends 'lib' to the target name, which would otherwise produce liblibopus.a).
1 parent 52ef67c commit 73ec642

1 file changed

Lines changed: 170 additions & 16 deletions

File tree

TMessagesProj/jni/CMakeLists.txt

Lines changed: 170 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ set_target_properties(libvpx PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY
4040
add_library(libdav1d STATIC IMPORTED)
4141
set_target_properties(libdav1d PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/dav1d/build/${ANDROID_ABI}/lib/libdav1d.a)
4242

43-
add_library(libopus STATIC IMPORTED)
44-
set_target_properties(libopus PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libopus.a)
45-
4643
add_library(tde2e STATIC IMPORTED)
4744
set_target_properties(tde2e PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/tde2e/${ANDROID_ABI}/libtde2e.a)
4845

@@ -130,6 +127,174 @@ target_include_directories(breakpad PUBLIC
130127
#voip
131128
include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt)
132129

130+
#libopus
131+
add_library(libopus STATIC
132+
third_party/xiph/opus/src/opus.c
133+
third_party/xiph/opus/src/opus_decoder.c
134+
third_party/xiph/opus/src/opus_encoder.c
135+
third_party/xiph/opus/src/opus_multistream.c
136+
third_party/xiph/opus/src/opus_multistream_encoder.c
137+
third_party/xiph/opus/src/opus_multistream_decoder.c
138+
third_party/xiph/opus/src/repacketizer.c
139+
third_party/xiph/opus/src/analysis.c
140+
third_party/xiph/opus/src/mlp.c
141+
third_party/xiph/opus/src/mlp_data.c
142+
third_party/xiph/opus/src/opus_projection_encoder.c
143+
third_party/xiph/opus/src/opus_projection_decoder.c
144+
third_party/xiph/opus/src/mapping_matrix.c
145+
third_party/xiph/opus/src/extensions.c
146+
147+
third_party/xiph/opus/silk/CNG.c
148+
third_party/xiph/opus/silk/code_signs.c
149+
third_party/xiph/opus/silk/init_decoder.c
150+
third_party/xiph/opus/silk/decode_core.c
151+
third_party/xiph/opus/silk/decode_frame.c
152+
third_party/xiph/opus/silk/decode_parameters.c
153+
third_party/xiph/opus/silk/decode_indices.c
154+
third_party/xiph/opus/silk/decode_pulses.c
155+
third_party/xiph/opus/silk/decoder_set_fs.c
156+
third_party/xiph/opus/silk/dec_API.c
157+
third_party/xiph/opus/silk/enc_API.c
158+
third_party/xiph/opus/silk/encode_indices.c
159+
third_party/xiph/opus/silk/encode_pulses.c
160+
third_party/xiph/opus/silk/gain_quant.c
161+
third_party/xiph/opus/silk/interpolate.c
162+
third_party/xiph/opus/silk/LP_variable_cutoff.c
163+
third_party/xiph/opus/silk/NLSF_decode.c
164+
third_party/xiph/opus/silk/NSQ.c
165+
third_party/xiph/opus/silk/NSQ_del_dec.c
166+
third_party/xiph/opus/silk/PLC.c
167+
third_party/xiph/opus/silk/shell_coder.c
168+
third_party/xiph/opus/silk/tables_gain.c
169+
third_party/xiph/opus/silk/tables_LTP.c
170+
third_party/xiph/opus/silk/tables_NLSF_CB_NB_MB.c
171+
third_party/xiph/opus/silk/tables_NLSF_CB_WB.c
172+
third_party/xiph/opus/silk/tables_other.c
173+
third_party/xiph/opus/silk/tables_pitch_lag.c
174+
third_party/xiph/opus/silk/tables_pulses_per_block.c
175+
third_party/xiph/opus/silk/VAD.c
176+
third_party/xiph/opus/silk/control_audio_bandwidth.c
177+
third_party/xiph/opus/silk/quant_LTP_gains.c
178+
third_party/xiph/opus/silk/VQ_WMat_EC.c
179+
third_party/xiph/opus/silk/HP_variable_cutoff.c
180+
third_party/xiph/opus/silk/NLSF_encode.c
181+
third_party/xiph/opus/silk/NLSF_VQ.c
182+
third_party/xiph/opus/silk/NLSF_unpack.c
183+
third_party/xiph/opus/silk/NLSF_del_dec_quant.c
184+
third_party/xiph/opus/silk/process_NLSFs.c
185+
third_party/xiph/opus/silk/stereo_LR_to_MS.c
186+
third_party/xiph/opus/silk/stereo_MS_to_LR.c
187+
third_party/xiph/opus/silk/check_control_input.c
188+
third_party/xiph/opus/silk/control_SNR.c
189+
third_party/xiph/opus/silk/init_encoder.c
190+
third_party/xiph/opus/silk/control_codec.c
191+
third_party/xiph/opus/silk/A2NLSF.c
192+
third_party/xiph/opus/silk/ana_filt_bank_1.c
193+
third_party/xiph/opus/silk/biquad_alt.c
194+
third_party/xiph/opus/silk/bwexpander_32.c
195+
third_party/xiph/opus/silk/bwexpander.c
196+
third_party/xiph/opus/silk/debug.c
197+
third_party/xiph/opus/silk/decode_pitch.c
198+
third_party/xiph/opus/silk/inner_prod_aligned.c
199+
third_party/xiph/opus/silk/lin2log.c
200+
third_party/xiph/opus/silk/log2lin.c
201+
third_party/xiph/opus/silk/LPC_analysis_filter.c
202+
third_party/xiph/opus/silk/LPC_inv_pred_gain.c
203+
third_party/xiph/opus/silk/table_LSF_cos.c
204+
third_party/xiph/opus/silk/NLSF2A.c
205+
third_party/xiph/opus/silk/NLSF_stabilize.c
206+
third_party/xiph/opus/silk/NLSF_VQ_weights_laroia.c
207+
third_party/xiph/opus/silk/pitch_est_tables.c
208+
third_party/xiph/opus/silk/resampler.c
209+
third_party/xiph/opus/silk/resampler_down2_3.c
210+
third_party/xiph/opus/silk/resampler_down2.c
211+
third_party/xiph/opus/silk/resampler_private_AR2.c
212+
third_party/xiph/opus/silk/resampler_private_down_FIR.c
213+
third_party/xiph/opus/silk/resampler_private_IIR_FIR.c
214+
third_party/xiph/opus/silk/resampler_private_up2_HQ.c
215+
third_party/xiph/opus/silk/resampler_rom.c
216+
third_party/xiph/opus/silk/sigm_Q15.c
217+
third_party/xiph/opus/silk/sort.c
218+
third_party/xiph/opus/silk/sum_sqr_shift.c
219+
third_party/xiph/opus/silk/stereo_decode_pred.c
220+
third_party/xiph/opus/silk/stereo_encode_pred.c
221+
third_party/xiph/opus/silk/stereo_find_predictor.c
222+
third_party/xiph/opus/silk/stereo_quant_pred.c
223+
third_party/xiph/opus/silk/LPC_fit.c
224+
225+
third_party/xiph/opus/silk/fixed/LTP_analysis_filter_FIX.c
226+
third_party/xiph/opus/silk/fixed/LTP_scale_ctrl_FIX.c
227+
third_party/xiph/opus/silk/fixed/corrMatrix_FIX.c
228+
third_party/xiph/opus/silk/fixed/encode_frame_FIX.c
229+
third_party/xiph/opus/silk/fixed/find_LPC_FIX.c
230+
third_party/xiph/opus/silk/fixed/find_LTP_FIX.c
231+
third_party/xiph/opus/silk/fixed/find_pitch_lags_FIX.c
232+
third_party/xiph/opus/silk/fixed/find_pred_coefs_FIX.c
233+
third_party/xiph/opus/silk/fixed/noise_shape_analysis_FIX.c
234+
third_party/xiph/opus/silk/fixed/process_gains_FIX.c
235+
third_party/xiph/opus/silk/fixed/regularize_correlations_FIX.c
236+
third_party/xiph/opus/silk/fixed/residual_energy16_FIX.c
237+
third_party/xiph/opus/silk/fixed/residual_energy_FIX.c
238+
third_party/xiph/opus/silk/fixed/warped_autocorrelation_FIX.c
239+
third_party/xiph/opus/silk/fixed/apply_sine_window_FIX.c
240+
third_party/xiph/opus/silk/fixed/autocorr_FIX.c
241+
third_party/xiph/opus/silk/fixed/burg_modified_FIX.c
242+
third_party/xiph/opus/silk/fixed/k2a_FIX.c
243+
third_party/xiph/opus/silk/fixed/k2a_Q16_FIX.c
244+
third_party/xiph/opus/silk/fixed/pitch_analysis_core_FIX.c
245+
third_party/xiph/opus/silk/fixed/vector_ops_FIX.c
246+
third_party/xiph/opus/silk/fixed/schur64_FIX.c
247+
third_party/xiph/opus/silk/fixed/schur_FIX.c
248+
249+
third_party/xiph/opus/celt/bands.c
250+
third_party/xiph/opus/celt/celt.c
251+
third_party/xiph/opus/celt/celt_encoder.c
252+
third_party/xiph/opus/celt/celt_decoder.c
253+
third_party/xiph/opus/celt/cwrs.c
254+
third_party/xiph/opus/celt/entcode.c
255+
third_party/xiph/opus/celt/entdec.c
256+
third_party/xiph/opus/celt/entenc.c
257+
third_party/xiph/opus/celt/kiss_fft.c
258+
third_party/xiph/opus/celt/laplace.c
259+
third_party/xiph/opus/celt/mathops.c
260+
third_party/xiph/opus/celt/mdct.c
261+
third_party/xiph/opus/celt/modes.c
262+
third_party/xiph/opus/celt/pitch.c
263+
third_party/xiph/opus/celt/celt_lpc.c
264+
third_party/xiph/opus/celt/quant_bands.c
265+
third_party/xiph/opus/celt/rate.c
266+
third_party/xiph/opus/celt/vq.c
267+
third_party/xiph/opus/celt/arm/armcpu.c
268+
third_party/xiph/opus/celt/arm/arm_celt_map.c
269+
)
270+
target_compile_options(libopus PUBLIC
271+
-ffast-math -Oz -funroll-loops -fno-strict-aliasing -fno-math-errno)
272+
set_target_properties(libopus PROPERTIES
273+
OUTPUT_NAME opus
274+
ANDROID_ARM_MODE arm)
275+
target_compile_definitions(libopus PUBLIC
276+
OPUS_BUILD FIXED_POINT USE_ALLOCA restrict= __EMX__ LOCALE_NOT_USED HAVE_LRINT HAVE_LRINTF)
277+
if (${ANDROID_ABI} STREQUAL "armeabi-v7a" OR ${ANDROID_ABI} STREQUAL "arm64-v8a")
278+
target_compile_definitions(libopus PUBLIC
279+
OPUS_HAVE_RTCD OPUS_ARM_ASM)
280+
target_sources(libopus PRIVATE
281+
third_party/xiph/opus/celt/arm/celt_neon_intr.c
282+
third_party/xiph/opus/celt/arm/pitch_neon_intr.c
283+
third_party/xiph/opus/silk/arm/NSQ_neon.c
284+
third_party/xiph/opus/silk/arm/arm_silk_map.c
285+
third_party/xiph/opus/silk/arm/LPC_inv_pred_gain_neon_intr.c
286+
third_party/xiph/opus/silk/arm/NSQ_del_dec_neon_intr.c
287+
third_party/xiph/opus/silk/arm/biquad_alt_neon_intr.c
288+
third_party/xiph/opus/silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c
289+
)
290+
endif()
291+
target_include_directories(libopus PUBLIC
292+
third_party/xiph/opus/include
293+
third_party/xiph/opus/silk
294+
third_party/xiph/opus/silk/fixed
295+
third_party/xiph/opus/celt
296+
third_party/xiph/opus)
297+
133298
set(NATIVE_LIB "tmessages.49")
134299

135300
#tmessages
@@ -155,7 +320,7 @@ target_compile_options(${NATIVE_LIB} PUBLIC
155320
-ffast-math -Oz -funroll-loops -ffast-math -fno-strict-aliasing -fno-math-errno)
156321

157322
target_compile_definitions(${NATIVE_LIB} PUBLIC
158-
BSD=1 NULL=0 SOCKLEN_T=socklen_t ANDROID_NDK DISABLE_IMPORTGL AVOID_TABLES ANDROID_TILE_BASED_DECODE __STDC_CONSTANT_MACROS ANDROID_ARMV6_IDCT OPUS_BUILD FIXED_POINT USE_ALLOCA restrict= __EMX__ LOCALE_NOT_USED HAVE_LRINT HAVE_LRINTF)
323+
BSD=1 NULL=0 SOCKLEN_T=socklen_t ANDROID_NDK DISABLE_IMPORTGL AVOID_TABLES ANDROID_TILE_BASED_DECODE __STDC_CONSTANT_MACROS ANDROID_ARMV6_IDCT)
159324

160325
if (${ANDROID_ABI} STREQUAL "armeabi-v7a")
161326
set_target_properties(${NATIVE_LIB} PROPERTIES
@@ -176,18 +341,7 @@ endif()
176341

177342
if (${ANDROID_ABI} STREQUAL "armeabi-v7a" OR ${ANDROID_ABI} STREQUAL "arm64-v8a")
178343
target_compile_definitions(${NATIVE_LIB} PUBLIC
179-
LIBYUV_NEON OPUS_HAVE_RTCD OPUS_ARM_ASM)
180-
181-
target_sources(${NATIVE_LIB} PRIVATE
182-
opus/celt/arm/celt_neon_intr.c
183-
opus/celt/arm/pitch_neon_intr.c
184-
opus/silk/arm/NSQ_neon.c
185-
opus/silk/arm/arm_silk_map.c
186-
opus/silk/arm/LPC_inv_pred_gain_neon_intr.c
187-
opus/silk/arm/NSQ_del_dec_neon_intr.c
188-
opus/silk/arm/biquad_alt_neon_intr.c
189-
opus/silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c
190-
)
344+
LIBYUV_NEON)
191345
endif()
192346

193347
target_sources(${NATIVE_LIB} PRIVATE

0 commit comments

Comments
 (0)