Skip to content

Commit 288befd

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 d0056c4 commit 288befd

1 file changed

Lines changed: 171 additions & 17 deletions

File tree

TMessagesProj/jni/CMakeLists.txt

Lines changed: 171 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set(CMAKE_C_FLAGS "-w -std=c11 -DANDROID -D_LARGEFILE_SOURCE=1 -g -Wno-error=imp
55
set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")
66
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections -fvisibility=hidden -flto=full")
77
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -flto=full")
8-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto=full -Wl,--gc-sections -Wl,--icf=safe -Wl,-Bsymbolic -Wl,--exclude-libs,libtgvoip.a,libtgcalls.a,libtgcalls_tp.a,libtgnet.a,libflac.a,librlottie.a,libsqlite.a,
8+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto=full -Wl,--gc-sections -Wl,--icf=safe -Wl,-Bsymbolic -Wl,--exclude-libs,libtgvoip.a,libtgcalls.a,libtgcalls_tp.a,libtgnet.a,libflac.a,librlottie.a,libsqlite.a,libopus.a,
99
${CMAKE_HOME_DIRECTORY}/ffmpeg/build/${ANDROID_ABI}/lib/libswscale.a,
1010
${CMAKE_HOME_DIRECTORY}/ffmpeg/build/${ANDROID_ABI}/lib/libavformat.a,
1111
${CMAKE_HOME_DIRECTORY}/ffmpeg/build/${ANDROID_ABI}/lib/libavcodec.a,
@@ -51,9 +51,6 @@ set_target_properties(libvpx PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY
5151
add_library(libdav1d STATIC IMPORTED)
5252
set_target_properties(libdav1d PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/dav1d/build/${ANDROID_ABI}/lib/libdav1d.a)
5353

54-
add_library(libopus STATIC IMPORTED)
55-
set_target_properties(libopus PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libopus.a)
56-
5754
add_library(tde2e STATIC IMPORTED)
5855
set_target_properties(tde2e PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/tde2e/${ANDROID_ABI}/libtde2e.a)
5956

@@ -141,6 +138,174 @@ target_include_directories(breakpad PUBLIC
141138
#voip
142139
include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt)
143140

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

146311
#tmessages
@@ -166,7 +331,7 @@ target_compile_options(${NATIVE_LIB} PUBLIC
166331
-ffast-math -Oz -funroll-loops -ffast-math -fno-strict-aliasing -fno-math-errno)
167332

168333
target_compile_definitions(${NATIVE_LIB} PUBLIC
169-
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)
334+
BSD=1 NULL=0 SOCKLEN_T=socklen_t ANDROID_NDK DISABLE_IMPORTGL AVOID_TABLES ANDROID_TILE_BASED_DECODE __STDC_CONSTANT_MACROS ANDROID_ARMV6_IDCT)
170335

171336
if (${ANDROID_ABI} STREQUAL "armeabi-v7a")
172337
set_target_properties(${NATIVE_LIB} PROPERTIES
@@ -187,18 +352,7 @@ endif()
187352

188353
if (${ANDROID_ABI} STREQUAL "armeabi-v7a" OR ${ANDROID_ABI} STREQUAL "arm64-v8a")
189354
target_compile_definitions(${NATIVE_LIB} PUBLIC
190-
LIBYUV_NEON OPUS_HAVE_RTCD OPUS_ARM_ASM)
191-
192-
target_sources(${NATIVE_LIB} PRIVATE
193-
opus/celt/arm/celt_neon_intr.c
194-
opus/celt/arm/pitch_neon_intr.c
195-
opus/silk/arm/NSQ_neon.c
196-
opus/silk/arm/arm_silk_map.c
197-
opus/silk/arm/LPC_inv_pred_gain_neon_intr.c
198-
opus/silk/arm/NSQ_del_dec_neon_intr.c
199-
opus/silk/arm/biquad_alt_neon_intr.c
200-
opus/silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c
201-
)
355+
LIBYUV_NEON)
202356
endif()
203357

204358
target_sources(${NATIVE_LIB} PRIVATE

0 commit comments

Comments
 (0)