├── include └── typedefs.h ├── jni ├── src │ └── webrtc │ │ ├── modules │ │ ├── meson.build │ │ ├── third_party │ │ │ └── fft │ │ │ │ ├── meson.build │ │ │ │ ├── BUILD.gn │ │ │ │ └── LICENSE │ │ ├── audio_processing │ │ │ ├── ns │ │ │ │ ├── prior_signal_model.cc │ │ │ │ ├── signal_model.cc │ │ │ │ ├── ns_config.h │ │ │ │ ├── signal_model.h │ │ │ │ ├── suppression_params.h │ │ │ │ ├── prior_signal_model.h │ │ │ │ ├── ns_common.h │ │ │ │ ├── fast_math.h │ │ │ │ ├── prior_signal_model_estimator.h │ │ │ │ ├── ns_fft.h │ │ │ │ ├── quantile_noise_estimator.h │ │ │ │ ├── suppression_params.cc │ │ │ │ └── histograms.cc │ │ │ ├── include │ │ │ │ ├── config.cc │ │ │ │ └── audio_processing_statistics.cc │ │ │ ├── agc │ │ │ │ ├── utility.h │ │ │ │ ├── utility.cc │ │ │ │ ├── mock_agc.h │ │ │ │ └── agc.h │ │ │ ├── aec3 │ │ │ │ ├── echo_path_variability.cc │ │ │ │ ├── fft_buffer.cc │ │ │ │ ├── downsampled_render_buffer.cc │ │ │ │ ├── spectrum_buffer.cc │ │ │ │ ├── delay_estimate.h │ │ │ │ ├── echo_path_variability.h │ │ │ │ ├── fft_data_avx2.cc │ │ │ │ ├── clockdrift_detector.h │ │ │ │ ├── adaptive_fir_filter_erl_avx2.cc │ │ │ │ ├── block_buffer.cc │ │ │ │ ├── decimator.h │ │ │ │ ├── moving_average.h │ │ │ │ ├── block_delay_buffer.h │ │ │ │ ├── subtractor_output_analyzer.h │ │ │ │ ├── block_processor_metrics.h │ │ │ │ ├── nearend_detector.h │ │ │ │ ├── transparent_mode.h │ │ │ │ └── subtractor_output.h │ │ │ ├── transient │ │ │ │ ├── common.h │ │ │ │ ├── wpd_node.h │ │ │ │ └── moving_moments.cc │ │ │ ├── level_estimator.cc │ │ │ ├── vad │ │ │ │ ├── common.h │ │ │ │ └── pitch_internal.h │ │ │ ├── agc2 │ │ │ │ ├── rnn_vad │ │ │ │ │ ├── common.cc │ │ │ │ │ ├── pitch_info.h │ │ │ │ │ └── lp_residual.h │ │ │ │ ├── agc2_testing_common.cc │ │ │ │ ├── down_sampler.h │ │ │ │ ├── vector_float_frame.cc │ │ │ │ ├── noise_spectrum_estimator.h │ │ │ │ ├── vector_float_frame.h │ │ │ │ ├── biquad_filter.cc │ │ │ │ ├── noise_level_estimator.h │ │ │ │ └── gain_applier.h │ │ │ ├── optionally_built_submodule_creators.cc │ │ │ ├── echo_detector │ │ │ │ ├── moving_max.h │ │ │ │ ├── mean_variance_estimator.h │ │ │ │ ├── mean_variance_estimator.cc │ │ │ │ ├── circular_buffer.h │ │ │ │ ├── moving_max.cc │ │ │ │ ├── normalized_covariance_estimator.cc │ │ │ │ ├── normalized_covariance_estimator.h │ │ │ │ └── circular_buffer.cc │ │ │ ├── common.h │ │ │ ├── render_queue_item_verifier.h │ │ │ ├── aecm │ │ │ │ └── BUILD.gn │ │ │ ├── aec_dump │ │ │ │ └── null_aec_dump_factory.cc │ │ │ ├── high_pass_filter.h │ │ │ ├── audio_processing_builder_impl.cc │ │ │ ├── optionally_built_submodule_creators.h │ │ │ └── utility │ │ │ │ └── delay_estimator_internal.h │ │ └── audio_coding │ │ │ └── codecs │ │ │ ├── isac │ │ │ ├── main │ │ │ │ ├── source │ │ │ │ │ ├── audio_decoder_isac.cc │ │ │ │ │ ├── audio_encoder_isac.cc │ │ │ │ │ ├── filter_functions.h │ │ │ │ │ ├── pitch_estimator.h │ │ │ │ │ ├── crc.h │ │ │ │ │ ├── os_specific_inline.h │ │ │ │ │ ├── pitch_filter.h │ │ │ │ │ └── lpc_gain_swb_tables.h │ │ │ │ └── include │ │ │ │ │ ├── audio_decoder_isac.h │ │ │ │ │ └── audio_encoder_isac.h │ │ │ ├── bandwidth_info.h │ │ │ └── locked_bandwidth_info.h │ │ │ ├── audio_decoder.h │ │ │ └── audio_encoder.h │ │ ├── meson.build │ │ ├── common_audio │ │ ├── third_party │ │ │ ├── ooura │ │ │ │ ├── LICENSE │ │ │ │ ├── fft_size_256 │ │ │ │ │ └── fft4g.h │ │ │ │ └── BUILD.gn │ │ │ └── spl_sqrt_floor │ │ │ │ ├── BUILD.gn │ │ │ │ ├── LICENSE │ │ │ │ └── spl_sqrt_floor.h │ │ ├── fir_filter.h │ │ ├── window_generator.h │ │ ├── fir_filter_c.h │ │ ├── signal_processing │ │ │ ├── spl_inl.c │ │ │ ├── sqrt_of_one_minus_x_squared.c │ │ │ ├── energy.c │ │ │ ├── cross_correlation.c │ │ │ ├── dot_product_with_scale.cc │ │ │ ├── get_scaling_square.c │ │ │ ├── dot_product_with_scale.h │ │ │ └── refl_coef_to_lpc.c │ │ ├── fir_filter_factory.h │ │ ├── fir_filter_neon.h │ │ ├── fir_filter_sse.h │ │ ├── fir_filter_avx2.h │ │ ├── real_fourier_openmax.h │ │ ├── real_fourier_ooura.h │ │ ├── vad │ │ │ ├── vad_gmm.h │ │ │ └── include │ │ │ │ └── vad.h │ │ ├── real_fourier.cc │ │ └── resampler │ │ │ └── sinc_resampler_neon.cc │ │ ├── third_party │ │ ├── rnnoise │ │ │ ├── meson.build │ │ │ ├── BUILD.gn │ │ │ └── src │ │ │ │ └── rnn_vad_weights.h │ │ └── pffft │ │ │ └── meson.build │ │ ├── rtc_base │ │ ├── synchronization │ │ │ ├── yield.h │ │ │ ├── rw_lock_wrapper.cc │ │ │ ├── yield.cc │ │ │ ├── rw_lock_win.h │ │ │ ├── rw_lock_win.cc │ │ │ ├── mutex.cc │ │ │ ├── rw_lock_posix.h │ │ │ ├── rw_lock_posix.cc │ │ │ └── yield_policy.h │ │ ├── constructor_magic.h │ │ ├── system │ │ │ ├── inline.h │ │ │ ├── warn_current_thread_is_deadlocked.h │ │ │ ├── ignore_warnings.h │ │ │ ├── rtc_export.h │ │ │ └── unused.h │ │ ├── units │ │ │ └── BUILD.gn │ │ ├── compile_assert_c.h │ │ ├── thread_checker.h │ │ ├── zero_memory.h │ │ ├── ignore_wundef.h │ │ ├── arraysize.h │ │ ├── zero_memory.cc │ │ ├── string_utils.cc │ │ ├── memory │ │ │ └── BUILD.gn │ │ └── gtest_prod_util.h │ │ ├── api │ │ ├── video │ │ │ ├── hdr_metadata.cc │ │ │ ├── video_rotation.h │ │ │ └── video_content_type.h │ │ ├── units │ │ │ ├── data_size.cc │ │ │ ├── frequency.cc │ │ │ ├── data_rate.cc │ │ │ ├── timestamp.cc │ │ │ └── time_delta.cc │ │ ├── meson.build │ │ ├── ref_counted_base.h │ │ ├── task_queue │ │ │ └── queued_task.h │ │ └── rtp_headers.cc │ │ ├── system_wrappers │ │ ├── meson.build │ │ ├── include │ │ │ ├── sleep.h │ │ │ └── cpu_features_wrapper.h │ │ └── source │ │ │ └── sleep.cc │ │ ├── PATENTS │ │ ├── LICENSE │ │ └── audio │ │ └── utility │ │ └── BUILD.gn └── Application.mk └── README.md /include/typedefs.h: -------------------------------------------------------------------------------- 1 | ../jni/src/webrtc/typedefs.h -------------------------------------------------------------------------------- /jni/src/webrtc/modules/meson.build: -------------------------------------------------------------------------------- 1 | subdir('third_party/fft') 2 | subdir('audio_coding') 3 | subdir('audio_processing') 4 | -------------------------------------------------------------------------------- /jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := $(ANDROID_TARGET_ARCH) 2 | 3 | ifeq ($(findstring x86,$(TARGET_ARCH_ABI)),) 4 | APP_STL := c++_static 5 | endif 6 | -------------------------------------------------------------------------------- /jni/src/webrtc/meson.build: -------------------------------------------------------------------------------- 1 | webrtc_inc = include_directories('.') 2 | 3 | subdir('rtc_base') 4 | subdir('api') 5 | subdir('system_wrappers') 6 | subdir('common_audio') 7 | 8 | subdir('third_party/pffft') 9 | subdir('third_party/rnnoise') 10 | 11 | subdir('modules') 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libwebrtc 2 | - webrtc AEC (Acoustic Echo Cancellation) library for baresip-studio project 3 | 4 | - this (mobile) branch includes AECM module 5 | 6 | - based on https://github.com/thepacific/webrtc-android-jni project 7 | 8 | - webrtc source is from https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing project 9 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/third_party/fft/meson.build: -------------------------------------------------------------------------------- 1 | fft_sources = ['fft.c'] 2 | 3 | libfft = static_library('libfft', 4 | fft_sources, 5 | dependencies: common_deps, 6 | include_directories: webrtc_inc, 7 | cpp_args : common_cxxflags 8 | ) 9 | 10 | fft_dep = declare_dependency( 11 | link_with: libfft 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/third_party/ooura/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html 3 | * Copyright Takuya OOURA, 1996-2001 4 | * 5 | * You may use, copy, modify and distribute this code for any purpose (include 6 | * commercial use) and without fee. Please refer to this package when you modify 7 | * this code. 8 | */ 9 | -------------------------------------------------------------------------------- /jni/src/webrtc/third_party/rnnoise/meson.build: -------------------------------------------------------------------------------- 1 | rnnoise_sources = [ 2 | 'src/rnn_vad_weights.cc', 3 | ] 4 | 5 | librnnoise = static_library('librnnoise', 6 | rnnoise_sources, 7 | dependencies: common_deps, 8 | include_directories: webrtc_inc, 9 | cpp_args : common_cxxflags 10 | ) 11 | 12 | rnnoise_dep = declare_dependency( 13 | link_with: librnnoise 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /jni/src/webrtc/third_party/rnnoise/BUILD.gn: -------------------------------------------------------------------------------- 1 | IyBDb3B5cmlnaHQgMjAxOCBUaGUgQ2hyb21pdW0gQXV0aG9ycy4gQWxsIHJpZ2h0cyByZXNlcnZlZC4KIyBVc2Ugb2YgdGhpcyBzb3VyY2UgY29kZSBpcyBnb3Zlcm5lZCBieSBhIEJTRC1zdHlsZSBsaWNlbnNlIHRoYXQgY2FuIGJlCiMgZm91bmQgaW4gdGhlIExJQ0VOU0UgZmlsZS4KCmltcG9ydCgiLy90ZXN0aW5nL3Rlc3QuZ25pIikKCmdyb3VwKCJybm5vaXNlIikgewogIGRlcHMgPSBbICI6cm5uX3ZhZCIgXQp9Cgpzb3VyY2Vfc2V0KCJybm5fdmFkIikgewogIHNvdXJjZXMgPSBbCiAgICAic3JjL3Jubl9hY3RpdmF0aW9ucy5oIiwKICAgICJzcmMvcm5uX3ZhZF93ZWlnaHRzLmNjIiwKICAgICJzcmMvcm5uX3ZhZF93ZWlnaHRzLmgiLAogIF0KfQo= -------------------------------------------------------------------------------- /jni/src/webrtc/third_party/pffft/meson.build: -------------------------------------------------------------------------------- 1 | pffft_sources = [ 2 | 'src/pffft.c', 3 | ] 4 | 5 | pffft_cflags = [ '-D_GNU_SOURCE' ] 6 | 7 | if (have_arm and not have_neon) or (have_mips and host_machine.endian() == 'little') or have_mips64 8 | pffft_cflags += [ '-DPFFFT_SIMD_DISABLE' ] 9 | endif 10 | 11 | libpffft = static_library('libpffft', 12 | pffft_sources, 13 | dependencies: common_deps, 14 | include_directories: webrtc_inc, 15 | c_args : common_cflags + pffft_cflags 16 | ) 17 | 18 | pffft_dep = declare_dependency( 19 | link_with: libpffft 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/third_party/fft/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the ../../../LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import("../../../webrtc.gni") 10 | 11 | rtc_library("fft") { 12 | sources = [ 13 | "fft.c", 14 | "fft.h", 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/prior_signal_model.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/ns/prior_signal_model.h" 12 | 13 | namespace webrtc { 14 | 15 | PriorSignalModel::PriorSignalModel(float lrt_initial_value) 16 | : lrt(lrt_initial_value) {} 17 | 18 | } // namespace webrtc 19 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/synchronization/yield.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #ifndef RTC_BASE_SYNCHRONIZATION_YIELD_H_ 11 | #define RTC_BASE_SYNCHRONIZATION_YIELD_H_ 12 | 13 | namespace webrtc { 14 | 15 | // Request rescheduling of threads. 16 | void YieldCurrentThread(); 17 | 18 | } // namespace webrtc 19 | 20 | #endif // RTC_BASE_SYNCHRONIZATION_YIELD_H_ 21 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/video/hdr_metadata.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "api/video/hdr_metadata.h" 12 | 13 | namespace webrtc { 14 | 15 | HdrMasteringMetadata::Chromaticity::Chromaticity() = default; 16 | 17 | HdrMasteringMetadata::HdrMasteringMetadata() = default; 18 | 19 | HdrMetadata::HdrMetadata() = default; 20 | 21 | } // namespace webrtc 22 | -------------------------------------------------------------------------------- /jni/src/webrtc/system_wrappers/meson.build: -------------------------------------------------------------------------------- 1 | system_wrappers_sources = [ 2 | 'source/cpu_features.cc', 3 | 'source/field_trial.cc', 4 | 'source/metrics.cc', 5 | 'source/sleep.cc', 6 | ] 7 | 8 | system_headers = [ 9 | 'include/cpu_features_wrapper.h', 10 | 'include/metrics.h', 11 | 'include/sleep.h', 12 | ] 13 | 14 | install_headers(system_headers, 15 | subdir: join_paths(include_subdir, 'system_wrappers', 'include') 16 | ) 17 | 18 | libsystem_wrappers = static_library('system_wrappers', 19 | system_wrappers_sources, 20 | dependencies: common_deps, 21 | include_directories: webrtc_inc, 22 | c_args : common_cflags, 23 | cpp_args : common_cxxflags 24 | ) 25 | 26 | system_wrappers_dep = declare_dependency( 27 | link_with: libsystem_wrappers 28 | ) 29 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/include/config.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/include/config.h" 12 | 13 | namespace webrtc { 14 | 15 | Config::Config() {} 16 | 17 | Config::~Config() { 18 | for (OptionMap::iterator it = options_.begin(); it != options_.end(); ++it) { 19 | delete it->second; 20 | } 21 | } 22 | 23 | } // namespace webrtc 24 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/main/source/audio_decoder_isac.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h" 12 | 13 | #include "modules/audio_coding/codecs/isac/audio_decoder_isac_t_impl.h" 14 | 15 | namespace webrtc { 16 | 17 | // Explicit instantiation: 18 | template class AudioDecoderIsacT; 19 | 20 | } // namespace webrtc 21 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h" 12 | 13 | #include "modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h" 14 | 15 | namespace webrtc { 16 | 17 | // Explicit instantiation: 18 | template class AudioEncoderIsacT; 19 | 20 | } // namespace webrtc 21 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/signal_model.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/ns/signal_model.h" 12 | 13 | namespace webrtc { 14 | 15 | SignalModel::SignalModel() { 16 | constexpr float kSfFeatureThr = 0.5f; 17 | 18 | lrt = kLtrFeatureThr; 19 | spectral_flatness = kSfFeatureThr; 20 | spectral_diff = kSfFeatureThr; 21 | avg_log_lrt.fill(kLtrFeatureThr); 22 | } 23 | 24 | } // namespace webrtc 25 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/video/video_rotation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef API_VIDEO_VIDEO_ROTATION_H_ 12 | #define API_VIDEO_VIDEO_ROTATION_H_ 13 | 14 | namespace webrtc { 15 | 16 | // enum for clockwise rotation. 17 | enum VideoRotation { 18 | kVideoRotation_0 = 0, 19 | kVideoRotation_90 = 90, 20 | kVideoRotation_180 = 180, 21 | kVideoRotation_270 = 270 22 | }; 23 | 24 | } // namespace webrtc 25 | 26 | #endif // API_VIDEO_VIDEO_ROTATION_H_ 27 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/audio_decoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // This file is for backwards compatibility only! Use 12 | // webrtc/api/audio_codecs/audio_decoder.h instead! 13 | // TODO(kwiberg): Remove it. 14 | 15 | #ifndef MODULES_AUDIO_CODING_CODECS_AUDIO_DECODER_H_ 16 | #define MODULES_AUDIO_CODING_CODECS_AUDIO_DECODER_H_ 17 | 18 | #include "api/audio_codecs/audio_decoder.h" 19 | 20 | #endif // MODULES_AUDIO_CODING_CODECS_AUDIO_DECODER_H_ 21 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/audio_encoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // This file is for backwards compatibility only! Use 12 | // webrtc/api/audio_codecs/audio_encoder.h instead! 13 | // TODO(ossu): Remove it. 14 | 15 | #ifndef MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ 16 | #define MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ 17 | 18 | #include "api/audio_codecs/audio_encoder.h" 19 | 20 | #endif // MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ 21 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/include/audio_processing_statistics.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/include/audio_processing_statistics.h" 12 | 13 | namespace webrtc { 14 | 15 | AudioProcessingStats::AudioProcessingStats() = default; 16 | 17 | AudioProcessingStats::AudioProcessingStats(const AudioProcessingStats& other) = 18 | default; 19 | 20 | AudioProcessingStats::~AudioProcessingStats() = default; 21 | 22 | } // namespace webrtc 23 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/third_party/ooura/fft_size_256/fft4g.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the ../../../LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_THIRD_PARTY_OOURA_FFT_SIZE_256_FFT4G_H_ 12 | #define COMMON_AUDIO_THIRD_PARTY_OOURA_FFT_SIZE_256_FFT4G_H_ 13 | 14 | namespace webrtc { 15 | 16 | // Refer to fft4g.c for documentation. 17 | void WebRtc_rdft(size_t n, int isgn, float* a, size_t* ip, float* w); 18 | 19 | } // namespace webrtc 20 | 21 | #endif // COMMON_AUDIO_THIRD_PARTY_OOURA_FFT_SIZE_256_FFT4G_H_ 22 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/constructor_magic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_CONSTRUCTOR_MAGIC_H_ 12 | #define RTC_BASE_CONSTRUCTOR_MAGIC_H_ 13 | 14 | // A macro to disallow the copy constructor and operator= functions. This should 15 | // be used in the declarations for a class. 16 | #define RTC_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 17 | TypeName(const TypeName&) = delete; \ 18 | TypeName& operator=(const TypeName&) = delete 19 | 20 | #endif // RTC_BASE_CONSTRUCTOR_MAGIC_H_ 21 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/bandwidth_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_BANDWIDTH_INFO_H_ 12 | #define MODULES_AUDIO_CODING_CODECS_ISAC_BANDWIDTH_INFO_H_ 13 | 14 | #include 15 | 16 | typedef struct { 17 | int in_use; 18 | int32_t send_bw_avg; 19 | int32_t send_max_delay_avg; 20 | int16_t bottleneck_idx; 21 | int16_t jitter_info; 22 | } IsacBandwidthInfo; 23 | 24 | #endif // MODULES_AUDIO_CODING_CODECS_ISAC_BANDWIDTH_INFO_H_ 25 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/ns_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_NS_NS_CONFIG_H_ 12 | #define MODULES_AUDIO_PROCESSING_NS_NS_CONFIG_H_ 13 | 14 | namespace webrtc { 15 | 16 | // Config struct for the noise suppressor 17 | struct NsConfig { 18 | enum class SuppressionLevel { k6dB, k12dB, k18dB, k21dB }; 19 | SuppressionLevel target_level = SuppressionLevel::k12dB; 20 | }; 21 | 22 | } // namespace webrtc 23 | 24 | #endif // MODULES_AUDIO_PROCESSING_NS_NS_CONFIG_H_ 25 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc/utility.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC_UTILITY_H_ 12 | #define MODULES_AUDIO_PROCESSING_AGC_UTILITY_H_ 13 | 14 | namespace webrtc { 15 | 16 | // TODO(turajs): Add description of function. 17 | double Loudness2Db(double loudness); 18 | 19 | double Linear2Loudness(double rms); 20 | 21 | double Db2Loudness(double db); 22 | 23 | double Dbfs2Loudness(double dbfs); 24 | 25 | } // namespace webrtc 26 | 27 | #endif // MODULES_AUDIO_PROCESSING_AGC_UTILITY_H_ 28 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/echo_path_variability.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/aec3/echo_path_variability.h" 12 | 13 | namespace webrtc { 14 | 15 | EchoPathVariability::EchoPathVariability(bool gain_change, 16 | DelayAdjustment delay_change, 17 | bool clock_drift) 18 | : gain_change(gain_change), 19 | delay_change(delay_change), 20 | clock_drift(clock_drift) {} 21 | 22 | } // namespace webrtc 23 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/synchronization/rw_lock_wrapper.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "rtc_base/synchronization/rw_lock_wrapper.h" 12 | 13 | #if defined(_WIN32) 14 | #include "rtc_base/synchronization/rw_lock_win.h" 15 | #else 16 | #include "rtc_base/synchronization/rw_lock_posix.h" 17 | #endif 18 | 19 | namespace webrtc { 20 | 21 | RWLockWrapper* RWLockWrapper::CreateRWLock() { 22 | #ifdef _WIN32 23 | return RWLockWin::Create(); 24 | #else 25 | return RWLockPosix::Create(); 26 | #endif 27 | } 28 | 29 | } // namespace webrtc 30 | -------------------------------------------------------------------------------- /jni/src/webrtc/system_wrappers/include/sleep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | // An OS-independent sleep function. 11 | 12 | #ifndef SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ 13 | #define SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ 14 | 15 | namespace webrtc { 16 | 17 | // This function sleeps for the specified number of milliseconds. 18 | // It may return early if the thread is woken by some other event, 19 | // such as the delivery of a signal on Unix. 20 | void SleepMs(int msecs); 21 | 22 | } // namespace webrtc 23 | 24 | #endif // SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ 25 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/third_party/spl_sqrt_floor/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the ../../../LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import("../../../webrtc.gni") 10 | 11 | rtc_library("spl_sqrt_floor") { 12 | visibility = [ "../..:common_audio_c" ] 13 | sources = [ "spl_sqrt_floor.h" ] 14 | deps = [] 15 | if (current_cpu == "arm") { 16 | sources += [ "spl_sqrt_floor_arm.S" ] 17 | 18 | deps += [ "../../../rtc_base/system:asm_defines" ] 19 | } else if (current_cpu == "mipsel") { 20 | sources += [ "spl_sqrt_floor_mips.c" ] 21 | } else { 22 | sources += [ "spl_sqrt_floor.c" ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/fft_buffer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/aec3/fft_buffer.h" 12 | 13 | namespace webrtc { 14 | 15 | FftBuffer::FftBuffer(size_t size, size_t num_channels) 16 | : size(static_cast(size)), 17 | buffer(size, std::vector(num_channels)) { 18 | for (auto& block : buffer) { 19 | for (auto& channel_fft_data : block) { 20 | channel_fft_data.Clear(); 21 | } 22 | } 23 | } 24 | 25 | FftBuffer::~FftBuffer() = default; 26 | 27 | } // namespace webrtc 28 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/system/inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_SYSTEM_INLINE_H_ 12 | #define RTC_BASE_SYSTEM_INLINE_H_ 13 | 14 | #if defined(_MSC_VER) 15 | 16 | #define RTC_FORCE_INLINE __forceinline 17 | #define RTC_NO_INLINE __declspec(noinline) 18 | 19 | #elif defined(__GNUC__) 20 | 21 | #define RTC_FORCE_INLINE __attribute__((__always_inline__)) 22 | #define RTC_NO_INLINE __attribute__((__noinline__)) 23 | 24 | #else 25 | 26 | #define RTC_FORCE_INLINE 27 | #define RTC_NO_INLINE 28 | 29 | #endif 30 | 31 | #endif // RTC_BASE_SYSTEM_INLINE_H_ 32 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/units/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import("../../webrtc.gni") 10 | 11 | rtc_source_set("unit_base") { 12 | visibility = [ 13 | "../../api/units:*", 14 | ":*", 15 | ] 16 | sources = [ "unit_base.h" ] 17 | 18 | deps = [ 19 | "../../rtc_base:checks", 20 | "../../rtc_base:safe_conversions", 21 | ] 22 | } 23 | 24 | if (rtc_include_tests) { 25 | rtc_library("units_unittests") { 26 | testonly = true 27 | sources = [ "unit_base_unittest.cc" ] 28 | deps = [ 29 | ":unit_base", 30 | "../../test:test_support", 31 | ] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/units/data_size.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "api/units/data_size.h" 12 | 13 | #include "api/array_view.h" 14 | #include "rtc_base/strings/string_builder.h" 15 | 16 | namespace webrtc { 17 | 18 | std::string ToString(DataSize value) { 19 | char buf[64]; 20 | rtc::SimpleStringBuilder sb(buf); 21 | if (value.IsPlusInfinity()) { 22 | sb << "+inf bytes"; 23 | } else if (value.IsMinusInfinity()) { 24 | sb << "-inf bytes"; 25 | } else { 26 | sb << value.bytes() << " bytes"; 27 | } 28 | return sb.str(); 29 | } 30 | } // namespace webrtc 31 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/downsampled_render_buffer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/aec3/downsampled_render_buffer.h" 12 | 13 | #include 14 | 15 | namespace webrtc { 16 | 17 | DownsampledRenderBuffer::DownsampledRenderBuffer(size_t downsampled_buffer_size) 18 | : size(static_cast(downsampled_buffer_size)), 19 | buffer(downsampled_buffer_size, 0.f) { 20 | std::fill(buffer.begin(), buffer.end(), 0.f); 21 | } 22 | 23 | DownsampledRenderBuffer::~DownsampledRenderBuffer() = default; 24 | 25 | } // namespace webrtc 26 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/transient/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_ 12 | #define MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_ 13 | namespace webrtc { 14 | namespace ts { 15 | 16 | static const float kPi = 3.14159265358979323846f; 17 | static const int kChunkSizeMs = 10; 18 | enum { 19 | kSampleRate8kHz = 8000, 20 | kSampleRate16kHz = 16000, 21 | kSampleRate32kHz = 32000, 22 | kSampleRate48kHz = 48000 23 | }; 24 | 25 | } // namespace ts 26 | } // namespace webrtc 27 | #endif // MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_ 28 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INCLUDE_AUDIO_DECODER_ISAC_H_ 12 | #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INCLUDE_AUDIO_DECODER_ISAC_H_ 13 | 14 | #include "modules/audio_coding/codecs/isac/audio_decoder_isac_t.h" 15 | #include "modules/audio_coding/codecs/isac/main/source/isac_float_type.h" 16 | 17 | namespace webrtc { 18 | 19 | using AudioDecoderIsacFloatImpl = AudioDecoderIsacT; 20 | 21 | } // namespace webrtc 22 | #endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INCLUDE_AUDIO_ENCODER_ISAC_H_ 23 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INCLUDE_AUDIO_ENCODER_ISAC_H_ 12 | #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INCLUDE_AUDIO_ENCODER_ISAC_H_ 13 | 14 | #include "modules/audio_coding/codecs/isac/audio_encoder_isac_t.h" 15 | #include "modules/audio_coding/codecs/isac/main/source/isac_float_type.h" 16 | 17 | namespace webrtc { 18 | 19 | using AudioEncoderIsacFloatImpl = AudioEncoderIsacT; 20 | 21 | } // namespace webrtc 22 | #endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INCLUDE_AUDIO_ENCODER_ISAC_H_ 23 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/fir_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_FIR_FILTER_H_ 12 | #define COMMON_AUDIO_FIR_FILTER_H_ 13 | 14 | #include 15 | 16 | namespace webrtc { 17 | 18 | // Finite Impulse Response filter using floating-point arithmetic. 19 | class FIRFilter { 20 | public: 21 | virtual ~FIRFilter() {} 22 | 23 | // Filters the |in| data supplied. 24 | // |out| must be previously allocated and it must be at least of |length|. 25 | virtual void Filter(const float* in, size_t length, float* out) = 0; 26 | }; 27 | 28 | } // namespace webrtc 29 | 30 | #endif // COMMON_AUDIO_FIR_FILTER_H_ 31 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/compile_assert_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_COMPILE_ASSERT_C_H_ 12 | #define RTC_BASE_COMPILE_ASSERT_C_H_ 13 | 14 | // Use this macro to verify at compile time that certain restrictions are met. 15 | // The argument is the boolean expression to evaluate. 16 | // Example: 17 | // RTC_COMPILE_ASSERT(sizeof(foo) < 128); 18 | // Note: In C++, use static_assert instead! 19 | #define RTC_COMPILE_ASSERT(expression) \ 20 | switch (0) { \ 21 | case 0: \ 22 | case expression:; \ 23 | } 24 | 25 | #endif // RTC_BASE_COMPILE_ASSERT_C_H_ 26 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/level_estimator.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/level_estimator.h" 12 | 13 | #include "api/array_view.h" 14 | 15 | namespace webrtc { 16 | 17 | LevelEstimator::LevelEstimator() { 18 | rms_.Reset(); 19 | } 20 | 21 | LevelEstimator::~LevelEstimator() = default; 22 | 23 | void LevelEstimator::ProcessStream(const AudioBuffer& audio) { 24 | for (size_t i = 0; i < audio.num_channels(); i++) { 25 | rms_.Analyze(rtc::ArrayView(audio.channels_const()[i], 26 | audio.num_frames())); 27 | } 28 | } 29 | } // namespace webrtc 30 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/third_party/spl_sqrt_floor/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by Wilco Dijkstra, 1996. The following email exchange establishes the 3 | * license. 4 | * 5 | * From: Wilco Dijkstra 6 | * Date: Fri, Jun 24, 2011 at 3:20 AM 7 | * Subject: Re: sqrt routine 8 | * To: Kevin Ma 9 | * Hi Kevin, 10 | * Thanks for asking. Those routines are public domain (originally posted to 11 | * comp.sys.arm a long time ago), so you can use them freely for any purpose. 12 | * Cheers, 13 | * Wilco 14 | * 15 | * ----- Original Message ----- 16 | * From: "Kevin Ma" 17 | * To: 18 | * Sent: Thursday, June 23, 2011 11:44 PM 19 | * Subject: Fwd: sqrt routine 20 | * Hi Wilco, 21 | * I saw your sqrt routine from several web sites, including 22 | * http://www.finesse.demon.co.uk/steven/sqrt.html. 23 | * Just wonder if there's any copyright information with your Successive 24 | * approximation routines, or if I can freely use it for any purpose. 25 | * Thanks. 26 | * Kevin 27 | */ 28 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/units/frequency.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #include "api/units/frequency.h" 11 | 12 | #include "rtc_base/strings/string_builder.h" 13 | 14 | namespace webrtc { 15 | std::string ToString(Frequency value) { 16 | char buf[64]; 17 | rtc::SimpleStringBuilder sb(buf); 18 | if (value.IsPlusInfinity()) { 19 | sb << "+inf Hz"; 20 | } else if (value.IsMinusInfinity()) { 21 | sb << "-inf Hz"; 22 | } else if (value.millihertz() % 1000 != 0) { 23 | sb.AppendFormat("%.3f Hz", value.hertz()); 24 | } else { 25 | sb << value.hertz() << " Hz"; 26 | } 27 | return sb.str(); 28 | } 29 | } // namespace webrtc 30 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/spectrum_buffer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/aec3/spectrum_buffer.h" 12 | 13 | #include 14 | 15 | namespace webrtc { 16 | 17 | SpectrumBuffer::SpectrumBuffer(size_t size, size_t num_channels) 18 | : size(static_cast(size)), 19 | buffer(size, 20 | std::vector>(num_channels)) { 21 | for (auto& channel : buffer) { 22 | for (auto& c : channel) { 23 | std::fill(c.begin(), c.end(), 0.f); 24 | } 25 | } 26 | } 27 | 28 | SpectrumBuffer::~SpectrumBuffer() = default; 29 | 30 | } // namespace webrtc 31 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | 13 | // 14 | // WebRtcSpl_SqrtFloor(...) 15 | // 16 | // Returns the square root of the input value |value|. The precision of this 17 | // function is rounding down integer precision, i.e., sqrt(8) gives 2 as answer. 18 | // If |value| is a negative number then 0 is returned. 19 | // 20 | // Algorithm: 21 | // 22 | // An iterative 4 cylce/bit routine 23 | // 24 | // Input: 25 | // - value : Value to calculate sqrt of 26 | // 27 | // Return value : Result of the sqrt calculation 28 | // 29 | int32_t WebRtcSpl_SqrtFloor(int32_t value); 30 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/vad/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_VAD_COMMON_H_ 12 | #define MODULES_AUDIO_PROCESSING_VAD_COMMON_H_ 13 | 14 | #include 15 | 16 | static const int kSampleRateHz = 16000; 17 | static const size_t kLength10Ms = kSampleRateHz / 100; 18 | static const size_t kMaxNumFrames = 4; 19 | 20 | struct AudioFeatures { 21 | double log_pitch_gain[kMaxNumFrames]; 22 | double pitch_lag_hz[kMaxNumFrames]; 23 | double spectral_peak[kMaxNumFrames]; 24 | double rms[kMaxNumFrames]; 25 | size_t num_frames; 26 | bool silence; 27 | }; 28 | 29 | #endif // MODULES_AUDIO_PROCESSING_VAD_COMMON_H_ 30 | -------------------------------------------------------------------------------- /jni/src/webrtc/system_wrappers/source/sleep.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | // An OS-independent sleep function. 11 | 12 | #include "system_wrappers/include/sleep.h" 13 | 14 | #ifdef _WIN32 15 | // For Sleep() 16 | #include 17 | #else 18 | // For nanosleep() 19 | #include 20 | #endif 21 | 22 | namespace webrtc { 23 | 24 | void SleepMs(int msecs) { 25 | #ifdef _WIN32 26 | Sleep(msecs); 27 | #else 28 | struct timespec short_wait; 29 | struct timespec remainder; 30 | short_wait.tv_sec = msecs / 1000; 31 | short_wait.tv_nsec = (msecs % 1000) * 1000 * 1000; 32 | nanosleep(&short_wait, &remainder); 33 | #endif 34 | } 35 | 36 | } // namespace webrtc 37 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/rnn_vad/common.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/agc2/rnn_vad/common.h" 12 | 13 | #include "rtc_base/system/arch.h" 14 | #include "system_wrappers/include/cpu_features_wrapper.h" 15 | 16 | namespace webrtc { 17 | namespace rnn_vad { 18 | 19 | Optimization DetectOptimization() { 20 | #if defined(WEBRTC_ARCH_X86_FAMILY) 21 | if (GetCPUInfo(kSSE2) != 0) { 22 | return Optimization::kSse2; 23 | } 24 | #endif 25 | 26 | #if defined(WEBRTC_HAS_NEON) 27 | return Optimization::kNeon; 28 | #endif 29 | 30 | return Optimization::kNone; 31 | } 32 | 33 | } // namespace rnn_vad 34 | } // namespace webrtc 35 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/thread_checker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Borrowed from Chromium's src/base/threading/thread_checker.h. 12 | 13 | #ifndef RTC_BASE_THREAD_CHECKER_H_ 14 | #define RTC_BASE_THREAD_CHECKER_H_ 15 | 16 | #include "rtc_base/deprecation.h" 17 | #include "rtc_base/synchronization/sequence_checker.h" 18 | 19 | namespace rtc { 20 | // TODO(srte): Replace usages of this with SequenceChecker. 21 | class ThreadChecker : public webrtc::SequenceChecker { 22 | public: 23 | RTC_DEPRECATED bool CalledOnValidThread() const { return IsCurrent(); } 24 | RTC_DEPRECATED void DetachFromThread() { Detach(); } 25 | }; 26 | } // namespace rtc 27 | #endif // RTC_BASE_THREAD_CHECKER_H_ 28 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/delay_estimate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_DELAY_ESTIMATE_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_DELAY_ESTIMATE_H_ 13 | 14 | namespace webrtc { 15 | 16 | // Stores delay_estimates. 17 | struct DelayEstimate { 18 | enum class Quality { kCoarse, kRefined }; 19 | 20 | DelayEstimate(Quality quality, size_t delay) 21 | : quality(quality), delay(delay) {} 22 | 23 | Quality quality; 24 | size_t delay; 25 | size_t blocks_since_last_change = 0; 26 | size_t blocks_since_last_update = 0; 27 | }; 28 | 29 | } // namespace webrtc 30 | 31 | #endif // MODULES_AUDIO_PROCESSING_AEC3_DELAY_ESTIMATE_H_ 32 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/units/data_rate.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "api/units/data_rate.h" 12 | 13 | #include "api/array_view.h" 14 | #include "rtc_base/strings/string_builder.h" 15 | 16 | namespace webrtc { 17 | 18 | std::string ToString(DataRate value) { 19 | char buf[64]; 20 | rtc::SimpleStringBuilder sb(buf); 21 | if (value.IsPlusInfinity()) { 22 | sb << "+inf bps"; 23 | } else if (value.IsMinusInfinity()) { 24 | sb << "-inf bps"; 25 | } else { 26 | if (value.bps() == 0 || value.bps() % 1000 != 0) { 27 | sb << value.bps() << " bps"; 28 | } else { 29 | sb << value.kbps() << " kbps"; 30 | } 31 | } 32 | return sb.str(); 33 | } 34 | } // namespace webrtc 35 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/rnn_vad/pitch_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_INFO_H_ 12 | #define MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_INFO_H_ 13 | 14 | namespace webrtc { 15 | namespace rnn_vad { 16 | 17 | // Stores pitch period and gain information. The pitch gain measures the 18 | // strength of the pitch (the higher, the stronger). 19 | struct PitchInfo { 20 | PitchInfo() : period(0), gain(0.f) {} 21 | PitchInfo(int p, float g) : period(p), gain(g) {} 22 | int period; 23 | float gain; 24 | }; 25 | 26 | } // namespace rnn_vad 27 | } // namespace webrtc 28 | 29 | #endif // MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_INFO_H_ 30 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/optionally_built_submodule_creators.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/optionally_built_submodule_creators.h" 12 | 13 | #include 14 | 15 | #include "modules/audio_processing/transient/transient_suppressor_impl.h" 16 | 17 | namespace webrtc { 18 | 19 | std::unique_ptr CreateTransientSuppressor( 20 | const ApmSubmoduleCreationOverrides& overrides) { 21 | #ifdef WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR 22 | return nullptr; 23 | #else 24 | if (overrides.transient_suppression) { 25 | return nullptr; 26 | } 27 | return std::make_unique(); 28 | #endif 29 | } 30 | 31 | } // namespace webrtc 32 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/main/source/filter_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FILTER_FUNCTIONS_H_ 12 | #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FILTER_FUNCTIONS_H_ 13 | 14 | #include "modules/audio_coding/codecs/isac/main/source/structs.h" 15 | 16 | void WebRtcIsac_AutoCorr(double* r, const double* x, size_t N, size_t order); 17 | 18 | void WebRtcIsac_WeightingFilter(const double* in, 19 | double* weiout, 20 | double* whiout, 21 | WeightFiltstr* wfdata); 22 | 23 | #endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FILTER_FUNCTIONS_H_ 24 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/window_generator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_WINDOW_GENERATOR_H_ 12 | #define COMMON_AUDIO_WINDOW_GENERATOR_H_ 13 | 14 | #include 15 | 16 | namespace webrtc { 17 | 18 | // Helper class with generators for various signal transform windows. 19 | class WindowGenerator { 20 | public: 21 | WindowGenerator() = delete; 22 | WindowGenerator(const WindowGenerator&) = delete; 23 | WindowGenerator& operator=(const WindowGenerator&) = delete; 24 | 25 | static void Hanning(int length, float* window); 26 | static void KaiserBesselDerived(float alpha, size_t length, float* window); 27 | }; 28 | 29 | } // namespace webrtc 30 | 31 | #endif // COMMON_AUDIO_WINDOW_GENERATOR_H_ 32 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/echo_detector/moving_max.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_MOVING_MAX_H_ 12 | #define MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_MOVING_MAX_H_ 13 | 14 | #include 15 | 16 | namespace webrtc { 17 | 18 | class MovingMax { 19 | public: 20 | explicit MovingMax(size_t window_size); 21 | ~MovingMax(); 22 | 23 | void Update(float value); 24 | float max() const; 25 | // Reset all of the state in this class. 26 | void Clear(); 27 | 28 | private: 29 | float max_value_ = 0.f; 30 | size_t counter_ = 0; 31 | size_t window_size_ = 1; 32 | }; 33 | 34 | } // namespace webrtc 35 | 36 | #endif // MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_MOVING_MAX_H_ 37 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/synchronization/yield.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "rtc_base/synchronization/yield.h" 12 | 13 | #if defined(WEBRTC_WIN) 14 | #include 15 | #else 16 | #include 17 | #include 18 | #endif 19 | 20 | namespace webrtc { 21 | 22 | void YieldCurrentThread() { 23 | // TODO(bugs.webrtc.org/11634): use dedicated OS functionality instead of 24 | // sleep for yielding. 25 | #if defined(WEBRTC_WIN) 26 | ::Sleep(0); 27 | #elif defined(WEBRTC_MAC) && defined(RTC_USE_NATIVE_MUTEX_ON_MAC) && \ 28 | !RTC_USE_NATIVE_MUTEX_ON_MAC 29 | sched_yield(); 30 | #else 31 | static const struct timespec ts_null = {0}; 32 | nanosleep(&ts_null, nullptr); 33 | #endif 34 | } 35 | 36 | } // namespace webrtc 37 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/system/warn_current_thread_is_deadlocked.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_SYSTEM_WARN_CURRENT_THREAD_IS_DEADLOCKED_H_ 12 | #define RTC_BASE_SYSTEM_WARN_CURRENT_THREAD_IS_DEADLOCKED_H_ 13 | 14 | namespace webrtc { 15 | 16 | #if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) 17 | /* webrtc-audio-processing: 18 | * We don't support the Android SDK integration for this, so stub out 19 | void WarnThatTheCurrentThreadIsProbablyDeadlocked(); 20 | */ 21 | inline void WarnThatTheCurrentThreadIsProbablyDeadlocked() {} 22 | #else 23 | inline void WarnThatTheCurrentThreadIsProbablyDeadlocked() {} 24 | #endif 25 | 26 | } // namespace webrtc 27 | 28 | #endif // RTC_BASE_SYSTEM_WARN_CURRENT_THREAD_IS_DEADLOCKED_H_ 29 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/signal_model.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_NS_SIGNAL_MODEL_H_ 12 | #define MODULES_AUDIO_PROCESSING_NS_SIGNAL_MODEL_H_ 13 | 14 | #include 15 | 16 | #include "modules/audio_processing/ns/ns_common.h" 17 | 18 | namespace webrtc { 19 | 20 | struct SignalModel { 21 | SignalModel(); 22 | SignalModel(const SignalModel&) = delete; 23 | SignalModel& operator=(const SignalModel&) = delete; 24 | 25 | float lrt; 26 | float spectral_diff; 27 | float spectral_flatness; 28 | // Log LRT factor with time-smoothing. 29 | std::array avg_log_lrt; 30 | }; 31 | 32 | } // namespace webrtc 33 | 34 | #endif // MODULES_AUDIO_PROCESSING_NS_SIGNAL_MODEL_H_ 35 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/synchronization/rw_lock_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_SYNCHRONIZATION_RW_LOCK_WIN_H_ 12 | #define RTC_BASE_SYNCHRONIZATION_RW_LOCK_WIN_H_ 13 | 14 | #include 15 | 16 | #include "rtc_base/synchronization/rw_lock_wrapper.h" 17 | 18 | namespace webrtc { 19 | 20 | class RWLockWin : public RWLockWrapper { 21 | public: 22 | static RWLockWin* Create(); 23 | 24 | void AcquireLockExclusive() override; 25 | void ReleaseLockExclusive() override; 26 | 27 | void AcquireLockShared() override; 28 | void ReleaseLockShared() override; 29 | 30 | private: 31 | RWLockWin(); 32 | 33 | SRWLOCK lock_; 34 | }; 35 | 36 | } // namespace webrtc 37 | 38 | #endif // RTC_BASE_SYNCHRONIZATION_RW_LOCK_WIN_H_ 39 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/units/timestamp.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "api/units/timestamp.h" 12 | 13 | #include "api/array_view.h" 14 | #include "rtc_base/strings/string_builder.h" 15 | 16 | namespace webrtc { 17 | std::string ToString(Timestamp value) { 18 | char buf[64]; 19 | rtc::SimpleStringBuilder sb(buf); 20 | if (value.IsPlusInfinity()) { 21 | sb << "+inf ms"; 22 | } else if (value.IsMinusInfinity()) { 23 | sb << "-inf ms"; 24 | } else { 25 | if (value.us() == 0 || (value.us() % 1000) != 0) 26 | sb << value.us() << " us"; 27 | else if (value.ms() % 1000 != 0) 28 | sb << value.ms() << " ms"; 29 | else 30 | sb << value.seconds() << " s"; 31 | } 32 | return sb.str(); 33 | } 34 | } // namespace webrtc 35 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/synchronization/rw_lock_win.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "rtc_base/synchronization/rw_lock_win.h" 12 | 13 | #include "rtc_base/logging.h" 14 | 15 | namespace webrtc { 16 | 17 | RWLockWin::RWLockWin() { 18 | InitializeSRWLock(&lock_); 19 | } 20 | 21 | RWLockWin* RWLockWin::Create() { 22 | return new RWLockWin(); 23 | } 24 | 25 | void RWLockWin::AcquireLockExclusive() { 26 | AcquireSRWLockExclusive(&lock_); 27 | } 28 | 29 | void RWLockWin::ReleaseLockExclusive() { 30 | ReleaseSRWLockExclusive(&lock_); 31 | } 32 | 33 | void RWLockWin::AcquireLockShared() { 34 | AcquireSRWLockShared(&lock_); 35 | } 36 | 37 | void RWLockWin::ReleaseLockShared() { 38 | ReleaseSRWLockShared(&lock_); 39 | } 40 | 41 | } // namespace webrtc 42 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/units/time_delta.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "api/units/time_delta.h" 12 | 13 | #include "api/array_view.h" 14 | #include "rtc_base/strings/string_builder.h" 15 | 16 | namespace webrtc { 17 | 18 | std::string ToString(TimeDelta value) { 19 | char buf[64]; 20 | rtc::SimpleStringBuilder sb(buf); 21 | if (value.IsPlusInfinity()) { 22 | sb << "+inf ms"; 23 | } else if (value.IsMinusInfinity()) { 24 | sb << "-inf ms"; 25 | } else { 26 | if (value.us() == 0 || (value.us() % 1000) != 0) 27 | sb << value.us() << " us"; 28 | else if (value.ms() % 1000 != 0) 29 | sb << value.ms() << " ms"; 30 | else 31 | sb << value.seconds() << " s"; 32 | } 33 | return sb.str(); 34 | } 35 | 36 | } // namespace webrtc 37 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /* 12 | * pitch_estimator.h 13 | * 14 | * Pitch functions 15 | * 16 | */ 17 | 18 | #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_ESTIMATOR_H_ 19 | #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_ESTIMATOR_H_ 20 | 21 | #include 22 | 23 | #include "modules/audio_coding/codecs/isac/main/source/structs.h" 24 | 25 | void WebRtcIsac_PitchAnalysis( 26 | const double* in, /* PITCH_FRAME_LEN samples */ 27 | double* out, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */ 28 | PitchAnalysisStruct* State, 29 | double* lags, 30 | double* gains); 31 | 32 | #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_ESTIMATOR_H_ */ 33 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_COMMON_H_ 12 | #define MODULES_AUDIO_PROCESSING_COMMON_H_ 13 | 14 | #include "modules/audio_processing/include/audio_processing.h" 15 | #include "rtc_base/checks.h" 16 | 17 | namespace webrtc { 18 | 19 | static inline size_t ChannelsFromLayout(AudioProcessing::ChannelLayout layout) { 20 | switch (layout) { 21 | case AudioProcessing::kMono: 22 | case AudioProcessing::kMonoAndKeyboard: 23 | return 1; 24 | case AudioProcessing::kStereo: 25 | case AudioProcessing::kStereoAndKeyboard: 26 | return 2; 27 | } 28 | RTC_NOTREACHED(); 29 | return 0; 30 | } 31 | 32 | } // namespace webrtc 33 | 34 | #endif // MODULES_AUDIO_PROCESSING_COMMON_H_ 35 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/suppression_params.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_NS_SUPPRESSION_PARAMS_H_ 12 | #define MODULES_AUDIO_PROCESSING_NS_SUPPRESSION_PARAMS_H_ 13 | 14 | #include "modules/audio_processing/ns/ns_config.h" 15 | 16 | namespace webrtc { 17 | 18 | struct SuppressionParams { 19 | explicit SuppressionParams(NsConfig::SuppressionLevel suppression_level); 20 | SuppressionParams(const SuppressionParams&) = delete; 21 | SuppressionParams& operator=(const SuppressionParams&) = delete; 22 | 23 | float over_subtraction_factor; 24 | float minimum_attenuating_gain; 25 | bool use_attenuation_adjustment; 26 | }; 27 | 28 | } // namespace webrtc 29 | 30 | #endif // MODULES_AUDIO_PROCESSING_NS_SUPPRESSION_PARAMS_H_ 31 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/fir_filter_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_FIR_FILTER_C_H_ 12 | #define COMMON_AUDIO_FIR_FILTER_C_H_ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include "common_audio/fir_filter.h" 19 | 20 | namespace webrtc { 21 | 22 | class FIRFilterC : public FIRFilter { 23 | public: 24 | FIRFilterC(const float* coefficients, size_t coefficients_length); 25 | ~FIRFilterC() override; 26 | 27 | void Filter(const float* in, size_t length, float* out) override; 28 | 29 | private: 30 | size_t coefficients_length_; 31 | size_t state_length_; 32 | std::unique_ptr coefficients_; 33 | std::unique_ptr state_; 34 | }; 35 | 36 | } // namespace webrtc 37 | 38 | #endif // COMMON_AUDIO_FIR_FILTER_C_H_ 39 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/meson.build: -------------------------------------------------------------------------------- 1 | api_sources = [ 2 | 'audio/audio_frame.cc', 3 | 'audio/channel_layout.cc', 4 | 'audio/echo_canceller3_config.cc', 5 | 'audio_codecs/audio_decoder.cc', 6 | 'audio_codecs/audio_encoder.cc', 7 | 'rtp_headers.cc', 8 | 'rtp_packet_info.cc', 9 | 'task_queue/task_queue_base.cc', 10 | 'units/data_rate.cc', 11 | 'units/data_size.cc', 12 | 'units/frequency.cc', 13 | 'units/time_delta.cc', 14 | 'units/timestamp.cc', 15 | 'video/color_space.cc', 16 | 'video/hdr_metadata.cc', 17 | 'video/video_content_type.cc', 18 | 'video/video_timing.cc', 19 | ] 20 | 21 | api_headers = [ 22 | ['', 'array_view.h'], 23 | ['', 'scoped_refptr.h'], 24 | ['audio', 'echo_canceller3_config.h'], 25 | ['audio', 'echo_control.h'], 26 | ] 27 | 28 | foreach h : api_headers 29 | install_headers( 30 | join_paths(h[0], h[1]), 31 | subdir: join_paths(include_subdir, 'api', h[0]) 32 | ) 33 | endforeach 34 | 35 | 36 | libapi = static_library('libapi', 37 | api_sources, 38 | dependencies: common_deps, 39 | include_directories: webrtc_inc, 40 | cpp_args : common_cxxflags 41 | ) 42 | 43 | api_dep = declare_dependency( 44 | link_with: libapi 45 | ) 46 | 47 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/signal_processing/spl_inl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | 13 | #include "common_audio/signal_processing/include/spl_inl.h" 14 | 15 | // Table used by WebRtcSpl_CountLeadingZeros32_NotBuiltin. For each uint32_t n 16 | // that's a sequence of 0 bits followed by a sequence of 1 bits, the entry at 17 | // index (n * 0x8c0b2891) >> 26 in this table gives the number of zero bits in 18 | // n. 19 | const int8_t kWebRtcSpl_CountLeadingZeros32_Table[64] = { 20 | 32, 8, 17, -1, -1, 14, -1, -1, -1, 20, -1, -1, -1, 28, -1, 18, 21 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 26, 25, 24, 22 | 4, 11, 23, 31, 3, 7, 10, 16, 22, 30, -1, -1, 2, 6, 13, 9, 23 | -1, 15, -1, 21, -1, 29, 19, -1, -1, -1, -1, -1, 1, 27, 5, 12, 24 | }; 25 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/agc2_testing_common.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/agc2/agc2_testing_common.h" 12 | 13 | #include "rtc_base/checks.h" 14 | 15 | namespace webrtc { 16 | 17 | namespace test { 18 | 19 | std::vector LinSpace(const double l, 20 | const double r, 21 | size_t num_points) { 22 | RTC_CHECK(num_points >= 2); 23 | std::vector points(num_points); 24 | const double step = (r - l) / (num_points - 1.0); 25 | points[0] = l; 26 | for (size_t i = 1; i < num_points - 1; i++) { 27 | points[i] = static_cast(l) + i * step; 28 | } 29 | points[num_points - 1] = r; 30 | return points; 31 | } 32 | } // namespace test 33 | } // namespace webrtc 34 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/zero_memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_ZERO_MEMORY_H_ 12 | #define RTC_BASE_ZERO_MEMORY_H_ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include "api/array_view.h" 19 | 20 | namespace rtc { 21 | 22 | // Fill memory with zeros in a way that the compiler doesn't optimize it away 23 | // even if the pointer is not used afterwards. 24 | void ExplicitZeroMemory(void* ptr, size_t len); 25 | 26 | template ::value && 28 | std::is_trivial::value>::type* = nullptr> 29 | void ExplicitZeroMemory(rtc::ArrayView a) { 30 | ExplicitZeroMemory(a.data(), a.size()); 31 | } 32 | 33 | } // namespace rtc 34 | 35 | #endif // RTC_BASE_ZERO_MEMORY_H_ 36 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/synchronization/mutex.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "rtc_base/synchronization/mutex.h" 12 | 13 | #include "rtc_base/checks.h" 14 | #include "rtc_base/synchronization/yield.h" 15 | 16 | namespace webrtc { 17 | 18 | #if !defined(WEBRTC_ABSL_MUTEX) 19 | void GlobalMutex::Lock() { 20 | while (mutex_locked_.exchange(1)) { 21 | YieldCurrentThread(); 22 | } 23 | } 24 | 25 | void GlobalMutex::Unlock() { 26 | int old = mutex_locked_.exchange(0); 27 | RTC_DCHECK_EQ(old, 1) << "Unlock called without calling Lock first"; 28 | } 29 | 30 | GlobalMutexLock::GlobalMutexLock(GlobalMutex* mutex) : mutex_(mutex) { 31 | mutex_->Lock(); 32 | } 33 | 34 | GlobalMutexLock::~GlobalMutexLock() { 35 | mutex_->Unlock(); 36 | } 37 | #endif // #if !defined(WEBRTC_ABSL_MUTEX) 38 | 39 | } // namespace webrtc 40 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/synchronization/rw_lock_posix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_SYNCHRONIZATION_RW_LOCK_POSIX_H_ 12 | #define RTC_BASE_SYNCHRONIZATION_RW_LOCK_POSIX_H_ 13 | 14 | #include 15 | 16 | #include "rtc_base/synchronization/rw_lock_wrapper.h" 17 | 18 | namespace webrtc { 19 | 20 | class RWLockPosix : public RWLockWrapper { 21 | public: 22 | static RWLockPosix* Create(); 23 | ~RWLockPosix() override; 24 | 25 | void AcquireLockExclusive() override; 26 | void ReleaseLockExclusive() override; 27 | 28 | void AcquireLockShared() override; 29 | void ReleaseLockShared() override; 30 | 31 | private: 32 | RWLockPosix(); 33 | bool Init(); 34 | 35 | pthread_rwlock_t lock_; 36 | }; 37 | 38 | } // namespace webrtc 39 | 40 | #endif // RTC_BASE_SYNCHRONIZATION_RW_LOCK_POSIX_H_ 41 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/third_party/fft/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c)1995,97 Mark Olesen 3 | * Queen's Univ at Kingston (Canada) 4 | * 5 | * Permission to use, copy, modify, and distribute this software for 6 | * any purpose without fee is hereby granted, provided that this 7 | * entire notice is included in all copies of any software which is 8 | * or includes a copy or modification of this software and in all 9 | * copies of the supporting documentation for such software. 10 | * 11 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR 12 | * IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR QUEEN'S 13 | * UNIVERSITY AT KINGSTON MAKES ANY REPRESENTATION OR WARRANTY OF ANY 14 | * KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS 15 | * FITNESS FOR ANY PARTICULAR PURPOSE. 16 | * 17 | * All of which is to say that you can do what you like with this 18 | * source code provided you don't try to sell it as your own and you 19 | * include an unaltered copy of this message (including the 20 | * copyright). 21 | * 22 | * It is also implicitly understood that bug fixes and improvements 23 | * should make their way back to the general Internet community so 24 | * that everyone benefits. 25 | */ 26 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/echo_detector/mean_variance_estimator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_MEAN_VARIANCE_ESTIMATOR_H_ 12 | #define MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_MEAN_VARIANCE_ESTIMATOR_H_ 13 | 14 | namespace webrtc { 15 | 16 | // This class iteratively estimates the mean and variance of a signal. 17 | class MeanVarianceEstimator { 18 | public: 19 | void Update(float value); 20 | float std_deviation() const; 21 | float mean() const; 22 | void Clear(); 23 | 24 | private: 25 | // Estimate of the expected value of the input values. 26 | float mean_ = 0.f; 27 | // Estimate of the variance of the input values. 28 | float variance_ = 0.f; 29 | }; 30 | 31 | } // namespace webrtc 32 | 33 | #endif // MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_MEAN_VARIANCE_ESTIMATOR_H_ 34 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/prior_signal_model.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_NS_PRIOR_SIGNAL_MODEL_H_ 12 | #define MODULES_AUDIO_PROCESSING_NS_PRIOR_SIGNAL_MODEL_H_ 13 | 14 | namespace webrtc { 15 | 16 | // Struct for storing the prior signal model parameters. 17 | struct PriorSignalModel { 18 | explicit PriorSignalModel(float lrt_initial_value); 19 | PriorSignalModel(const PriorSignalModel&) = delete; 20 | PriorSignalModel& operator=(const PriorSignalModel&) = delete; 21 | 22 | float lrt; 23 | float flatness_threshold = .5f; 24 | float template_diff_threshold = .5f; 25 | float lrt_weighting = 1.f; 26 | float flatness_weighting = 0.f; 27 | float difference_weighting = 0.f; 28 | }; 29 | 30 | } // namespace webrtc 31 | 32 | #endif // MODULES_AUDIO_PROCESSING_NS_PRIOR_SIGNAL_MODEL_H_ 33 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc/utility.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/agc/utility.h" 12 | 13 | #include 14 | 15 | namespace webrtc { 16 | 17 | static const double kLog10 = 2.30258509299; 18 | static const double kLinear2DbScale = 20.0 / kLog10; 19 | static const double kLinear2LoudnessScale = 13.4 / kLog10; 20 | 21 | double Loudness2Db(double loudness) { 22 | return loudness * kLinear2DbScale / kLinear2LoudnessScale; 23 | } 24 | 25 | double Linear2Loudness(double rms) { 26 | if (rms == 0) 27 | return -15; 28 | return kLinear2LoudnessScale * log(rms); 29 | } 30 | 31 | double Db2Loudness(double db) { 32 | return db * kLinear2LoudnessScale / kLinear2DbScale; 33 | } 34 | 35 | double Dbfs2Loudness(double dbfs) { 36 | return Db2Loudness(90 + dbfs); 37 | } 38 | 39 | } // namespace webrtc 40 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/render_queue_item_verifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_RENDER_QUEUE_ITEM_VERIFIER_H_ 12 | #define MODULES_AUDIO_PROCESSING_RENDER_QUEUE_ITEM_VERIFIER_H_ 13 | 14 | #include 15 | 16 | namespace webrtc { 17 | 18 | // Functor to use when supplying a verifier function for the queue item 19 | // verifcation. 20 | template 21 | class RenderQueueItemVerifier { 22 | public: 23 | explicit RenderQueueItemVerifier(size_t minimum_capacity) 24 | : minimum_capacity_(minimum_capacity) {} 25 | 26 | bool operator()(const std::vector& v) const { 27 | return v.capacity() >= minimum_capacity_; 28 | } 29 | 30 | private: 31 | size_t minimum_capacity_; 32 | }; 33 | 34 | } // namespace webrtc 35 | 36 | #endif // MODULES_AUDIO_PROCESSING_RENDER_QUEUE_ITEM_VERIFIER_H__ 37 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/ns_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_NS_NS_COMMON_H_ 12 | #define MODULES_AUDIO_PROCESSING_NS_NS_COMMON_H_ 13 | 14 | #include 15 | 16 | namespace webrtc { 17 | 18 | constexpr size_t kFftSize = 256; 19 | constexpr size_t kFftSizeBy2Plus1 = kFftSize / 2 + 1; 20 | constexpr size_t kNsFrameSize = 160; 21 | constexpr size_t kOverlapSize = kFftSize - kNsFrameSize; 22 | 23 | constexpr int kShortStartupPhaseBlocks = 50; 24 | constexpr int kLongStartupPhaseBlocks = 200; 25 | constexpr int kFeatureUpdateWindowSize = 500; 26 | 27 | constexpr float kLtrFeatureThr = 0.5f; 28 | constexpr float kBinSizeLrt = 0.1f; 29 | constexpr float kBinSizeSpecFlat = 0.05f; 30 | constexpr float kBinSizeSpecDiff = 0.1f; 31 | 32 | } // namespace webrtc 33 | 34 | #endif // MODULES_AUDIO_PROCESSING_NS_NS_COMMON_H_ 35 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/echo_path_variability.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_ECHO_PATH_VARIABILITY_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_ECHO_PATH_VARIABILITY_H_ 13 | 14 | namespace webrtc { 15 | 16 | struct EchoPathVariability { 17 | enum class DelayAdjustment { 18 | kNone, 19 | kBufferFlush, 20 | kNewDetectedDelay 21 | }; 22 | 23 | EchoPathVariability(bool gain_change, 24 | DelayAdjustment delay_change, 25 | bool clock_drift); 26 | 27 | bool AudioPathChanged() const { 28 | return gain_change || delay_change != DelayAdjustment::kNone; 29 | } 30 | bool gain_change; 31 | DelayAdjustment delay_change; 32 | bool clock_drift; 33 | }; 34 | 35 | } // namespace webrtc 36 | 37 | #endif // MODULES_AUDIO_PROCESSING_AEC3_ECHO_PATH_VARIABILITY_H_ 38 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/fir_filter_factory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_FIR_FILTER_FACTORY_H_ 12 | #define COMMON_AUDIO_FIR_FILTER_FACTORY_H_ 13 | 14 | #include 15 | 16 | namespace webrtc { 17 | 18 | class FIRFilter; 19 | 20 | // Creates a filter with the given coefficients. All initial state values will 21 | // be zeros. 22 | // The length of the chunks fed to the filter should never be greater than 23 | // |max_input_length|. This is needed because, when vectorizing it is 24 | // necessary to concatenate the input after the state, and resizing this array 25 | // dynamically is expensive. 26 | FIRFilter* CreateFirFilter(const float* coefficients, 27 | size_t coefficients_length, 28 | size_t max_input_length); 29 | 30 | } // namespace webrtc 31 | 32 | #endif // COMMON_AUDIO_FIR_FILTER_FACTORY_H_ 33 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc/mock_agc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC_MOCK_AGC_H_ 12 | #define MODULES_AUDIO_PROCESSING_AGC_MOCK_AGC_H_ 13 | 14 | #include "modules/audio_processing/agc/agc.h" 15 | #include "test/gmock.h" 16 | 17 | namespace webrtc { 18 | 19 | class MockAgc : public Agc { 20 | public: 21 | virtual ~MockAgc() {} 22 | MOCK_METHOD(void, 23 | Process, 24 | (const int16_t* audio, size_t length, int sample_rate_hz), 25 | (override)); 26 | MOCK_METHOD(bool, GetRmsErrorDb, (int* error), (override)); 27 | MOCK_METHOD(void, Reset, (), (override)); 28 | MOCK_METHOD(int, set_target_level_dbfs, (int level), (override)); 29 | MOCK_METHOD(int, target_level_dbfs, (), (const, override)); 30 | }; 31 | 32 | } // namespace webrtc 33 | 34 | #endif // MODULES_AUDIO_PROCESSING_AGC_MOCK_AGC_H_ 35 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_SqrtOfOneMinusXSquared(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | void WebRtcSpl_SqrtOfOneMinusXSquared(int16_t *xQ15, size_t vector_length, 21 | int16_t *yQ15) 22 | { 23 | int32_t sq; 24 | size_t m; 25 | int16_t tmp; 26 | 27 | for (m = 0; m < vector_length; m++) 28 | { 29 | tmp = xQ15[m]; 30 | sq = tmp * tmp; // x^2 in Q30 31 | sq = 1073741823 - sq; // 1-x^2, where 1 ~= 0.99999999906 is 1073741823 in Q30 32 | sq = WebRtcSpl_Sqrt(sq); // sqrt(1-x^2) in Q15 33 | yQ15[m] = (int16_t)sq; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/system/ignore_warnings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_SYSTEM_IGNORE_WARNINGS_H_ 12 | #define RTC_BASE_SYSTEM_IGNORE_WARNINGS_H_ 13 | 14 | #ifdef __clang__ 15 | #define RTC_PUSH_IGNORING_WFRAME_LARGER_THAN() \ 16 | _Pragma("clang diagnostic push") \ 17 | _Pragma("clang diagnostic ignored \"-Wframe-larger-than=\"") 18 | #define RTC_POP_IGNORING_WFRAME_LARGER_THAN() _Pragma("clang diagnostic pop") 19 | #elif __GNUC__ 20 | #define RTC_PUSH_IGNORING_WFRAME_LARGER_THAN() \ 21 | _Pragma("GCC diagnostic push") \ 22 | _Pragma("GCC diagnostic ignored \"-Wframe-larger-than=\"") 23 | #define RTC_POP_IGNORING_WFRAME_LARGER_THAN() _Pragma("GCC diagnostic pop") 24 | #else 25 | #define RTC_PUSH_IGNORING_WFRAME_LARGER_THAN() 26 | #define RTC_POP_IGNORING_WFRAME_LARGER_THAN() 27 | #endif 28 | 29 | #endif // RTC_BASE_SYSTEM_IGNORE_WARNINGS_H_ 30 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/ignore_wundef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_IGNORE_WUNDEF_H_ 12 | #define RTC_BASE_IGNORE_WUNDEF_H_ 13 | 14 | // If a header file uses #if on possibly undefined macros (and it's for some 15 | // reason not possible to just fix the header file), include it like this: 16 | // 17 | // RTC_PUSH_IGNORING_WUNDEF() 18 | // #include "misbehaving_header.h" 19 | // RTC_POP_IGNORING_WUNDEF() 20 | // 21 | // This will cause the compiler to not emit -Wundef warnings for that file. 22 | 23 | #ifdef __clang__ 24 | #define RTC_PUSH_IGNORING_WUNDEF() \ 25 | _Pragma("clang diagnostic push") \ 26 | _Pragma("clang diagnostic ignored \"-Wundef\"") 27 | #define RTC_POP_IGNORING_WUNDEF() _Pragma("clang diagnostic pop") 28 | #else 29 | #define RTC_PUSH_IGNORING_WUNDEF() 30 | #define RTC_POP_IGNORING_WUNDEF() 31 | #endif // __clang__ 32 | 33 | #endif // RTC_BASE_IGNORE_WUNDEF_H_ 34 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/fft_data_avx2.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/aec3/fft_data.h" 12 | 13 | #include 14 | 15 | #include "api/array_view.h" 16 | 17 | namespace webrtc { 18 | 19 | // Computes the power spectrum of the data. 20 | void FftData::SpectrumAVX2(rtc::ArrayView power_spectrum) const { 21 | RTC_DCHECK_EQ(kFftLengthBy2Plus1, power_spectrum.size()); 22 | for (size_t k = 0; k < kFftLengthBy2; k += 8) { 23 | __m256 r = _mm256_loadu_ps(&re[k]); 24 | __m256 i = _mm256_loadu_ps(&im[k]); 25 | __m256 ii = _mm256_mul_ps(i, i); 26 | ii = _mm256_fmadd_ps(r, r, ii); 27 | _mm256_storeu_ps(&power_spectrum[k], ii); 28 | } 29 | power_spectrum[kFftLengthBy2] = re[kFftLengthBy2] * re[kFftLengthBy2] + 30 | im[kFftLengthBy2] * im[kFftLengthBy2]; 31 | } 32 | 33 | } // namespace webrtc 34 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/signal_processing/energy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_Energy(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | int32_t WebRtcSpl_Energy(int16_t* vector, 21 | size_t vector_length, 22 | int* scale_factor) 23 | { 24 | int32_t en = 0; 25 | size_t i; 26 | int scaling = 27 | WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length); 28 | size_t looptimes = vector_length; 29 | int16_t *vectorptr = vector; 30 | 31 | for (i = 0; i < looptimes; i++) 32 | { 33 | en += (*vectorptr * *vectorptr) >> scaling; 34 | vectorptr++; 35 | } 36 | *scale_factor = scaling; 37 | 38 | return en; 39 | } 40 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/arraysize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_ARRAYSIZE_H_ 12 | #define RTC_BASE_ARRAYSIZE_H_ 13 | 14 | #include 15 | 16 | // This file defines the arraysize() macro and is derived from Chromium's 17 | // base/macros.h. 18 | 19 | // The arraysize(arr) macro returns the # of elements in an array arr. 20 | // The expression is a compile-time constant, and therefore can be 21 | // used in defining new arrays, for example. If you use arraysize on 22 | // a pointer by mistake, you will get a compile-time error. 23 | 24 | // This template function declaration is used in defining arraysize. 25 | // Note that the function doesn't need an implementation, as we only 26 | // use its type. 27 | template 28 | char (&ArraySizeHelper(T (&array)[N]))[N]; 29 | 30 | #define arraysize(array) (sizeof(ArraySizeHelper(array))) 31 | 32 | #endif // RTC_BASE_ARRAYSIZE_H_ 33 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/zero_memory.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #if defined(WEBRTC_WIN) 12 | #include 13 | #else 14 | #include 15 | #endif 16 | 17 | #include "rtc_base/checks.h" 18 | #include "rtc_base/zero_memory.h" 19 | 20 | namespace rtc { 21 | 22 | // Code and comment taken from "OPENSSL_cleanse" of BoringSSL. 23 | void ExplicitZeroMemory(void* ptr, size_t len) { 24 | RTC_DCHECK(ptr || !len); 25 | #if defined(WEBRTC_WIN) 26 | SecureZeroMemory(ptr, len); 27 | #else 28 | memset(ptr, 0, len); 29 | #if !defined(__pnacl__) 30 | /* As best as we can tell, this is sufficient to break any optimisations that 31 | might try to eliminate "superfluous" memsets. If there's an easy way to 32 | detect memset_s, it would be better to use that. */ 33 | __asm__ __volatile__("" : : "r"(ptr) : "memory"); // NOLINT 34 | #endif 35 | #endif // !WEBRTC_WIN 36 | } 37 | 38 | } // namespace rtc 39 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/ref_counted_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #ifndef API_REF_COUNTED_BASE_H_ 11 | #define API_REF_COUNTED_BASE_H_ 12 | 13 | #include "rtc_base/constructor_magic.h" 14 | #include "rtc_base/ref_count.h" 15 | #include "rtc_base/ref_counter.h" 16 | 17 | namespace rtc { 18 | 19 | class RefCountedBase { 20 | public: 21 | RefCountedBase() = default; 22 | 23 | void AddRef() const { ref_count_.IncRef(); } 24 | RefCountReleaseStatus Release() const { 25 | const auto status = ref_count_.DecRef(); 26 | if (status == RefCountReleaseStatus::kDroppedLastRef) { 27 | delete this; 28 | } 29 | return status; 30 | } 31 | 32 | protected: 33 | virtual ~RefCountedBase() = default; 34 | 35 | private: 36 | mutable webrtc::webrtc_impl::RefCounter ref_count_{0}; 37 | 38 | RTC_DISALLOW_COPY_AND_ASSIGN(RefCountedBase); 39 | }; 40 | 41 | } // namespace rtc 42 | 43 | #endif // API_REF_COUNTED_BASE_H_ 44 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/fir_filter_neon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_FIR_FILTER_NEON_H_ 12 | #define COMMON_AUDIO_FIR_FILTER_NEON_H_ 13 | 14 | #include 15 | 16 | #include "common_audio/fir_filter.h" 17 | #include "rtc_base/memory/aligned_malloc.h" 18 | 19 | namespace webrtc { 20 | 21 | class FIRFilterNEON : public FIRFilter { 22 | public: 23 | FIRFilterNEON(const float* coefficients, 24 | size_t coefficients_length, 25 | size_t max_input_length); 26 | ~FIRFilterNEON() override; 27 | 28 | void Filter(const float* in, size_t length, float* out) override; 29 | 30 | private: 31 | size_t coefficients_length_; 32 | size_t state_length_; 33 | std::unique_ptr coefficients_; 34 | std::unique_ptr state_; 35 | }; 36 | 37 | } // namespace webrtc 38 | 39 | #endif // COMMON_AUDIO_FIR_FILTER_NEON_H_ 40 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/signal_processing/cross_correlation.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "common_audio/signal_processing/include/signal_processing_library.h" 12 | 13 | /* C version of WebRtcSpl_CrossCorrelation() for generic platforms. */ 14 | void WebRtcSpl_CrossCorrelationC(int32_t* cross_correlation, 15 | const int16_t* seq1, 16 | const int16_t* seq2, 17 | size_t dim_seq, 18 | size_t dim_cross_correlation, 19 | int right_shifts, 20 | int step_seq2) { 21 | size_t i = 0, j = 0; 22 | 23 | for (i = 0; i < dim_cross_correlation; i++) { 24 | int32_t corr = 0; 25 | for (j = 0; j < dim_seq; j++) 26 | corr += (seq1[j] * seq2[j]) >> right_shifts; 27 | seq2 += step_seq2; 28 | *cross_correlation++ = corr; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/fir_filter_sse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_FIR_FILTER_SSE_H_ 12 | #define COMMON_AUDIO_FIR_FILTER_SSE_H_ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include "common_audio/fir_filter.h" 19 | #include "rtc_base/memory/aligned_malloc.h" 20 | 21 | namespace webrtc { 22 | 23 | class FIRFilterSSE2 : public FIRFilter { 24 | public: 25 | FIRFilterSSE2(const float* coefficients, 26 | size_t coefficients_length, 27 | size_t max_input_length); 28 | ~FIRFilterSSE2() override; 29 | 30 | void Filter(const float* in, size_t length, float* out) override; 31 | 32 | private: 33 | size_t coefficients_length_; 34 | size_t state_length_; 35 | std::unique_ptr coefficients_; 36 | std::unique_ptr state_; 37 | }; 38 | 39 | } // namespace webrtc 40 | 41 | #endif // COMMON_AUDIO_FIR_FILTER_SSE_H_ 42 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/main/source/crc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /* 12 | * crc.h 13 | * 14 | * Checksum functions 15 | * 16 | */ 17 | 18 | #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_ 19 | #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_ 20 | 21 | #include 22 | 23 | /**************************************************************************** 24 | * WebRtcIsac_GetCrc(...) 25 | * 26 | * This function returns a 32 bit CRC checksum of a bit stream 27 | * 28 | * Input: 29 | * - encoded : payload bit stream 30 | * - no_of_word8s : number of 8-bit words in the bit stream 31 | * 32 | * Output: 33 | * - crc : checksum 34 | * 35 | * Return value : 0 - Ok 36 | * -1 - Error 37 | */ 38 | 39 | int WebRtcIsac_GetCrc(const int16_t* encoded, int no_of_word8s, uint32_t* crc); 40 | 41 | #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_ */ 42 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/clockdrift_detector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_CLOCKDRIFT_DETECTOR_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_CLOCKDRIFT_DETECTOR_H_ 13 | 14 | #include 15 | 16 | #include 17 | 18 | namespace webrtc { 19 | 20 | class ApmDataDumper; 21 | struct DownsampledRenderBuffer; 22 | struct EchoCanceller3Config; 23 | 24 | // Detects clockdrift by analyzing the estimated delay. 25 | class ClockdriftDetector { 26 | public: 27 | enum class Level { kNone, kProbable, kVerified, kNumCategories }; 28 | ClockdriftDetector(); 29 | ~ClockdriftDetector(); 30 | void Update(int delay_estimate); 31 | Level ClockdriftLevel() const { return level_; } 32 | 33 | private: 34 | std::array delay_history_; 35 | Level level_; 36 | size_t stability_counter_; 37 | }; 38 | } // namespace webrtc 39 | 40 | #endif // MODULES_AUDIO_PROCESSING_AEC3_CLOCKDRIFT_DETECTOR_H_ 41 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/fir_filter_avx2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_FIR_FILTER_AVX2_H_ 12 | #define COMMON_AUDIO_FIR_FILTER_AVX2_H_ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include "common_audio/fir_filter.h" 19 | #include "rtc_base/memory/aligned_malloc.h" 20 | 21 | namespace webrtc { 22 | 23 | class FIRFilterAVX2 : public FIRFilter { 24 | public: 25 | FIRFilterAVX2(const float* coefficients, 26 | size_t coefficients_length, 27 | size_t max_input_length); 28 | ~FIRFilterAVX2() override; 29 | 30 | void Filter(const float* in, size_t length, float* out) override; 31 | 32 | private: 33 | const size_t coefficients_length_; 34 | const size_t state_length_; 35 | std::unique_ptr coefficients_; 36 | std::unique_ptr state_; 37 | }; 38 | 39 | } // namespace webrtc 40 | 41 | #endif // COMMON_AUDIO_FIR_FILTER_AVX2_H_ 42 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/system/rtc_export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_SYSTEM_RTC_EXPORT_H_ 12 | #define RTC_BASE_SYSTEM_RTC_EXPORT_H_ 13 | 14 | // RTC_EXPORT is used to mark symbols as exported or imported when WebRTC is 15 | // built or used as a shared library. 16 | // When WebRTC is built as a static library the RTC_EXPORT macro expands to 17 | // nothing. 18 | 19 | #ifdef WEBRTC_ENABLE_SYMBOL_EXPORT 20 | 21 | #ifdef WEBRTC_WIN 22 | 23 | #ifdef WEBRTC_LIBRARY_IMPL 24 | #define RTC_EXPORT __declspec(dllexport) 25 | #else 26 | #define RTC_EXPORT __declspec(dllimport) 27 | #endif 28 | 29 | #else // WEBRTC_WIN 30 | 31 | #if __has_attribute(visibility) && defined(WEBRTC_LIBRARY_IMPL) 32 | #define RTC_EXPORT __attribute__((visibility("default"))) 33 | #endif 34 | 35 | #endif // WEBRTC_WIN 36 | 37 | #endif // WEBRTC_ENABLE_SYMBOL_EXPORT 38 | 39 | #ifndef RTC_EXPORT 40 | #define RTC_EXPORT 41 | #endif 42 | 43 | #endif // RTC_BASE_SYSTEM_RTC_EXPORT_H_ 44 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/video/video_content_type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef API_VIDEO_VIDEO_CONTENT_TYPE_H_ 12 | #define API_VIDEO_VIDEO_CONTENT_TYPE_H_ 13 | 14 | #include 15 | 16 | namespace webrtc { 17 | 18 | enum class VideoContentType : uint8_t { 19 | UNSPECIFIED = 0, 20 | SCREENSHARE = 1, 21 | }; 22 | 23 | namespace videocontenttypehelpers { 24 | bool SetExperimentId(VideoContentType* content_type, uint8_t experiment_id); 25 | bool SetSimulcastId(VideoContentType* content_type, uint8_t simulcast_id); 26 | 27 | uint8_t GetExperimentId(const VideoContentType& content_type); 28 | uint8_t GetSimulcastId(const VideoContentType& content_type); 29 | 30 | bool IsScreenshare(const VideoContentType& content_type); 31 | 32 | bool IsValidContentType(uint8_t value); 33 | 34 | const char* ToString(const VideoContentType& content_type); 35 | } // namespace videocontenttypehelpers 36 | 37 | } // namespace webrtc 38 | 39 | #endif // API_VIDEO_VIDEO_CONTENT_TYPE_H_ 40 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/vad/pitch_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_VAD_PITCH_INTERNAL_H_ 12 | #define MODULES_AUDIO_PROCESSING_VAD_PITCH_INTERNAL_H_ 13 | 14 | namespace webrtc { 15 | 16 | // TODO(turajs): Write a description of this function. Also be consistent with 17 | // usage of |sampling_rate_hz| vs |kSamplingFreqHz|. 18 | void GetSubframesPitchParameters(int sampling_rate_hz, 19 | double* gains, 20 | double* lags, 21 | int num_in_frames, 22 | int num_out_frames, 23 | double* log_old_gain, 24 | double* old_lag, 25 | double* log_pitch_gain, 26 | double* pitch_lag_hz); 27 | 28 | } // namespace webrtc 29 | 30 | #endif // MODULES_AUDIO_PROCESSING_VAD_PITCH_INTERNAL_H_ 31 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ 12 | #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ 13 | 14 | #include 15 | 16 | #include "rtc_base/system/arch.h" 17 | 18 | #if defined(WEBRTC_POSIX) 19 | #define WebRtcIsac_lrint lrint 20 | #elif (defined(WEBRTC_ARCH_X86) && defined(WIN32)) 21 | static __inline long int WebRtcIsac_lrint(double x_dbl) { 22 | long int x_int; 23 | 24 | __asm { 25 | fld x_dbl 26 | fistp x_int 27 | } 28 | ; 29 | 30 | return x_int; 31 | } 32 | #else // Do a slow but correct implementation of lrint 33 | 34 | static __inline long int WebRtcIsac_lrint(double x_dbl) { 35 | long int x_int; 36 | x_int = (long int)floor(x_dbl + 0.499999999999); 37 | return x_int; 38 | } 39 | 40 | #endif 41 | 42 | #endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ 43 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/down_sampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC2_DOWN_SAMPLER_H_ 12 | #define MODULES_AUDIO_PROCESSING_AGC2_DOWN_SAMPLER_H_ 13 | 14 | #include "api/array_view.h" 15 | #include "modules/audio_processing/agc2/biquad_filter.h" 16 | 17 | namespace webrtc { 18 | 19 | class ApmDataDumper; 20 | 21 | class DownSampler { 22 | public: 23 | explicit DownSampler(ApmDataDumper* data_dumper); 24 | 25 | DownSampler() = delete; 26 | DownSampler(const DownSampler&) = delete; 27 | DownSampler& operator=(const DownSampler&) = delete; 28 | 29 | void Initialize(int sample_rate_hz); 30 | 31 | void DownSample(rtc::ArrayView in, rtc::ArrayView out); 32 | 33 | private: 34 | ApmDataDumper* data_dumper_; 35 | int sample_rate_hz_; 36 | int down_sampling_factor_; 37 | BiQuadFilter low_pass_filter_; 38 | }; 39 | 40 | } // namespace webrtc 41 | 42 | #endif // MODULES_AUDIO_PROCESSING_AGC2_DOWN_SAMPLER_H_ 43 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/task_queue/queued_task.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #ifndef API_TASK_QUEUE_QUEUED_TASK_H_ 11 | #define API_TASK_QUEUE_QUEUED_TASK_H_ 12 | 13 | namespace webrtc { 14 | 15 | // Base interface for asynchronously executed tasks. 16 | // The interface basically consists of a single function, Run(), that executes 17 | // on the target queue. For more details see the Run() method and TaskQueue. 18 | class QueuedTask { 19 | public: 20 | virtual ~QueuedTask() = default; 21 | 22 | // Main routine that will run when the task is executed on the desired queue. 23 | // The task should return |true| to indicate that it should be deleted or 24 | // |false| to indicate that the queue should consider ownership of the task 25 | // having been transferred. Returning |false| can be useful if a task has 26 | // re-posted itself to a different queue or is otherwise being re-used. 27 | virtual bool Run() = 0; 28 | }; 29 | 30 | } // namespace webrtc 31 | 32 | #endif // API_TASK_QUEUE_QUEUED_TASK_H_ 33 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_erl_avx2.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/aec3/adaptive_fir_filter_erl.h" 12 | 13 | #include 14 | 15 | namespace webrtc { 16 | 17 | namespace aec3 { 18 | 19 | // Computes and stores the echo return loss estimate of the filter, which is the 20 | // sum of the partition frequency responses. 21 | void ErlComputer_AVX2( 22 | const std::vector>& H2, 23 | rtc::ArrayView erl) { 24 | std::fill(erl.begin(), erl.end(), 0.f); 25 | for (auto& H2_j : H2) { 26 | for (size_t k = 0; k < kFftLengthBy2; k += 8) { 27 | const __m256 H2_j_k = _mm256_loadu_ps(&H2_j[k]); 28 | __m256 erl_k = _mm256_loadu_ps(&erl[k]); 29 | erl_k = _mm256_add_ps(erl_k, H2_j_k); 30 | _mm256_storeu_ps(&erl[k], erl_k); 31 | } 32 | erl[kFftLengthBy2] += H2_j[kFftLengthBy2]; 33 | } 34 | } 35 | 36 | } // namespace aec3 37 | } // namespace webrtc 38 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/block_buffer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/aec3/block_buffer.h" 12 | 13 | #include 14 | 15 | namespace webrtc { 16 | 17 | BlockBuffer::BlockBuffer(size_t size, 18 | size_t num_bands, 19 | size_t num_channels, 20 | size_t frame_length) 21 | : size(static_cast(size)), 22 | buffer(size, 23 | std::vector>>( 24 | num_bands, 25 | std::vector>( 26 | num_channels, 27 | std::vector(frame_length, 0.f)))) { 28 | for (auto& block : buffer) { 29 | for (auto& band : block) { 30 | for (auto& channel : band) { 31 | std::fill(channel.begin(), channel.end(), 0.f); 32 | } 33 | } 34 | } 35 | } 36 | 37 | BlockBuffer::~BlockBuffer() = default; 38 | 39 | } // namespace webrtc 40 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/fast_math.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_NS_FAST_MATH_H_ 12 | #define MODULES_AUDIO_PROCESSING_NS_FAST_MATH_H_ 13 | 14 | #include "api/array_view.h" 15 | 16 | namespace webrtc { 17 | 18 | // Sqrt approximation. 19 | float SqrtFastApproximation(float f); 20 | 21 | // Log base conversion log(x) = log2(x)/log2(e). 22 | float LogApproximation(float x); 23 | void LogApproximation(rtc::ArrayView x, rtc::ArrayView y); 24 | 25 | // 2^x approximation. 26 | float Pow2Approximation(float p); 27 | 28 | // x^p approximation. 29 | float PowApproximation(float x, float p); 30 | 31 | // e^x approximation. 32 | float ExpApproximation(float x); 33 | void ExpApproximation(rtc::ArrayView x, rtc::ArrayView y); 34 | void ExpApproximationSignFlip(rtc::ArrayView x, 35 | rtc::ArrayView y); 36 | } // namespace webrtc 37 | 38 | #endif // MODULES_AUDIO_PROCESSING_NS_FAST_MATH_H_ 39 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/signal_processing/dot_product_with_scale.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "common_audio/signal_processing/dot_product_with_scale.h" 12 | 13 | #include "rtc_base/numerics/safe_conversions.h" 14 | 15 | int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, 16 | const int16_t* vector2, 17 | size_t length, 18 | int scaling) { 19 | int64_t sum = 0; 20 | size_t i = 0; 21 | 22 | /* Unroll the loop to improve performance. */ 23 | for (i = 0; i + 3 < length; i += 4) { 24 | sum += (vector1[i + 0] * vector2[i + 0]) >> scaling; 25 | sum += (vector1[i + 1] * vector2[i + 1]) >> scaling; 26 | sum += (vector1[i + 2] * vector2[i + 2]) >> scaling; 27 | sum += (vector1[i + 3] * vector2[i + 3]) >> scaling; 28 | } 29 | for (; i < length; i++) { 30 | sum += (vector1[i] * vector2[i]) >> scaling; 31 | } 32 | 33 | return rtc::saturated_cast(sum); 34 | } 35 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/real_fourier_openmax.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_COMMON_AUDIO_REAL_FOURIER_OPENMAX_H_ 12 | #define WEBRTC_COMMON_AUDIO_REAL_FOURIER_OPENMAX_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/common_audio/real_fourier.h" 17 | 18 | namespace webrtc { 19 | 20 | class RealFourierOpenmax : public RealFourier { 21 | public: 22 | explicit RealFourierOpenmax(int fft_order); 23 | ~RealFourierOpenmax() override; 24 | 25 | void Forward(const float* src, std::complex* dest) const override; 26 | void Inverse(const std::complex* src, float* dest) const override; 27 | 28 | int order() const override { 29 | return order_; 30 | } 31 | 32 | private: 33 | // Basically a forward declare of OMXFFTSpec_R_F32. To get rid of the 34 | // dependency on openmax. 35 | typedef void OMXFFTSpec_R_F32_; 36 | const int order_; 37 | 38 | OMXFFTSpec_R_F32_* const omx_spec_; 39 | }; 40 | 41 | } // namespace webrtc 42 | 43 | #endif // WEBRTC_COMMON_AUDIO_REAL_FOURIER_OPENMAX_H_ 44 | 45 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/synchronization/rw_lock_posix.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "rtc_base/synchronization/rw_lock_posix.h" 12 | 13 | #include 14 | 15 | namespace webrtc { 16 | 17 | RWLockPosix::RWLockPosix() : lock_() {} 18 | 19 | RWLockPosix::~RWLockPosix() { 20 | pthread_rwlock_destroy(&lock_); 21 | } 22 | 23 | RWLockPosix* RWLockPosix::Create() { 24 | RWLockPosix* ret_val = new RWLockPosix(); 25 | if (!ret_val->Init()) { 26 | delete ret_val; 27 | return NULL; 28 | } 29 | return ret_val; 30 | } 31 | 32 | bool RWLockPosix::Init() { 33 | return pthread_rwlock_init(&lock_, 0) == 0; 34 | } 35 | 36 | void RWLockPosix::AcquireLockExclusive() { 37 | pthread_rwlock_wrlock(&lock_); 38 | } 39 | 40 | void RWLockPosix::ReleaseLockExclusive() { 41 | pthread_rwlock_unlock(&lock_); 42 | } 43 | 44 | void RWLockPosix::AcquireLockShared() { 45 | pthread_rwlock_rdlock(&lock_); 46 | } 47 | 48 | void RWLockPosix::ReleaseLockShared() { 49 | pthread_rwlock_unlock(&lock_); 50 | } 51 | 52 | } // namespace webrtc 53 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/synchronization/yield_policy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | #ifndef RTC_BASE_SYNCHRONIZATION_YIELD_POLICY_H_ 11 | #define RTC_BASE_SYNCHRONIZATION_YIELD_POLICY_H_ 12 | 13 | namespace rtc { 14 | class YieldInterface { 15 | public: 16 | virtual ~YieldInterface() = default; 17 | virtual void YieldExecution() = 0; 18 | }; 19 | 20 | // Sets the current thread-local yield policy while it's in scope and reverts 21 | // to the previous policy when it leaves the scope. 22 | class ScopedYieldPolicy final { 23 | public: 24 | explicit ScopedYieldPolicy(YieldInterface* policy); 25 | ScopedYieldPolicy(const ScopedYieldPolicy&) = delete; 26 | ScopedYieldPolicy& operator=(const ScopedYieldPolicy&) = delete; 27 | ~ScopedYieldPolicy(); 28 | // Will yield as specified by the currently active thread-local yield policy 29 | // (which by default is a no-op). 30 | static void YieldExecution(); 31 | 32 | private: 33 | YieldInterface* const previous_; 34 | }; 35 | 36 | } // namespace rtc 37 | 38 | #endif // RTC_BASE_SYNCHRONIZATION_YIELD_POLICY_H_ 39 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aecm/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import("../../../webrtc.gni") 10 | 11 | rtc_library("aecm_core") { 12 | sources = [ 13 | "aecm_core.cc", 14 | "aecm_core.h", 15 | "aecm_defines.h", 16 | "echo_control_mobile.cc", 17 | "echo_control_mobile.h", 18 | ] 19 | deps = [ 20 | "../../../common_audio:common_audio_c", 21 | "../../../rtc_base:checks", 22 | "../../../rtc_base:rtc_base_approved", 23 | "../../../rtc_base:sanitizer", 24 | "../../../system_wrappers", 25 | "../utility:legacy_delay_estimator", 26 | ] 27 | cflags = [] 28 | 29 | if (rtc_build_with_neon) { 30 | sources += [ "aecm_core_neon.cc" ] 31 | 32 | if (current_cpu != "arm64") { 33 | # Enable compilation for the NEON instruction set. 34 | suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ] 35 | cflags += [ "-mfpu=neon" ] 36 | } 37 | } 38 | 39 | if (current_cpu == "mipsel") { 40 | sources += [ "aecm_core_mips.cc" ] 41 | } else { 42 | sources += [ "aecm_core_c.cc" ] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/echo_detector/mean_variance_estimator.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/echo_detector/mean_variance_estimator.h" 12 | 13 | #include 14 | 15 | #include "rtc_base/checks.h" 16 | 17 | namespace webrtc { 18 | namespace { 19 | 20 | // Parameter controlling the adaptation speed. 21 | constexpr float kAlpha = 0.001f; 22 | 23 | } // namespace 24 | 25 | void MeanVarianceEstimator::Update(float value) { 26 | mean_ = (1.f - kAlpha) * mean_ + kAlpha * value; 27 | variance_ = 28 | (1.f - kAlpha) * variance_ + kAlpha * (value - mean_) * (value - mean_); 29 | RTC_DCHECK(isfinite(mean_)); 30 | RTC_DCHECK(isfinite(variance_)); 31 | } 32 | 33 | float MeanVarianceEstimator::std_deviation() const { 34 | RTC_DCHECK_GE(variance_, 0.f); 35 | return sqrtf(variance_); 36 | } 37 | 38 | float MeanVarianceEstimator::mean() const { 39 | return mean_; 40 | } 41 | 42 | void MeanVarianceEstimator::Clear() { 43 | mean_ = 0.f; 44 | variance_ = 0.f; 45 | } 46 | 47 | } // namespace webrtc 48 | -------------------------------------------------------------------------------- /jni/src/webrtc/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the WebRTC code package. 5 | 6 | Google hereby grants to you a perpetual, worldwide, non-exclusive, 7 | no-charge, irrevocable (except as stated in this section) patent 8 | license to make, have made, use, offer to sell, sell, import, 9 | transfer, and otherwise run, modify and propagate the contents of this 10 | implementation of the WebRTC code package, where such license applies 11 | only to those patent claims, both currently owned by Google and 12 | acquired in the future, licensable by Google that are necessarily 13 | infringed by this implementation of the WebRTC code package. This 14 | grant does not include claims that would be infringed only as a 15 | consequence of further modification of this implementation. If you or 16 | your agent or exclusive licensee institute or order or agree to the 17 | institution of patent litigation against any entity (including a 18 | cross-claim or counterclaim in a lawsuit) alleging that this 19 | implementation of the WebRTC code package or any code incorporated 20 | within this implementation of the WebRTC code package constitutes 21 | direct or contributory patent infringement, or inducement of patent 22 | infringement, then any patent rights granted to you under this License 23 | for this implementation of the WebRTC code package shall terminate as 24 | of the date such litigation is filed. 25 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/decimator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_DECIMATOR_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_DECIMATOR_H_ 13 | 14 | #include 15 | #include 16 | 17 | #include "api/array_view.h" 18 | #include "modules/audio_processing/aec3/aec3_common.h" 19 | #include "modules/audio_processing/utility/cascaded_biquad_filter.h" 20 | #include "rtc_base/constructor_magic.h" 21 | 22 | namespace webrtc { 23 | 24 | // Provides functionality for decimating a signal. 25 | class Decimator { 26 | public: 27 | explicit Decimator(size_t down_sampling_factor); 28 | 29 | // Downsamples the signal. 30 | void Decimate(rtc::ArrayView in, rtc::ArrayView out); 31 | 32 | private: 33 | const size_t down_sampling_factor_; 34 | CascadedBiQuadFilter anti_aliasing_filter_; 35 | CascadedBiQuadFilter noise_reduction_filter_; 36 | 37 | RTC_DISALLOW_COPY_AND_ASSIGN(Decimator); 38 | }; 39 | } // namespace webrtc 40 | 41 | #endif // MODULES_AUDIO_PROCESSING_AEC3_DECIMATOR_H_ 42 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/vector_float_frame.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/agc2/vector_float_frame.h" 12 | 13 | namespace webrtc { 14 | 15 | namespace { 16 | 17 | std::vector ConstructChannelPointers( 18 | std::vector>* x) { 19 | std::vector channel_ptrs; 20 | for (auto& v : *x) { 21 | channel_ptrs.push_back(v.data()); 22 | } 23 | return channel_ptrs; 24 | } 25 | } // namespace 26 | 27 | VectorFloatFrame::VectorFloatFrame(int num_channels, 28 | int samples_per_channel, 29 | float start_value) 30 | : channels_(num_channels, 31 | std::vector(samples_per_channel, start_value)), 32 | channel_ptrs_(ConstructChannelPointers(&channels_)), 33 | float_frame_view_(channel_ptrs_.data(), 34 | channels_.size(), 35 | samples_per_channel) {} 36 | 37 | VectorFloatFrame::~VectorFloatFrame() = default; 38 | 39 | } // namespace webrtc 40 | -------------------------------------------------------------------------------- /jni/src/webrtc/third_party/rnnoise/src/rnn_vad_weights.h: -------------------------------------------------------------------------------- 1 | #ifndef THIRD_PARTY_RNNOISE_SRC_RNN_VAD_WEIGHTS_H_ 2 | #define THIRD_PARTY_RNNOISE_SRC_RNN_VAD_WEIGHTS_H_ 3 | 4 | #include 5 | #include 6 | 7 | namespace rnnoise { 8 | 9 | // Weights scaling factor. 10 | const float kWeightsScale = 1.f / 256.f; 11 | 12 | // Input layer (dense). 13 | const size_t kInputLayerInputSize = 42; 14 | const size_t kInputLayerOutputSize = 24; 15 | const size_t kInputLayerWeights = kInputLayerInputSize * kInputLayerOutputSize; 16 | extern const int8_t kInputDenseWeights[kInputLayerWeights]; 17 | extern const int8_t kInputDenseBias[kInputLayerOutputSize]; 18 | 19 | // Hidden layer (GRU). 20 | const size_t kHiddenLayerOutputSize = 24; 21 | const size_t kHiddenLayerWeights = 22 | 3 * kInputLayerOutputSize * kHiddenLayerOutputSize; 23 | const size_t kHiddenLayerBiases = 3 * kHiddenLayerOutputSize; 24 | extern const int8_t kHiddenGruWeights[kHiddenLayerWeights]; 25 | extern const int8_t kHiddenGruRecurrentWeights[kHiddenLayerWeights]; 26 | extern const int8_t kHiddenGruBias[kHiddenLayerBiases]; 27 | 28 | // Output layer (dense). 29 | const size_t kOutputLayerOutputSize = 1; 30 | const size_t kOutputLayerWeights = 31 | kHiddenLayerOutputSize * kOutputLayerOutputSize; 32 | extern const int8_t kOutputDenseWeights[kOutputLayerWeights]; 33 | extern const int8_t kOutputDenseBias[kOutputLayerOutputSize]; 34 | 35 | } // namespace rnnoise 36 | 37 | #endif // THIRD_PARTY_RNNOISE_SRC_RNN_VAD_WEIGHTS_H_ 38 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec_dump/null_aec_dump_factory.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/aec_dump/aec_dump_factory.h" 12 | #include "modules/audio_processing/include/aec_dump.h" 13 | 14 | namespace webrtc { 15 | 16 | std::unique_ptr AecDumpFactory::Create(webrtc::FileWrapper file, 17 | int64_t max_log_size_bytes, 18 | rtc::TaskQueue* worker_queue) { 19 | return nullptr; 20 | } 21 | 22 | std::unique_ptr AecDumpFactory::Create(std::string file_name, 23 | int64_t max_log_size_bytes, 24 | rtc::TaskQueue* worker_queue) { 25 | return nullptr; 26 | } 27 | 28 | std::unique_ptr AecDumpFactory::Create(FILE* handle, 29 | int64_t max_log_size_bytes, 30 | rtc::TaskQueue* worker_queue) { 31 | return nullptr; 32 | } 33 | } // namespace webrtc 34 | -------------------------------------------------------------------------------- /jni/src/webrtc/system_wrappers/include/cpu_features_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ 12 | #define SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ 13 | 14 | #include 15 | 16 | namespace webrtc { 17 | 18 | // List of features in x86. 19 | typedef enum { kSSE2, kSSE3, kAVX2 } CPUFeature; 20 | 21 | // List of features in ARM. 22 | enum { 23 | kCPUFeatureARMv7 = (1 << 0), 24 | kCPUFeatureVFPv3 = (1 << 1), 25 | kCPUFeatureNEON = (1 << 2), 26 | kCPUFeatureLDREXSTREX = (1 << 3) 27 | }; 28 | 29 | // Returns true if the CPU supports the feature. 30 | int GetCPUInfo(CPUFeature feature); 31 | 32 | // No CPU feature is available => straight C path. 33 | int GetCPUInfoNoASM(CPUFeature feature); 34 | 35 | // Return the features in an ARM device. 36 | // It detects the features in the hardware platform, and returns supported 37 | // values in the above enum definition as a bitmask. 38 | uint64_t GetCPUFeaturesARM(void); 39 | 40 | } // namespace webrtc 41 | 42 | #endif // SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ 43 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/noise_spectrum_estimator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC2_NOISE_SPECTRUM_ESTIMATOR_H_ 12 | #define MODULES_AUDIO_PROCESSING_AGC2_NOISE_SPECTRUM_ESTIMATOR_H_ 13 | 14 | #include "api/array_view.h" 15 | 16 | namespace webrtc { 17 | 18 | class ApmDataDumper; 19 | 20 | class NoiseSpectrumEstimator { 21 | public: 22 | explicit NoiseSpectrumEstimator(ApmDataDumper* data_dumper); 23 | 24 | NoiseSpectrumEstimator() = delete; 25 | NoiseSpectrumEstimator(const NoiseSpectrumEstimator&) = delete; 26 | NoiseSpectrumEstimator& operator=(const NoiseSpectrumEstimator&) = delete; 27 | 28 | void Initialize(); 29 | void Update(rtc::ArrayView spectrum, bool first_update); 30 | 31 | rtc::ArrayView GetNoiseSpectrum() const { 32 | return rtc::ArrayView(noise_spectrum_); 33 | } 34 | 35 | private: 36 | ApmDataDumper* data_dumper_; 37 | float noise_spectrum_[65]; 38 | }; 39 | 40 | } // namespace webrtc 41 | 42 | #endif // MODULES_AUDIO_PROCESSING_AGC2_NOISE_SPECTRUM_ESTIMATOR_H_ 43 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/moving_average.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_MOVING_AVERAGE_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_MOVING_AVERAGE_H_ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include "api/array_view.h" 19 | 20 | namespace webrtc { 21 | namespace aec3 { 22 | 23 | class MovingAverage { 24 | public: 25 | // Creates an instance of MovingAverage that accepts inputs of length num_elem 26 | // and averages over mem_len inputs. 27 | MovingAverage(size_t num_elem, size_t mem_len); 28 | ~MovingAverage(); 29 | 30 | // Computes the average of input and mem_len-1 previous inputs and stores the 31 | // result in output. 32 | void Average(rtc::ArrayView input, rtc::ArrayView output); 33 | 34 | private: 35 | const size_t num_elem_; 36 | const size_t mem_len_; 37 | const float scaling_; 38 | std::vector memory_; 39 | size_t mem_index_; 40 | }; 41 | 42 | } // namespace aec3 43 | } // namespace webrtc 44 | 45 | #endif // MODULES_AUDIO_PROCESSING_AEC3_MOVING_AVERAGE_H_ 46 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/vector_float_frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC2_VECTOR_FLOAT_FRAME_H_ 12 | #define MODULES_AUDIO_PROCESSING_AGC2_VECTOR_FLOAT_FRAME_H_ 13 | 14 | #include 15 | 16 | #include "modules/audio_processing/include/audio_frame_view.h" 17 | 18 | namespace webrtc { 19 | 20 | // A construct consisting of a multi-channel audio frame, and a FloatFrame view 21 | // of it. 22 | class VectorFloatFrame { 23 | public: 24 | VectorFloatFrame(int num_channels, 25 | int samples_per_channel, 26 | float start_value); 27 | const AudioFrameView& float_frame_view() { return float_frame_view_; } 28 | AudioFrameView float_frame_view() const { 29 | return float_frame_view_; 30 | } 31 | 32 | ~VectorFloatFrame(); 33 | 34 | private: 35 | std::vector> channels_; 36 | std::vector channel_ptrs_; 37 | AudioFrameView float_frame_view_; 38 | }; 39 | 40 | } // namespace webrtc 41 | 42 | #endif // MODULES_AUDIO_PROCESSING_AGC2_VECTOR_FLOAT_FRAME_H_ 43 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/real_fourier_ooura.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_REAL_FOURIER_OOURA_H_ 12 | #define COMMON_AUDIO_REAL_FOURIER_OOURA_H_ 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | #include "common_audio/real_fourier.h" 20 | 21 | namespace webrtc { 22 | 23 | class RealFourierOoura : public RealFourier { 24 | public: 25 | explicit RealFourierOoura(int fft_order); 26 | ~RealFourierOoura() override; 27 | 28 | void Forward(const float* src, std::complex* dest) const override; 29 | void Inverse(const std::complex* src, float* dest) const override; 30 | 31 | int order() const override; 32 | 33 | private: 34 | const int order_; 35 | const size_t length_; 36 | const size_t complex_length_; 37 | // These are work arrays for Ooura. The names are based on the comments in 38 | // common_audio/third_party/ooura/fft_size_256/fft4g.cc. 39 | const std::unique_ptr work_ip_; 40 | const std::unique_ptr work_w_; 41 | }; 42 | 43 | } // namespace webrtc 44 | 45 | #endif // COMMON_AUDIO_REAL_FOURIER_OOURA_H_ 46 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/block_delay_buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_BLOCK_DELAY_BUFFER_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_DELAY_BUFFER_H_ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include "modules/audio_processing/audio_buffer.h" 19 | 20 | namespace webrtc { 21 | 22 | // Class for applying a fixed delay to the samples in a signal partitioned using 23 | // the audiobuffer band-splitting scheme. 24 | class BlockDelayBuffer { 25 | public: 26 | BlockDelayBuffer(size_t num_channels, 27 | size_t num_bands, 28 | size_t frame_length, 29 | size_t delay_samples); 30 | ~BlockDelayBuffer(); 31 | 32 | // Delays the samples by the specified delay. 33 | void DelaySignal(AudioBuffer* frame); 34 | 35 | private: 36 | const size_t frame_length_; 37 | const size_t delay_; 38 | std::vector>> buf_; 39 | size_t last_insert_ = 0; 40 | }; 41 | } // namespace webrtc 42 | 43 | #endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_DELAY_BUFFER_H_ 44 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/prior_signal_model_estimator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_NS_PRIOR_SIGNAL_MODEL_ESTIMATOR_H_ 12 | #define MODULES_AUDIO_PROCESSING_NS_PRIOR_SIGNAL_MODEL_ESTIMATOR_H_ 13 | 14 | #include "modules/audio_processing/ns/histograms.h" 15 | #include "modules/audio_processing/ns/prior_signal_model.h" 16 | 17 | namespace webrtc { 18 | 19 | // Estimator of the prior signal model parameters. 20 | class PriorSignalModelEstimator { 21 | public: 22 | explicit PriorSignalModelEstimator(float lrt_initial_value); 23 | PriorSignalModelEstimator(const PriorSignalModelEstimator&) = delete; 24 | PriorSignalModelEstimator& operator=(const PriorSignalModelEstimator&) = 25 | delete; 26 | 27 | // Updates the model estimate. 28 | void Update(const Histograms& h); 29 | 30 | // Returns the estimated model. 31 | const PriorSignalModel& get_prior_model() const { return prior_model_; } 32 | 33 | private: 34 | PriorSignalModel prior_model_; 35 | }; 36 | 37 | } // namespace webrtc 38 | 39 | #endif // MODULES_AUDIO_PROCESSING_NS_PRIOR_SIGNAL_MODEL_ESTIMATOR_H_ 40 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/biquad_filter.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/agc2/biquad_filter.h" 12 | 13 | #include 14 | 15 | namespace webrtc { 16 | 17 | // Transposed direct form I implementation of a bi-quad filter applied to an 18 | // input signal |x| to produce an output signal |y|. 19 | void BiQuadFilter::Process(rtc::ArrayView x, 20 | rtc::ArrayView y) { 21 | for (size_t k = 0; k < x.size(); ++k) { 22 | // Use temporary variable for x[k] to allow in-place function call 23 | // (that x and y refer to the same array). 24 | const float tmp = x[k]; 25 | y[k] = coefficients_.b[0] * tmp + coefficients_.b[1] * biquad_state_.b[0] + 26 | coefficients_.b[2] * biquad_state_.b[1] - 27 | coefficients_.a[0] * biquad_state_.a[0] - 28 | coefficients_.a[1] * biquad_state_.a[1]; 29 | biquad_state_.b[1] = biquad_state_.b[0]; 30 | biquad_state_.b[0] = tmp; 31 | biquad_state_.a[1] = biquad_state_.a[0]; 32 | biquad_state_.a[0] = y[k]; 33 | } 34 | } 35 | 36 | } // namespace webrtc 37 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/echo_detector/circular_buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_CIRCULAR_BUFFER_H_ 12 | #define MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_CIRCULAR_BUFFER_H_ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include "absl/types/optional.h" 19 | 20 | namespace webrtc { 21 | 22 | // Ring buffer containing floating point values. 23 | struct CircularBuffer { 24 | public: 25 | explicit CircularBuffer(size_t size); 26 | ~CircularBuffer(); 27 | 28 | void Push(float value); 29 | absl::optional Pop(); 30 | size_t Size() const { return nr_elements_in_buffer_; } 31 | // This function fills the buffer with zeros, but does not change its size. 32 | void Clear(); 33 | 34 | private: 35 | std::vector buffer_; 36 | size_t next_insertion_index_ = 0; 37 | // This is the number of elements that have been pushed into the circular 38 | // buffer, not the allocated buffer size. 39 | size_t nr_elements_in_buffer_ = 0; 40 | }; 41 | 42 | } // namespace webrtc 43 | 44 | #endif // MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_CIRCULAR_BUFFER_H_ 45 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/noise_level_estimator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC2_NOISE_LEVEL_ESTIMATOR_H_ 12 | #define MODULES_AUDIO_PROCESSING_AGC2_NOISE_LEVEL_ESTIMATOR_H_ 13 | 14 | #include "modules/audio_processing/agc2/signal_classifier.h" 15 | #include "modules/audio_processing/include/audio_frame_view.h" 16 | #include "rtc_base/constructor_magic.h" 17 | 18 | namespace webrtc { 19 | class ApmDataDumper; 20 | 21 | class NoiseLevelEstimator { 22 | public: 23 | NoiseLevelEstimator(ApmDataDumper* data_dumper); 24 | ~NoiseLevelEstimator(); 25 | // Returns the estimated noise level in dBFS. 26 | float Analyze(const AudioFrameView& frame); 27 | 28 | private: 29 | void Initialize(int sample_rate_hz); 30 | 31 | int sample_rate_hz_; 32 | float min_noise_energy_; 33 | bool first_update_; 34 | float noise_energy_; 35 | int noise_energy_hold_counter_; 36 | SignalClassifier signal_classifier_; 37 | 38 | RTC_DISALLOW_COPY_AND_ASSIGN(NoiseLevelEstimator); 39 | }; 40 | 41 | } // namespace webrtc 42 | 43 | #endif // MODULES_AUDIO_PROCESSING_AGC2_NOISE_LEVEL_ESTIMATOR_H_ 44 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/echo_detector/moving_max.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/echo_detector/moving_max.h" 12 | 13 | #include "rtc_base/checks.h" 14 | 15 | namespace webrtc { 16 | namespace { 17 | 18 | // Parameter for controlling how fast the estimated maximum decays after the 19 | // previous maximum is no longer valid. With a value of 0.99, the maximum will 20 | // decay to 1% of its former value after 460 updates. 21 | constexpr float kDecayFactor = 0.99f; 22 | 23 | } // namespace 24 | 25 | MovingMax::MovingMax(size_t window_size) : window_size_(window_size) { 26 | RTC_DCHECK_GT(window_size, 0); 27 | } 28 | 29 | MovingMax::~MovingMax() {} 30 | 31 | void MovingMax::Update(float value) { 32 | if (counter_ >= window_size_ - 1) { 33 | max_value_ *= kDecayFactor; 34 | } else { 35 | ++counter_; 36 | } 37 | if (value > max_value_) { 38 | max_value_ = value; 39 | counter_ = 0; 40 | } 41 | } 42 | 43 | float MovingMax::max() const { 44 | return max_value_; 45 | } 46 | 47 | void MovingMax::Clear() { 48 | max_value_ = 0.f; 49 | counter_ = 0; 50 | } 51 | 52 | } // namespace webrtc 53 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/ns_fft.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_NS_NS_FFT_H_ 12 | #define MODULES_AUDIO_PROCESSING_NS_NS_FFT_H_ 13 | 14 | #include 15 | 16 | #include "api/array_view.h" 17 | #include "modules/audio_processing/ns/ns_common.h" 18 | 19 | namespace webrtc { 20 | 21 | // Wrapper class providing 256 point FFT functionality. 22 | class NrFft { 23 | public: 24 | NrFft(); 25 | NrFft(const NrFft&) = delete; 26 | NrFft& operator=(const NrFft&) = delete; 27 | 28 | // Transforms the signal from time to frequency domain. 29 | void Fft(rtc::ArrayView time_data, 30 | rtc::ArrayView real, 31 | rtc::ArrayView imag); 32 | 33 | // Transforms the signal from frequency to time domain. 34 | void Ifft(rtc::ArrayView real, 35 | rtc::ArrayView imag, 36 | rtc::ArrayView time_data); 37 | 38 | private: 39 | std::vector bit_reversal_state_; 40 | std::vector tables_; 41 | }; 42 | 43 | } // namespace webrtc 44 | 45 | #endif // MODULES_AUDIO_PROCESSING_NS_NS_FFT_H_ 46 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/signal_processing/get_scaling_square.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_GetScalingSquare(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | int16_t WebRtcSpl_GetScalingSquare(int16_t* in_vector, 21 | size_t in_vector_length, 22 | size_t times) 23 | { 24 | int16_t nbits = WebRtcSpl_GetSizeInBits((uint32_t)times); 25 | size_t i; 26 | int16_t smax = -1; 27 | int16_t sabs; 28 | int16_t *sptr = in_vector; 29 | int16_t t; 30 | size_t looptimes = in_vector_length; 31 | 32 | for (i = looptimes; i > 0; i--) 33 | { 34 | sabs = (*sptr > 0 ? *sptr++ : -*sptr++); 35 | smax = (sabs > smax ? sabs : smax); 36 | } 37 | t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); 38 | 39 | if (smax == 0) 40 | { 41 | return 0; // Since norm(0) returns 0 42 | } else 43 | { 44 | return (t > nbits) ? 0 : nbits - t; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/vad/vad_gmm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Gaussian probability calculations internally used in vad_core.c. 12 | 13 | #ifndef COMMON_AUDIO_VAD_VAD_GMM_H_ 14 | #define COMMON_AUDIO_VAD_VAD_GMM_H_ 15 | 16 | #include 17 | 18 | // Calculates the probability for |input|, given that |input| comes from a 19 | // normal distribution with mean and standard deviation (|mean|, |std|). 20 | // 21 | // Inputs: 22 | // - input : input sample in Q4. 23 | // - mean : mean input in the statistical model, Q7. 24 | // - std : standard deviation, Q7. 25 | // 26 | // Output: 27 | // 28 | // - delta : input used when updating the model, Q11. 29 | // |delta| = (|input| - |mean|) / |std|^2. 30 | // 31 | // Return: 32 | // (probability for |input|) = 33 | // 1 / |std| * exp(-(|input| - |mean|)^2 / (2 * |std|^2)); 34 | int32_t WebRtcVad_GaussianProbability(int16_t input, 35 | int16_t mean, 36 | int16_t std, 37 | int16_t* delta); 38 | 39 | #endif // COMMON_AUDIO_VAD_VAD_GMM_H_ 40 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/subtractor_output_analyzer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_OUTPUT_ANALYZER_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_OUTPUT_ANALYZER_H_ 13 | 14 | #include 15 | 16 | #include "modules/audio_processing/aec3/subtractor_output.h" 17 | 18 | namespace webrtc { 19 | 20 | // Class for analyzing the properties subtractor output. 21 | class SubtractorOutputAnalyzer { 22 | public: 23 | explicit SubtractorOutputAnalyzer(size_t num_capture_channels); 24 | ~SubtractorOutputAnalyzer() = default; 25 | 26 | // Analyses the subtractor output. 27 | void Update(rtc::ArrayView subtractor_output, 28 | bool* any_filter_converged, 29 | bool* all_filters_diverged); 30 | 31 | const std::vector& ConvergedFilters() const { 32 | return filters_converged_; 33 | } 34 | 35 | // Handle echo path change. 36 | void HandleEchoPathChange(); 37 | 38 | private: 39 | std::vector filters_converged_; 40 | }; 41 | 42 | } // namespace webrtc 43 | 44 | #endif // MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_OUTPUT_ANALYZER_H_ 45 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/rnn_vad/lp_residual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_LP_RESIDUAL_H_ 12 | #define MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_LP_RESIDUAL_H_ 13 | 14 | #include 15 | 16 | #include "api/array_view.h" 17 | 18 | namespace webrtc { 19 | namespace rnn_vad { 20 | 21 | // LPC inverse filter length. 22 | constexpr size_t kNumLpcCoefficients = 5; 23 | 24 | // Given a frame |x|, computes a post-processed version of LPC coefficients 25 | // tailored for pitch estimation. 26 | void ComputeAndPostProcessLpcCoefficients( 27 | rtc::ArrayView x, 28 | rtc::ArrayView lpc_coeffs); 29 | 30 | // Computes the LP residual for the input frame |x| and the LPC coefficients 31 | // |lpc_coeffs|. |y| and |x| can point to the same array for in-place 32 | // computation. 33 | void ComputeLpResidual( 34 | rtc::ArrayView lpc_coeffs, 35 | rtc::ArrayView x, 36 | rtc::ArrayView y); 37 | 38 | } // namespace rnn_vad 39 | } // namespace webrtc 40 | 41 | #endif // MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_LP_RESIDUAL_H_ 42 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/string_utils.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "rtc_base/string_utils.h" 12 | 13 | namespace rtc { 14 | 15 | size_t strcpyn(char* buffer, 16 | size_t buflen, 17 | const char* source, 18 | size_t srclen /* = SIZE_UNKNOWN */) { 19 | if (buflen <= 0) 20 | return 0; 21 | 22 | if (srclen == SIZE_UNKNOWN) { 23 | srclen = strlen(source); 24 | } 25 | if (srclen >= buflen) { 26 | srclen = buflen - 1; 27 | } 28 | memcpy(buffer, source, srclen); 29 | buffer[srclen] = 0; 30 | return srclen; 31 | } 32 | 33 | static const char kWhitespace[] = " \n\r\t"; 34 | 35 | std::string string_trim(const std::string& s) { 36 | std::string::size_type first = s.find_first_not_of(kWhitespace); 37 | std::string::size_type last = s.find_last_not_of(kWhitespace); 38 | 39 | if (first == std::string::npos || last == std::string::npos) { 40 | return std::string(""); 41 | } 42 | 43 | return s.substr(first, last - first + 1); 44 | } 45 | 46 | std::string ToHex(const int i) { 47 | char buffer[50]; 48 | snprintf(buffer, sizeof(buffer), "%x", i); 49 | 50 | return std::string(buffer); 51 | } 52 | 53 | } // namespace rtc 54 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/system/unused.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_SYSTEM_UNUSED_H_ 12 | #define RTC_BASE_SYSTEM_UNUSED_H_ 13 | 14 | // Annotate a function indicating the caller must examine the return value. 15 | // Use like: 16 | // int foo() RTC_WARN_UNUSED_RESULT; 17 | // To explicitly ignore a result, cast to void. 18 | // TODO(kwiberg): Remove when we can use [[nodiscard]] from C++17. 19 | #if defined(__clang__) 20 | #define RTC_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 21 | #elif defined(__GNUC__) 22 | // gcc has a __warn_unused_result__ attribute, but you can't quiet it by 23 | // casting to void, so we don't use it. 24 | #define RTC_WARN_UNUSED_RESULT 25 | #else 26 | #define RTC_WARN_UNUSED_RESULT 27 | #endif 28 | 29 | // Prevent the compiler from warning about an unused variable. For example: 30 | // int result = DoSomething(); 31 | // assert(result == 17); 32 | // RTC_UNUSED(result); 33 | // Note: In most cases it is better to remove the unused variable rather than 34 | // suppressing the compiler warning. 35 | #ifndef RTC_UNUSED 36 | #define RTC_UNUSED(x) static_cast(x) 37 | #endif // RTC_UNUSED 38 | 39 | #endif // RTC_BASE_SYSTEM_UNUSED_H_ 40 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/high_pass_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_H_ 12 | #define MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_H_ 13 | 14 | #include 15 | #include 16 | 17 | #include "api/array_view.h" 18 | #include "modules/audio_processing/utility/cascaded_biquad_filter.h" 19 | 20 | namespace webrtc { 21 | 22 | class AudioBuffer; 23 | 24 | class HighPassFilter { 25 | public: 26 | HighPassFilter(int sample_rate_hz, size_t num_channels); 27 | ~HighPassFilter(); 28 | HighPassFilter(const HighPassFilter&) = delete; 29 | HighPassFilter& operator=(const HighPassFilter&) = delete; 30 | 31 | void Process(AudioBuffer* audio, bool use_split_band_data); 32 | void Process(std::vector>* audio); 33 | void Reset(); 34 | void Reset(size_t num_channels); 35 | 36 | int sample_rate_hz() const { return sample_rate_hz_; } 37 | size_t num_channels() const { return filters_.size(); } 38 | 39 | private: 40 | const int sample_rate_hz_; 41 | std::vector> filters_; 42 | }; 43 | } // namespace webrtc 44 | 45 | #endif // MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_H_ 46 | -------------------------------------------------------------------------------- /jni/src/webrtc/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, The WebRTC project authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of Google nor the names of its contributors may 16 | be used to endorse or promote products derived from this software 17 | without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/memory/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import("../../webrtc.gni") 10 | if (is_android) { 11 | import("//build/config/android/config.gni") 12 | import("//build/config/android/rules.gni") 13 | } 14 | 15 | rtc_library("aligned_malloc") { 16 | sources = [ 17 | "aligned_malloc.cc", 18 | "aligned_malloc.h", 19 | ] 20 | deps = [ "..:checks" ] 21 | } 22 | 23 | # Test only utility. 24 | # TODO: Tag with `testonly = true` once all depending targets are correctly 25 | # tagged. 26 | rtc_library("fifo_buffer") { 27 | visibility = [ 28 | ":unittests", 29 | "..:rtc_base_tests_utils", 30 | "..:rtc_base_unittests", 31 | "../../p2p:rtc_p2p", # This needs to be fixed. 32 | ] 33 | sources = [ 34 | "fifo_buffer.cc", 35 | "fifo_buffer.h", 36 | ] 37 | deps = [ 38 | "..:rtc_base", 39 | "../synchronization:mutex", 40 | "../task_utils:pending_task_safety_flag", 41 | "../task_utils:to_queued_task", 42 | ] 43 | } 44 | 45 | rtc_library("unittests") { 46 | testonly = true 47 | sources = [ 48 | "aligned_malloc_unittest.cc", 49 | "fifo_buffer_unittest.cc", 50 | ] 51 | deps = [ 52 | ":aligned_malloc", 53 | ":fifo_buffer", 54 | "../../test:test_support", 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/audio_processing_builder_impl.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/include/audio_processing.h" 12 | 13 | #include 14 | 15 | #include "modules/audio_processing/audio_processing_impl.h" 16 | #include "rtc_base/ref_counted_object.h" 17 | 18 | namespace webrtc { 19 | 20 | AudioProcessingBuilder::AudioProcessingBuilder() = default; 21 | AudioProcessingBuilder::~AudioProcessingBuilder() = default; 22 | 23 | AudioProcessing* AudioProcessingBuilder::Create() { 24 | webrtc::Config config; 25 | return Create(config); 26 | } 27 | 28 | AudioProcessing* AudioProcessingBuilder::Create(const webrtc::Config& config) { 29 | #ifdef WEBRTC_EXCLUDE_AUDIO_PROCESSING_MODULE 30 | 31 | // Implementation returning a null pointer for using when the APM is excluded 32 | // from the build.. 33 | return nullptr; 34 | 35 | #else 36 | 37 | // Standard implementation. 38 | return new rtc::RefCountedObject( 39 | config, std::move(capture_post_processing_), 40 | std::move(render_pre_processing_), std::move(echo_control_factory_), 41 | std::move(echo_detector_), std::move(capture_analyzer_)); 42 | #endif 43 | } 44 | 45 | } // namespace webrtc 46 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/echo_detector/normalized_covariance_estimator.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/echo_detector/normalized_covariance_estimator.h" 12 | 13 | #include 14 | 15 | #include "rtc_base/checks.h" 16 | 17 | namespace webrtc { 18 | namespace { 19 | 20 | // Parameter controlling the adaptation speed. 21 | constexpr float kAlpha = 0.001f; 22 | 23 | } // namespace 24 | 25 | void NormalizedCovarianceEstimator::Update(float x, 26 | float x_mean, 27 | float x_sigma, 28 | float y, 29 | float y_mean, 30 | float y_sigma) { 31 | covariance_ = 32 | (1.f - kAlpha) * covariance_ + kAlpha * (x - x_mean) * (y - y_mean); 33 | normalized_cross_correlation_ = covariance_ / (x_sigma * y_sigma + .0001f); 34 | RTC_DCHECK(isfinite(covariance_)); 35 | RTC_DCHECK(isfinite(normalized_cross_correlation_)); 36 | } 37 | 38 | void NormalizedCovarianceEstimator::Clear() { 39 | covariance_ = 0.f; 40 | normalized_cross_correlation_ = 0.f; 41 | } 42 | 43 | } // namespace webrtc 44 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/signal_processing/dot_product_with_scale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_SIGNAL_PROCESSING_DOT_PRODUCT_WITH_SCALE_H_ 12 | #define COMMON_AUDIO_SIGNAL_PROCESSING_DOT_PRODUCT_WITH_SCALE_H_ 13 | 14 | #include 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | // Calculates the dot product between two (int16_t) vectors. 22 | // 23 | // Input: 24 | // - vector1 : Vector 1 25 | // - vector2 : Vector 2 26 | // - vector_length : Number of samples used in the dot product 27 | // - scaling : The number of right bit shifts to apply on each term 28 | // during calculation to avoid overflow, i.e., the 29 | // output will be in Q(-|scaling|) 30 | // 31 | // Return value : The dot product in Q(-scaling) 32 | int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, 33 | const int16_t* vector2, 34 | size_t length, 35 | int scaling); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif // __cplusplus 40 | #endif // COMMON_AUDIO_SIGNAL_PROCESSING_DOT_PRODUCT_WITH_SCALE_H_ 41 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc2/gain_applier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC2_GAIN_APPLIER_H_ 12 | #define MODULES_AUDIO_PROCESSING_AGC2_GAIN_APPLIER_H_ 13 | 14 | #include 15 | 16 | #include "modules/audio_processing/include/audio_frame_view.h" 17 | 18 | namespace webrtc { 19 | class GainApplier { 20 | public: 21 | GainApplier(bool hard_clip_samples, float initial_gain_factor); 22 | 23 | void ApplyGain(AudioFrameView signal); 24 | void SetGainFactor(float gain_factor); 25 | float GetGainFactor() const { return current_gain_factor_; } 26 | 27 | private: 28 | void Initialize(size_t samples_per_channel); 29 | 30 | // Whether to clip samples after gain is applied. If 'true', result 31 | // will fit in FloatS16 range. 32 | const bool hard_clip_samples_; 33 | float last_gain_factor_; 34 | 35 | // If this value is not equal to 'last_gain_factor', gain will be 36 | // ramped from 'last_gain_factor_' to this value during the next 37 | // 'ApplyGain'. 38 | float current_gain_factor_; 39 | int samples_per_channel_ = -1; 40 | float inverse_samples_per_channel_ = -1.f; 41 | }; 42 | } // namespace webrtc 43 | 44 | #endif // MODULES_AUDIO_PROCESSING_AGC2_GAIN_APPLIER_H_ 45 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/block_processor_metrics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_METRICS_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_METRICS_H_ 13 | 14 | #include "rtc_base/constructor_magic.h" 15 | 16 | namespace webrtc { 17 | 18 | // Handles the reporting of metrics for the block_processor. 19 | class BlockProcessorMetrics { 20 | public: 21 | BlockProcessorMetrics() = default; 22 | 23 | // Updates the metric with new capture data. 24 | void UpdateCapture(bool underrun); 25 | 26 | // Updates the metric with new render data. 27 | void UpdateRender(bool overrun); 28 | 29 | // Returns true if the metrics have just been reported, otherwise false. 30 | bool MetricsReported() { return metrics_reported_; } 31 | 32 | private: 33 | // Resets the metrics. 34 | void ResetMetrics(); 35 | 36 | int capture_block_counter_ = 0; 37 | bool metrics_reported_ = false; 38 | int render_buffer_underruns_ = 0; 39 | int render_buffer_overruns_ = 0; 40 | int buffer_render_calls_ = 0; 41 | 42 | RTC_DISALLOW_COPY_AND_ASSIGN(BlockProcessorMetrics); 43 | }; 44 | 45 | } // namespace webrtc 46 | 47 | #endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_METRICS_H_ 48 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/nearend_detector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_NEAREND_DETECTOR_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_NEAREND_DETECTOR_H_ 13 | 14 | #include 15 | 16 | #include "api/array_view.h" 17 | #include "api/audio/echo_canceller3_config.h" 18 | #include "modules/audio_processing/aec3/aec3_common.h" 19 | 20 | namespace webrtc { 21 | // Class for selecting whether the suppressor is in the nearend or echo state. 22 | class NearendDetector { 23 | public: 24 | virtual ~NearendDetector() {} 25 | 26 | // Returns whether the current state is the nearend state. 27 | virtual bool IsNearendState() const = 0; 28 | 29 | // Updates the state selection based on latest spectral estimates. 30 | virtual void Update( 31 | rtc::ArrayView> 32 | nearend_spectrum, 33 | rtc::ArrayView> 34 | residual_echo_spectrum, 35 | rtc::ArrayView> 36 | comfort_noise_spectrum, 37 | bool initial_state) = 0; 38 | }; 39 | 40 | } // namespace webrtc 41 | 42 | #endif // MODULES_AUDIO_PROCESSING_AEC3_NEAREND_DETECTOR_H_ 43 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/transient/wpd_node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_ 12 | #define MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_ 13 | 14 | #include 15 | 16 | namespace webrtc { 17 | 18 | class FIRFilter; 19 | 20 | // A single node of a Wavelet Packet Decomposition (WPD) tree. 21 | class WPDNode { 22 | public: 23 | // Creates a WPDNode. The data vector will contain zeros. The filter will have 24 | // the coefficients provided. 25 | WPDNode(size_t length, const float* coefficients, size_t coefficients_length); 26 | ~WPDNode(); 27 | 28 | // Updates the node data. |parent_data| / 2 must be equals to |length_|. 29 | // Returns 0 if correct, and -1 otherwise. 30 | int Update(const float* parent_data, size_t parent_data_length); 31 | 32 | const float* data() const { return data_.get(); } 33 | // Returns 0 if correct, and -1 otherwise. 34 | int set_data(const float* new_data, size_t length); 35 | size_t length() const { return length_; } 36 | 37 | private: 38 | std::unique_ptr data_; 39 | size_t length_; 40 | std::unique_ptr filter_; 41 | }; 42 | 43 | } // namespace webrtc 44 | 45 | #endif // MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_ 46 | -------------------------------------------------------------------------------- /jni/src/webrtc/rtc_base/gtest_prod_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_GTEST_PROD_UTIL_H_ 12 | #define RTC_BASE_GTEST_PROD_UTIL_H_ 13 | 14 | // Define our own version of FRIEND_TEST here rather than including 15 | // gtest_prod.h to avoid depending on any part of GTest in production code. 16 | #define FRIEND_TEST_WEBRTC(test_case_name, test_name) \ 17 | friend class test_case_name##_##test_name##_Test 18 | 19 | // This file is a plain copy of Chromium's base/gtest_prod_util.h. 20 | // 21 | // This is a wrapper for gtest's FRIEND_TEST macro that friends 22 | // test with all possible prefixes. This is very helpful when changing the test 23 | // prefix, because the friend declarations don't need to be updated. 24 | // 25 | // Example usage: 26 | // 27 | // class MyClass { 28 | // private: 29 | // void MyMethod(); 30 | // FRIEND_TEST_ALL_PREFIXES(MyClassTest, MyMethod); 31 | // }; 32 | #define FRIEND_TEST_ALL_PREFIXES(test_case_name, test_name) \ 33 | FRIEND_TEST_WEBRTC(test_case_name, test_name); \ 34 | FRIEND_TEST_WEBRTC(test_case_name, DISABLED_##test_name); \ 35 | FRIEND_TEST_WEBRTC(test_case_name, FLAKY_##test_name); \ 36 | FRIEND_TEST_WEBRTC(test_case_name, FAILS_##test_name) 37 | 38 | #endif // RTC_BASE_GTEST_PROD_UTIL_H_ 39 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_ 12 | #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_ 13 | 14 | #include "webrtc/base/scoped_ptr.h" 15 | #include "webrtc/base/thread_annotations.h" 16 | #include "webrtc/modules/audio_coding/codecs/isac/bandwidth_info.h" 17 | #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 18 | 19 | namespace webrtc { 20 | 21 | // An IsacBandwidthInfo that's safe to access from multiple threads because 22 | // it's protected by a mutex. 23 | class LockedIsacBandwidthInfo final { 24 | public: 25 | LockedIsacBandwidthInfo(); 26 | ~LockedIsacBandwidthInfo(); 27 | 28 | IsacBandwidthInfo Get() const { 29 | CriticalSectionScoped cs(lock_.get()); 30 | return bwinfo_; 31 | } 32 | 33 | void Set(const IsacBandwidthInfo& bwinfo) { 34 | CriticalSectionScoped cs(lock_.get()); 35 | bwinfo_ = bwinfo; 36 | } 37 | 38 | private: 39 | const rtc::scoped_ptr lock_; 40 | IsacBandwidthInfo bwinfo_ GUARDED_BY(lock_); 41 | }; 42 | 43 | } // namespace webrtc 44 | 45 | #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_ 46 | -------------------------------------------------------------------------------- /jni/src/webrtc/audio/utility/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | import("../../webrtc.gni") 9 | 10 | group("utility") { 11 | deps = [ ":audio_frame_operations" ] 12 | } 13 | 14 | rtc_library("audio_frame_operations") { 15 | visibility = [ "*" ] 16 | sources = [ 17 | "audio_frame_operations.cc", 18 | "audio_frame_operations.h", 19 | "channel_mixer.cc", 20 | "channel_mixer.h", 21 | "channel_mixing_matrix.cc", 22 | "channel_mixing_matrix.h", 23 | ] 24 | 25 | deps = [ 26 | "../../api/audio:audio_frame_api", 27 | "../../common_audio", 28 | "../../rtc_base:checks", 29 | "../../rtc_base:deprecation", 30 | "../../rtc_base:rtc_base_approved", 31 | "../../system_wrappers:field_trial", 32 | ] 33 | } 34 | 35 | if (rtc_include_tests) { 36 | rtc_library("utility_tests") { 37 | testonly = true 38 | sources = [ 39 | "audio_frame_operations_unittest.cc", 40 | "channel_mixer_unittest.cc", 41 | "channel_mixing_matrix_unittest.cc", 42 | ] 43 | deps = [ 44 | ":audio_frame_operations", 45 | "../../api/audio:audio_frame_api", 46 | "../../rtc_base:checks", 47 | "../../rtc_base:rtc_base_approved", 48 | "../../test:field_trial", 49 | "../../test:test_support", 50 | "//testing/gtest", 51 | ] 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/quantile_noise_estimator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_NS_QUANTILE_NOISE_ESTIMATOR_H_ 12 | #define MODULES_AUDIO_PROCESSING_NS_QUANTILE_NOISE_ESTIMATOR_H_ 13 | 14 | #include 15 | #include 16 | 17 | #include "api/array_view.h" 18 | #include "modules/audio_processing/ns/ns_common.h" 19 | 20 | namespace webrtc { 21 | 22 | constexpr int kSimult = 3; 23 | 24 | // For quantile noise estimation. 25 | class QuantileNoiseEstimator { 26 | public: 27 | QuantileNoiseEstimator(); 28 | QuantileNoiseEstimator(const QuantileNoiseEstimator&) = delete; 29 | QuantileNoiseEstimator& operator=(const QuantileNoiseEstimator&) = delete; 30 | 31 | // Estimate noise. 32 | void Estimate(rtc::ArrayView signal_spectrum, 33 | rtc::ArrayView noise_spectrum); 34 | 35 | private: 36 | std::array density_; 37 | std::array log_quantile_; 38 | std::array quantile_; 39 | std::array counter_; 40 | int num_updates_ = 1; 41 | }; 42 | 43 | } // namespace webrtc 44 | 45 | #endif // MODULES_AUDIO_PROCESSING_NS_QUANTILE_NOISE_ESTIMATOR_H_ 46 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/vad/include/vad.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_VAD_INCLUDE_VAD_H_ 12 | #define COMMON_AUDIO_VAD_INCLUDE_VAD_H_ 13 | 14 | #include 15 | 16 | #include "common_audio/vad/include/webrtc_vad.h" 17 | #include "rtc_base/checks.h" 18 | 19 | namespace webrtc { 20 | 21 | class Vad { 22 | public: 23 | enum Aggressiveness { 24 | kVadNormal = 0, 25 | kVadLowBitrate = 1, 26 | kVadAggressive = 2, 27 | kVadVeryAggressive = 3 28 | }; 29 | 30 | enum Activity { kPassive = 0, kActive = 1, kError = -1 }; 31 | 32 | virtual ~Vad() = default; 33 | 34 | // Calculates a VAD decision for the given audio frame. Valid sample rates 35 | // are 8000, 16000, and 32000 Hz; the number of samples must be such that the 36 | // frame is 10, 20, or 30 ms long. 37 | virtual Activity VoiceActivity(const int16_t* audio, 38 | size_t num_samples, 39 | int sample_rate_hz) = 0; 40 | 41 | // Resets VAD state. 42 | virtual void Reset() = 0; 43 | }; 44 | 45 | // Returns a Vad instance that's implemented on top of WebRtcVad. 46 | std::unique_ptr CreateVad(Vad::Aggressiveness aggressiveness); 47 | 48 | } // namespace webrtc 49 | 50 | #endif // COMMON_AUDIO_VAD_INCLUDE_VAD_H_ 51 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/echo_detector/normalized_covariance_estimator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_NORMALIZED_COVARIANCE_ESTIMATOR_H_ 12 | #define MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_NORMALIZED_COVARIANCE_ESTIMATOR_H_ 13 | 14 | namespace webrtc { 15 | 16 | // This class iteratively estimates the normalized covariance between two 17 | // signals. 18 | class NormalizedCovarianceEstimator { 19 | public: 20 | void Update(float x, 21 | float x_mean, 22 | float x_var, 23 | float y, 24 | float y_mean, 25 | float y_var); 26 | // This function returns an estimate of the Pearson product-moment correlation 27 | // coefficient of the two signals. 28 | float normalized_cross_correlation() const { 29 | return normalized_cross_correlation_; 30 | } 31 | float covariance() const { return covariance_; } 32 | // This function resets the estimated values to zero. 33 | void Clear(); 34 | 35 | private: 36 | float normalized_cross_correlation_ = 0.f; 37 | // Estimate of the covariance value. 38 | float covariance_ = 0.f; 39 | }; 40 | 41 | } // namespace webrtc 42 | 43 | #endif // MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_NORMALIZED_COVARIANCE_ESTIMATOR_H_ 44 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/transient/moving_moments.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/transient/moving_moments.h" 12 | 13 | #include 14 | 15 | #include "rtc_base/checks.h" 16 | 17 | namespace webrtc { 18 | 19 | MovingMoments::MovingMoments(size_t length) 20 | : length_(length), queue_(), sum_(0.0), sum_of_squares_(0.0) { 21 | RTC_DCHECK_GT(length, 0); 22 | for (size_t i = 0; i < length; ++i) { 23 | queue_.push(0.0); 24 | } 25 | } 26 | 27 | MovingMoments::~MovingMoments() {} 28 | 29 | void MovingMoments::CalculateMoments(const float* in, 30 | size_t in_length, 31 | float* first, 32 | float* second) { 33 | RTC_DCHECK(in); 34 | RTC_DCHECK_GT(in_length, 0); 35 | RTC_DCHECK(first); 36 | RTC_DCHECK(second); 37 | 38 | for (size_t i = 0; i < in_length; ++i) { 39 | const float old_value = queue_.front(); 40 | queue_.pop(); 41 | queue_.push(in[i]); 42 | 43 | sum_ += in[i] - old_value; 44 | sum_of_squares_ += in[i] * in[i] - old_value * old_value; 45 | first[i] = sum_ / length_; 46 | second[i] = std::max(0.f, sum_of_squares_ / length_); 47 | } 48 | } 49 | 50 | } // namespace webrtc 51 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/optionally_built_submodule_creators.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_OPTIONALLY_BUILT_SUBMODULE_CREATORS_H_ 12 | #define MODULES_AUDIO_PROCESSING_OPTIONALLY_BUILT_SUBMODULE_CREATORS_H_ 13 | 14 | #include 15 | 16 | #include "modules/audio_processing/transient/transient_suppressor.h" 17 | 18 | namespace webrtc { 19 | 20 | // These overrides are only to be used for testing purposes. 21 | // Each flag emulates a preprocessor macro to exclude a submodule of APM from 22 | // the build, e.g. WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR. If the corresponding 23 | // flag |transient_suppression| is enabled, then the creators will return 24 | // nullptr instead of a submodule instance, as if the macro had been defined. 25 | struct ApmSubmoduleCreationOverrides { 26 | bool transient_suppression = false; 27 | }; 28 | 29 | // Creates a transient suppressor. 30 | // Will instead return nullptr if one of the following is true: 31 | // * WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR is defined 32 | // * The corresponding override in |overrides| is enabled. 33 | std::unique_ptr CreateTransientSuppressor( 34 | const ApmSubmoduleCreationOverrides& overrides); 35 | 36 | } // namespace webrtc 37 | 38 | #endif // MODULES_AUDIO_PROCESSING_OPTIONALLY_BUILT_SUBMODULE_CREATORS_H_ 39 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/echo_detector/circular_buffer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/echo_detector/circular_buffer.h" 12 | 13 | #include 14 | 15 | #include "rtc_base/checks.h" 16 | 17 | namespace webrtc { 18 | 19 | CircularBuffer::CircularBuffer(size_t size) : buffer_(size) {} 20 | CircularBuffer::~CircularBuffer() = default; 21 | 22 | void CircularBuffer::Push(float value) { 23 | buffer_[next_insertion_index_] = value; 24 | ++next_insertion_index_; 25 | next_insertion_index_ %= buffer_.size(); 26 | RTC_DCHECK_LT(next_insertion_index_, buffer_.size()); 27 | nr_elements_in_buffer_ = std::min(nr_elements_in_buffer_ + 1, buffer_.size()); 28 | RTC_DCHECK_LE(nr_elements_in_buffer_, buffer_.size()); 29 | } 30 | 31 | absl::optional CircularBuffer::Pop() { 32 | if (nr_elements_in_buffer_ == 0) { 33 | return absl::nullopt; 34 | } 35 | const size_t index = 36 | (buffer_.size() + next_insertion_index_ - nr_elements_in_buffer_) % 37 | buffer_.size(); 38 | RTC_DCHECK_LT(index, buffer_.size()); 39 | --nr_elements_in_buffer_; 40 | return buffer_[index]; 41 | } 42 | 43 | void CircularBuffer::Clear() { 44 | std::fill(buffer_.begin(), buffer_.end(), 0.f); 45 | next_insertion_index_ = 0; 46 | nr_elements_in_buffer_ = 0; 47 | } 48 | 49 | } // namespace webrtc 50 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/signal_processing/refl_coef_to_lpc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_ReflCoefToLpc(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | void WebRtcSpl_ReflCoefToLpc(const int16_t *k, int use_order, int16_t *a) 21 | { 22 | int16_t any[WEBRTC_SPL_MAX_LPC_ORDER + 1]; 23 | int16_t *aptr, *aptr2, *anyptr; 24 | const int16_t *kptr; 25 | int m, i; 26 | 27 | kptr = k; 28 | *a = 4096; // i.e., (Word16_MAX >> 3)+1. 29 | *any = *a; 30 | a[1] = *k >> 3; 31 | 32 | for (m = 1; m < use_order; m++) 33 | { 34 | kptr++; 35 | aptr = a; 36 | aptr++; 37 | aptr2 = &a[m]; 38 | anyptr = any; 39 | anyptr++; 40 | 41 | any[m + 1] = *kptr >> 3; 42 | for (i = 0; i < m; i++) 43 | { 44 | *anyptr = *aptr + (int16_t)((*aptr2 * *kptr) >> 15); 45 | anyptr++; 46 | aptr++; 47 | aptr2--; 48 | } 49 | 50 | aptr = a; 51 | anyptr = any; 52 | for (i = 0; i < (m + 2); i++) 53 | { 54 | *aptr = *anyptr; 55 | aptr++; 56 | anyptr++; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/transparent_mode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_TRANSPARENT_MODE_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_TRANSPARENT_MODE_H_ 13 | 14 | #include 15 | 16 | #include "api/audio/echo_canceller3_config.h" 17 | #include "modules/audio_processing/aec3/aec3_common.h" 18 | 19 | namespace webrtc { 20 | 21 | // Class for detecting and toggling the transparent mode which causes the 22 | // suppressor to apply less suppression. 23 | class TransparentMode { 24 | public: 25 | static std::unique_ptr Create( 26 | const EchoCanceller3Config& config); 27 | 28 | virtual ~TransparentMode() {} 29 | 30 | // Returns whether the transparent mode should be active. 31 | virtual bool Active() const = 0; 32 | 33 | // Resets the state of the detector. 34 | virtual void Reset() = 0; 35 | 36 | // Updates the detection decision based on new data. 37 | virtual void Update(int filter_delay_blocks, 38 | bool any_filter_consistent, 39 | bool any_filter_converged, 40 | bool all_filters_diverged, 41 | bool active_render, 42 | bool saturated_capture) = 0; 43 | }; 44 | 45 | } // namespace webrtc 46 | #endif // MODULES_AUDIO_PROCESSING_AEC3_TRANSPARENT_MODE_H_ 47 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/utility/delay_estimator_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Header file including the delay estimator handle used for testing. 12 | 13 | #ifndef MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_INTERNAL_H_ 14 | #define MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_INTERNAL_H_ 15 | 16 | #include "modules/audio_processing/utility/delay_estimator.h" 17 | 18 | namespace webrtc { 19 | 20 | typedef union { 21 | float float_; 22 | int32_t int32_; 23 | } SpectrumType; 24 | 25 | typedef struct { 26 | // Pointers to mean values of spectrum. 27 | SpectrumType* mean_far_spectrum; 28 | // |mean_far_spectrum| initialization indicator. 29 | int far_spectrum_initialized; 30 | 31 | int spectrum_size; 32 | 33 | // Far-end part of binary spectrum based delay estimation. 34 | BinaryDelayEstimatorFarend* binary_farend; 35 | } DelayEstimatorFarend; 36 | 37 | typedef struct { 38 | // Pointers to mean values of spectrum. 39 | SpectrumType* mean_near_spectrum; 40 | // |mean_near_spectrum| initialization indicator. 41 | int near_spectrum_initialized; 42 | 43 | int spectrum_size; 44 | 45 | // Binary spectrum based delay estimator 46 | BinaryDelayEstimator* binary_handle; 47 | } DelayEstimator; 48 | 49 | } // namespace webrtc 50 | 51 | #endif // MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_INTERNAL_H_ 52 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/suppression_params.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/ns/suppression_params.h" 12 | 13 | #include "rtc_base/checks.h" 14 | 15 | namespace webrtc { 16 | 17 | SuppressionParams::SuppressionParams( 18 | NsConfig::SuppressionLevel suppression_level) { 19 | switch (suppression_level) { 20 | case NsConfig::SuppressionLevel::k6dB: 21 | over_subtraction_factor = 1.f; 22 | // 6 dB attenuation. 23 | minimum_attenuating_gain = 0.5f; 24 | use_attenuation_adjustment = false; 25 | break; 26 | case NsConfig::SuppressionLevel::k12dB: 27 | over_subtraction_factor = 1.f; 28 | // 12 dB attenuation. 29 | minimum_attenuating_gain = 0.25f; 30 | use_attenuation_adjustment = true; 31 | break; 32 | case NsConfig::SuppressionLevel::k18dB: 33 | over_subtraction_factor = 1.1f; 34 | // 18 dB attenuation. 35 | minimum_attenuating_gain = 0.125f; 36 | use_attenuation_adjustment = true; 37 | break; 38 | case NsConfig::SuppressionLevel::k21dB: 39 | over_subtraction_factor = 1.25f; 40 | // 20.9 dB attenuation. 41 | minimum_attenuating_gain = 0.09f; 42 | use_attenuation_adjustment = true; 43 | break; 44 | default: 45 | RTC_NOTREACHED(); 46 | } 47 | } 48 | 49 | } // namespace webrtc 50 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/ns/histograms.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "modules/audio_processing/ns/histograms.h" 12 | 13 | namespace webrtc { 14 | 15 | Histograms::Histograms() { 16 | Clear(); 17 | } 18 | 19 | void Histograms::Clear() { 20 | lrt_.fill(0); 21 | spectral_flatness_.fill(0); 22 | spectral_diff_.fill(0); 23 | } 24 | 25 | void Histograms::Update(const SignalModel& features_) { 26 | // Update the histogram for the LRT. 27 | constexpr float kOneByBinSizeLrt = 1.f / kBinSizeLrt; 28 | if (features_.lrt < kHistogramSize * kBinSizeLrt && features_.lrt >= 0.f) { 29 | ++lrt_[kOneByBinSizeLrt * features_.lrt]; 30 | } 31 | 32 | // Update histogram for the spectral flatness. 33 | constexpr float kOneByBinSizeSpecFlat = 1.f / kBinSizeSpecFlat; 34 | if (features_.spectral_flatness < kHistogramSize * kBinSizeSpecFlat && 35 | features_.spectral_flatness >= 0.f) { 36 | ++spectral_flatness_[features_.spectral_flatness * kOneByBinSizeSpecFlat]; 37 | } 38 | 39 | // Update histogram for the spectral difference. 40 | constexpr float kOneByBinSizeSpecDiff = 1.f / kBinSizeSpecDiff; 41 | if (features_.spectral_diff < kHistogramSize * kBinSizeSpecDiff && 42 | features_.spectral_diff >= 0.f) { 43 | ++spectral_diff_[features_.spectral_diff * kOneByBinSizeSpecDiff]; 44 | } 45 | } 46 | 47 | } // namespace webrtc 48 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/agc/agc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AGC_AGC_H_ 12 | #define MODULES_AUDIO_PROCESSING_AGC_AGC_H_ 13 | 14 | #include 15 | 16 | #include "modules/audio_processing/vad/voice_activity_detector.h" 17 | 18 | namespace webrtc { 19 | 20 | class LoudnessHistogram; 21 | 22 | class Agc { 23 | public: 24 | Agc(); 25 | virtual ~Agc(); 26 | 27 | // |audio| must be mono; in a multi-channel stream, provide the first (usually 28 | // left) channel. 29 | virtual void Process(const int16_t* audio, size_t length, int sample_rate_hz); 30 | 31 | // Retrieves the difference between the target RMS level and the current 32 | // signal RMS level in dB. Returns true if an update is available and false 33 | // otherwise, in which case |error| should be ignored and no action taken. 34 | virtual bool GetRmsErrorDb(int* error); 35 | virtual void Reset(); 36 | 37 | virtual int set_target_level_dbfs(int level); 38 | virtual int target_level_dbfs() const; 39 | virtual float voice_probability() const; 40 | 41 | private: 42 | double target_level_loudness_; 43 | int target_level_dbfs_; 44 | std::unique_ptr histogram_; 45 | std::unique_ptr inactive_histogram_; 46 | VoiceActivityDetector vad_; 47 | }; 48 | 49 | } // namespace webrtc 50 | 51 | #endif // MODULES_AUDIO_PROCESSING_AGC_AGC_H_ 52 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/real_fourier.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "common_audio/real_fourier.h" 12 | 13 | #include "common_audio/real_fourier_ooura.h" 14 | #include "common_audio/signal_processing/include/signal_processing_library.h" 15 | #include "rtc_base/checks.h" 16 | 17 | namespace webrtc { 18 | 19 | using std::complex; 20 | 21 | const size_t RealFourier::kFftBufferAlignment = 32; 22 | 23 | std::unique_ptr RealFourier::Create(int fft_order) { 24 | return std::unique_ptr(new RealFourierOoura(fft_order)); 25 | } 26 | 27 | int RealFourier::FftOrder(size_t length) { 28 | RTC_CHECK_GT(length, 0U); 29 | return WebRtcSpl_GetSizeInBits(static_cast(length - 1)); 30 | } 31 | 32 | size_t RealFourier::FftLength(int order) { 33 | RTC_CHECK_GE(order, 0); 34 | return size_t{1} << order; 35 | } 36 | 37 | size_t RealFourier::ComplexLength(int order) { 38 | return FftLength(order) / 2 + 1; 39 | } 40 | 41 | RealFourier::fft_real_scoper RealFourier::AllocRealBuffer(int count) { 42 | return fft_real_scoper(static_cast( 43 | AlignedMalloc(sizeof(float) * count, kFftBufferAlignment))); 44 | } 45 | 46 | RealFourier::fft_cplx_scoper RealFourier::AllocCplxBuffer(int count) { 47 | return fft_cplx_scoper(static_cast*>( 48 | AlignedMalloc(sizeof(complex) * count, kFftBufferAlignment))); 49 | } 50 | 51 | } // namespace webrtc 52 | -------------------------------------------------------------------------------- /jni/src/webrtc/api/rtp_headers.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "api/rtp_headers.h" 12 | 13 | namespace webrtc { 14 | 15 | RTPHeaderExtension::RTPHeaderExtension() 16 | : hasTransmissionTimeOffset(false), 17 | transmissionTimeOffset(0), 18 | hasAbsoluteSendTime(false), 19 | absoluteSendTime(0), 20 | hasTransportSequenceNumber(false), 21 | transportSequenceNumber(0), 22 | hasAudioLevel(false), 23 | voiceActivity(false), 24 | audioLevel(0), 25 | hasVideoRotation(false), 26 | videoRotation(kVideoRotation_0), 27 | hasVideoContentType(false), 28 | videoContentType(VideoContentType::UNSPECIFIED), 29 | has_video_timing(false) {} 30 | 31 | RTPHeaderExtension::RTPHeaderExtension(const RTPHeaderExtension& other) = 32 | default; 33 | 34 | RTPHeaderExtension& RTPHeaderExtension::operator=( 35 | const RTPHeaderExtension& other) = default; 36 | 37 | RTPHeader::RTPHeader() 38 | : markerBit(false), 39 | payloadType(0), 40 | sequenceNumber(0), 41 | timestamp(0), 42 | ssrc(0), 43 | numCSRCs(0), 44 | arrOfCSRCs(), 45 | paddingLength(0), 46 | headerLength(0), 47 | payload_type_frequency(0), 48 | extension() {} 49 | 50 | RTPHeader::RTPHeader(const RTPHeader& other) = default; 51 | 52 | RTPHeader& RTPHeader::operator=(const RTPHeader& other) = default; 53 | 54 | } // namespace webrtc 55 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/main/source/pitch_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_FILTER_H_ 12 | #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_FILTER_H_ 13 | 14 | #include "modules/audio_coding/codecs/isac/main/source/structs.h" 15 | 16 | void WebRtcIsac_PitchfilterPre(double* indat, 17 | double* outdat, 18 | PitchFiltstr* pfp, 19 | double* lags, 20 | double* gains); 21 | 22 | void WebRtcIsac_PitchfilterPost(double* indat, 23 | double* outdat, 24 | PitchFiltstr* pfp, 25 | double* lags, 26 | double* gains); 27 | 28 | void WebRtcIsac_PitchfilterPre_la(double* indat, 29 | double* outdat, 30 | PitchFiltstr* pfp, 31 | double* lags, 32 | double* gains); 33 | 34 | void WebRtcIsac_PitchfilterPre_gains( 35 | double* indat, 36 | double* outdat, 37 | double out_dG[][PITCH_FRAME_LEN + QLOOKAHEAD], 38 | PitchFiltstr* pfp, 39 | double* lags, 40 | double* gains); 41 | 42 | #endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_FILTER_H_ 43 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/third_party/ooura/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the ../../../LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import("../../../webrtc.gni") 10 | 11 | rtc_library("fft_size_128") { 12 | sources = [ 13 | "fft_size_128/ooura_fft.cc", 14 | "fft_size_128/ooura_fft.h", 15 | "fft_size_128/ooura_fft_tables_common.h", 16 | ] 17 | deps = [ 18 | "../../../rtc_base/system:arch", 19 | "../../../system_wrappers", 20 | ] 21 | cflags = [] 22 | 23 | if (current_cpu == "x86" || current_cpu == "x64") { 24 | sources += [ 25 | "fft_size_128/ooura_fft_sse2.cc", 26 | "fft_size_128/ooura_fft_tables_neon_sse2.h", 27 | ] 28 | if (is_posix || is_fuchsia) { 29 | cflags += [ "-msse2" ] 30 | } 31 | } 32 | 33 | if (rtc_build_with_neon) { 34 | sources += [ 35 | "fft_size_128/ooura_fft_neon.cc", 36 | "fft_size_128/ooura_fft_tables_neon_sse2.h", 37 | ] 38 | 39 | deps += [ "../../../common_audio" ] 40 | 41 | if (current_cpu != "arm64") { 42 | # Enable compilation for the NEON instruction set. 43 | suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ] 44 | cflags += [ "-mfpu=neon" ] 45 | } 46 | } 47 | 48 | if (current_cpu == "mipsel" && mips_float_abi == "hard") { 49 | sources += [ "fft_size_128/ooura_fft_mips.cc" ] 50 | } 51 | } 52 | 53 | rtc_library("fft_size_256") { 54 | sources = [ 55 | "fft_size_256/fft4g.cc", 56 | "fft_size_256/fft4g.h", 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /* 12 | * SWB_KLT_Tables_LPCGain.h 13 | * 14 | * This file declares tables used for entropy coding of LPC Gain 15 | * of upper-band. 16 | * 17 | */ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_ 21 | 22 | #include 23 | 24 | #include "modules/audio_coding/codecs/isac/main/source/settings.h" 25 | 26 | extern const double WebRtcIsac_kQSizeLpcGain; 27 | 28 | extern const double WebRtcIsac_kLeftRecPointLpcGain[SUBFRAMES]; 29 | 30 | extern const int16_t WebRtcIsac_kNumQCellLpcGain[SUBFRAMES]; 31 | 32 | extern const uint16_t WebRtcIsac_kLpcGainEntropySearch[SUBFRAMES]; 33 | 34 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec0[18]; 35 | 36 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec1[21]; 37 | 38 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec2[26]; 39 | 40 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec3[46]; 41 | 42 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec4[78]; 43 | 44 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec5[171]; 45 | 46 | extern const uint16_t* WebRtcIsac_kLpcGainCdfMat[SUBFRAMES]; 47 | 48 | extern const double WebRtcIsac_kLpcGainDecorrMat[SUBFRAMES][SUBFRAMES]; 49 | 50 | #endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_ 51 | -------------------------------------------------------------------------------- /jni/src/webrtc/common_audio/resampler/sinc_resampler_neon.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Modified from the Chromium original: 12 | // src/media/base/sinc_resampler.cc 13 | 14 | #include 15 | 16 | #include "common_audio/resampler/sinc_resampler.h" 17 | 18 | namespace webrtc { 19 | 20 | float SincResampler::Convolve_NEON(const float* input_ptr, 21 | const float* k1, 22 | const float* k2, 23 | double kernel_interpolation_factor) { 24 | float32x4_t m_input; 25 | float32x4_t m_sums1 = vmovq_n_f32(0); 26 | float32x4_t m_sums2 = vmovq_n_f32(0); 27 | 28 | const float* upper = input_ptr + kKernelSize; 29 | for (; input_ptr < upper;) { 30 | m_input = vld1q_f32(input_ptr); 31 | input_ptr += 4; 32 | m_sums1 = vmlaq_f32(m_sums1, m_input, vld1q_f32(k1)); 33 | k1 += 4; 34 | m_sums2 = vmlaq_f32(m_sums2, m_input, vld1q_f32(k2)); 35 | k2 += 4; 36 | } 37 | 38 | // Linearly interpolate the two "convolutions". 39 | m_sums1 = vmlaq_f32( 40 | vmulq_f32(m_sums1, vmovq_n_f32(1.0 - kernel_interpolation_factor)), 41 | m_sums2, vmovq_n_f32(kernel_interpolation_factor)); 42 | 43 | // Sum components together. 44 | float32x2_t m_half = vadd_f32(vget_high_f32(m_sums1), vget_low_f32(m_sums1)); 45 | return vget_lane_f32(vpadd_f32(m_half, m_half), 0); 46 | } 47 | 48 | } // namespace webrtc 49 | -------------------------------------------------------------------------------- /jni/src/webrtc/modules/audio_processing/aec3/subtractor_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_OUTPUT_H_ 12 | #define MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_OUTPUT_H_ 13 | 14 | #include 15 | 16 | #include "api/array_view.h" 17 | #include "modules/audio_processing/aec3/aec3_common.h" 18 | #include "modules/audio_processing/aec3/fft_data.h" 19 | 20 | namespace webrtc { 21 | 22 | // Stores the values being returned from the echo subtractor for a single 23 | // capture channel. 24 | struct SubtractorOutput { 25 | SubtractorOutput(); 26 | ~SubtractorOutput(); 27 | 28 | std::array s_refined; 29 | std::array s_coarse; 30 | std::array e_refined; 31 | std::array e_coarse; 32 | FftData E_refined; 33 | std::array E2_refined; 34 | std::array E2_coarse; 35 | float s2_refined = 0.f; 36 | float s2_coarse = 0.f; 37 | float e2_refined = 0.f; 38 | float e2_coarse = 0.f; 39 | float y2 = 0.f; 40 | float s_refined_max_abs = 0.f; 41 | float s_coarse_max_abs = 0.f; 42 | 43 | // Reset the struct content. 44 | void Reset(); 45 | 46 | // Updates the powers of the signals. 47 | void ComputeMetrics(rtc::ArrayView y); 48 | }; 49 | 50 | } // namespace webrtc 51 | 52 | #endif // MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_OUTPUT_H_ 53 | --------------------------------------------------------------------------------