├── webrtc ├── modules │ ├── meson.build │ ├── interface │ │ └── meson.build │ ├── audio_processing │ │ ├── agc │ │ │ ├── utility.h │ │ │ ├── utility.cc │ │ │ └── agc.h │ │ ├── transient │ │ │ ├── common.h │ │ │ ├── moving_moments.cc │ │ │ ├── wpd_node.h │ │ │ ├── moving_moments.h │ │ │ └── daubechies_8_wavelet_coeffs.h │ │ ├── vad │ │ │ ├── common.h │ │ │ ├── pitch_internal.h │ │ │ ├── pole_zero_filter.h │ │ │ ├── gmm.h │ │ │ ├── gmm.cc │ │ │ ├── pitch_based_vad.h │ │ │ └── pitch_internal.cc │ │ ├── common.h │ │ ├── aec │ │ │ ├── aec_common.h │ │ │ ├── aec_resampler.h │ │ │ └── echo_cancellation_internal.h │ │ ├── logging │ │ │ ├── aec_logging_file_handling.h │ │ │ └── aec_logging_file_handling.cc │ │ ├── rms_level.cc │ │ ├── processing_component.h │ │ ├── utility │ │ │ └── delay_estimator_internal.h │ │ ├── ns │ │ │ ├── noise_suppression_x.c │ │ │ └── noise_suppression.c │ │ ├── high_pass_filter_impl.h │ │ ├── level_estimator_impl.h │ │ ├── beamformer │ │ │ └── beamformer.h │ │ ├── noise_suppression_impl.h │ │ └── rms_level.h │ └── audio_coding │ │ ├── codecs │ │ └── isac │ │ │ ├── bandwidth_info.h │ │ │ └── main │ │ │ └── source │ │ │ ├── os_specific_inline.h │ │ │ ├── filterbank_tables.c │ │ │ ├── lpc_gain_swb_tables.h │ │ │ ├── pitch_gain_tables.h │ │ │ ├── lpc_analysis.h │ │ │ ├── filterbank_tables.h │ │ │ ├── arith_routines.c │ │ │ └── lpc_shape_swb12_tables.h │ │ └── meson.build ├── meson.build ├── base │ ├── meson.build │ ├── thread_checker_impl.cc │ ├── arraysize.h │ ├── platform_thread.h │ ├── platform_file.cc │ ├── platform_file.h │ ├── constructormagic.h │ ├── event.h │ └── thread_checker_impl.h ├── common_audio │ ├── fft4g.h │ ├── window_generator.h │ ├── signal_processing │ │ ├── sqrt_of_one_minus_x_squared.c │ │ ├── energy.c │ │ ├── cross_correlation.c │ │ ├── dot_product_with_scale.c │ │ ├── filter_ar_fast_q12.c │ │ ├── get_scaling_square.c │ │ ├── filter_ma_fast_q12.c │ │ ├── refl_coef_to_lpc.c │ │ ├── downsample_fast.c │ │ ├── resample_by_2_internal.h │ │ └── lpc_to_refl_coef.c │ ├── fir_filter_sse.h │ ├── fir_filter_neon.h │ ├── real_fourier_openmax.h │ ├── real_fourier_ooura.h │ ├── fir_filter.h │ ├── vad │ │ ├── vad_gmm.h │ │ ├── include │ │ │ └── vad.h │ │ ├── vad.cc │ │ ├── vad_filterbank.h │ │ └── vad_sp.h │ ├── resampler │ │ ├── sinc_resampler_neon.cc │ │ ├── include │ │ │ └── push_resampler.h │ │ ├── sinusoidal_linear_chirp_source.h │ │ ├── sinusoidal_linear_chirp_source.cc │ │ └── sinc_resampler_sse.cc │ ├── audio_util.cc │ ├── real_fourier.cc │ ├── sparse_fir_filter.h │ ├── window_generator.cc │ ├── audio_ring_buffer.h │ ├── channel_buffer.cc │ └── sparse_fir_filter.cc ├── system_wrappers │ ├── include │ │ ├── sleep.h │ │ ├── compile_assert_c.h │ │ ├── condition_variable_wrapper.h │ │ ├── cpu_features_wrapper.h │ │ ├── fix_interlocked_exchange_pointer_win.h │ │ ├── asm_defines.h │ │ ├── critical_section_wrapper.h │ │ ├── rw_lock_wrapper.h │ │ └── aligned_malloc.h │ ├── source │ │ ├── critical_section.cc │ │ ├── critical_section_win.cc │ │ ├── sleep.cc │ │ ├── metrics_default.cc │ │ ├── thread.cc │ │ ├── critical_section_posix.h │ │ ├── rw_lock.cc │ │ ├── rw_lock_win.h │ │ ├── trace_win.h │ │ ├── event_timer_win.h │ │ ├── critical_section_win.h │ │ ├── rw_lock_posix.h │ │ ├── trace_posix.h │ │ ├── rw_lock_posix.cc │ │ ├── thread_win.h │ │ ├── critical_section_posix.cc │ │ ├── rw_lock_generic.h │ │ ├── condition_variable_event_win.h │ │ ├── condition_variable.cc │ │ ├── thread_posix.h │ │ ├── event.cc │ │ ├── event_timer_posix.h │ │ ├── condition_variable_native_win.h │ │ ├── logging.cc │ │ ├── file_impl.h │ │ ├── cpu_features.cc │ │ └── event_timer_win.cc │ └── meson.build ├── PATENTS └── common_types.cc ├── AUTHORS ├── webrtc-audio-processing.pc.in ├── meson_options.txt ├── .gitignore ├── cross-files ├── android.txt └── ios.txt ├── README.md ├── COPYING └── NEWS /webrtc/modules/meson.build: -------------------------------------------------------------------------------- 1 | subdir('audio_coding') 2 | subdir('audio_processing') 3 | subdir('interface') 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file like so: 2 | # Name or Organization 3 | 4 | Google Inc. 5 | 6 | # autofoo-based build system 7 | Arun Raghavan 8 | -------------------------------------------------------------------------------- /webrtc/modules/interface/meson.build: -------------------------------------------------------------------------------- 1 | interface_headers = [ 2 | 'module_common_types.h', 3 | ] 4 | 5 | install_headers(interface_headers, 6 | subdir: 'webrtc_audio_processing/webrtc/modules/interface' 7 | ) 8 | -------------------------------------------------------------------------------- /webrtc-audio-processing.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: webrtc-audio-processing 7 | Description: WebRTC Audio Processing library 8 | Version: @PACKAGE_VERSION@ 9 | Libs: -L${libdir} -lwebrtc_audio_processing 10 | Cflags: -DWEBRTC_AUDIO_PROCESSING_ONLY_BUILD -I${includedir}/webrtc_audio_processing @PLATFORM_CFLAGS@ 11 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('ns_mode', type: 'combo', 2 | choices : ['float', 'fixed'], 3 | description: 'Noise suppresion mode to use.') 4 | option('gnustl', type: 'feature', 5 | value: 'auto', 6 | description: 'Use gnustl for a c++ library implementation (only used on Android)') 7 | option('neon', type: 'combo', 8 | choices: ['no', 'yes', 'auto', 'runtime'], 9 | description: '') 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.lo 3 | *.la 4 | *.pc 5 | .*.swp 6 | *~ 7 | .deps* 8 | .dirstamp 9 | .DS_Store 10 | .libs* 11 | Makefile 12 | Makefile.in 13 | aclocal.m4 14 | autom4te.cache 15 | build/ 16 | compile 17 | config.guess 18 | config.h 19 | config.h.in 20 | config.log 21 | config.rpath 22 | config.status 23 | config.sub 24 | configure 25 | depcomp 26 | install-sh 27 | libltdl 28 | libtool 29 | ltmain.sh 30 | missing 31 | mkinstalldirs 32 | stamp-* 33 | -------------------------------------------------------------------------------- /cross-files/android.txt: -------------------------------------------------------------------------------- 1 | # To use this, first run: 2 | # export PATH="$PATH:.../android-ndk-rxxx/toolchains/llvm/prebuilt/linux-x86_64/bin" 3 | 4 | [host_machine] 5 | system = 'android' 6 | cpu_family = 'aarch64' 7 | cpu = 'arm64' 8 | endian = 'little' 9 | 10 | [binaries] 11 | c = 'aarch64-linux-android28-clang' 12 | cpp = 'aarch64-linux-android28-clang++' 13 | ar = 'aarch64-linux-android-ar' 14 | strip = 'aarch64-linux-android-strip' 15 | pkgconfig = 'false' 16 | -------------------------------------------------------------------------------- /webrtc/meson.build: -------------------------------------------------------------------------------- 1 | webrtc_sources = [ 2 | 'common_types.cc' 3 | ] 4 | 5 | webrtc_headers = [ 6 | 'common.h', 7 | 'common_types.h', 8 | 'typedefs.h', 9 | ] 10 | 11 | install_headers(webrtc_headers, 12 | subdir: 'webrtc_audio_processing/webrtc' 13 | ) 14 | 15 | libwebrtc = static_library('webrtc', 16 | webrtc_sources, 17 | dependencies: common_deps, 18 | include_directories: webrtc_inc, 19 | c_args: common_cflags, 20 | cpp_args: common_cxxflags 21 | ) 22 | 23 | subdir('base') 24 | subdir('common_audio') 25 | subdir('system_wrappers') 26 | 27 | subdir('modules') 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | The AudioProcessing module from WebRTC[1][2] 4 | 5 | [1] http://code.google.com/p/webrtc/ 6 | [2] https://chromium.googlesource.com/external/webrtc/trunk/webrtc.git 7 | 8 | # Build 9 | 10 | 1. Install Meson: http://mesonbuild.com/Getting-meson.html 11 | 2. Install Ninja: https://github.com/ninja-build/ninja/releases 12 | 3. Open a Terminal / Visual Studio Command Prompt and run: 13 | 14 | ``` 15 | mkdir build 16 | cd build 17 | meson ../ 18 | ninja 19 | ``` 20 | 21 | * To specify a build type, use `meson ../ --buildtype=debug` or `meson ../ --buildtype=release` 22 | * To cross-build for another platform, use `meson ../ --cross-file xxx.txt` 23 | -------------------------------------------------------------------------------- /webrtc/base/meson.build: -------------------------------------------------------------------------------- 1 | base_sources = [ 2 | 'criticalsection.cc', 3 | 'checks.cc', 4 | 'event.cc', 5 | 'platform_thread.cc', 6 | 'platform_file.cc', 7 | 'stringutils.cc', 8 | 'thread_checker_impl.cc', 9 | ] 10 | 11 | base_headers = [ 12 | 'arraysize.h', 13 | 'checks.h', 14 | 'constructormagic.h', 15 | 'basictypes.h', 16 | 'maybe.h', 17 | 'platform_file.h', 18 | ] 19 | 20 | install_headers(base_headers, 21 | subdir: 'webrtc_audio_processing/webrtc/base' 22 | ) 23 | 24 | libbase = static_library('libbase', 25 | base_sources, 26 | dependencies: common_deps, 27 | include_directories: webrtc_inc, 28 | cpp_args : common_cxxflags 29 | ) 30 | -------------------------------------------------------------------------------- /webrtc/common_audio/fft4g.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 WEBRTC_COMMON_AUDIO_FFT4G_H_ 12 | #define WEBRTC_COMMON_AUDIO_FFT4G_H_ 13 | 14 | #if defined(__cplusplus) 15 | extern "C" { 16 | #endif 17 | 18 | // Refer to fft4g.c for documentation. 19 | void WebRtc_rdft(size_t n, int isgn, float *a, size_t *ip, float *w); 20 | 21 | #if defined(__cplusplus) 22 | } 23 | #endif 24 | 25 | #endif // WEBRTC_COMMON_AUDIO_FFT4G_H_ 26 | -------------------------------------------------------------------------------- /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 WEBRTC_MODULES_AUDIO_PROCESSING_AGC_UTILITY_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_UTILITY_H_ 13 | 14 | // TODO(turajs): Add description of function. 15 | double Loudness2Db(double loudness); 16 | 17 | double Linear2Loudness(double rms); 18 | 19 | double Db2Loudness(double db); 20 | 21 | double Dbfs2Loudness(double dbfs); 22 | 23 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_UTILITY_H_ 24 | -------------------------------------------------------------------------------- /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 WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_BANDWIDTH_INFO_H_ 12 | #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_BANDWIDTH_INFO_H_ 13 | 14 | #include "webrtc/typedefs.h" 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 // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_BANDWIDTH_INFO_H_ 25 | -------------------------------------------------------------------------------- /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 WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ 13 | #define WEBRTC_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 // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ 25 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/critical_section.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 | #if defined(_WIN32) 12 | #include 13 | #include "webrtc/system_wrappers/source/critical_section_win.h" 14 | #else 15 | #include "webrtc/system_wrappers/source/critical_section_posix.h" 16 | #endif 17 | 18 | namespace webrtc { 19 | 20 | CriticalSectionWrapper* CriticalSectionWrapper::CreateCriticalSection() { 21 | #ifdef _WIN32 22 | return new CriticalSectionWindows(); 23 | #else 24 | return new CriticalSectionPosix(); 25 | #endif 26 | } 27 | 28 | } // namespace webrtc 29 | -------------------------------------------------------------------------------- /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 WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_ 12 | #define WEBRTC_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 // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_ 28 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/critical_section_win.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 "webrtc/system_wrappers/source/critical_section_win.h" 12 | 13 | namespace webrtc { 14 | 15 | CriticalSectionWindows::CriticalSectionWindows() { 16 | InitializeCriticalSection(&crit); 17 | } 18 | 19 | CriticalSectionWindows::~CriticalSectionWindows() { 20 | DeleteCriticalSection(&crit); 21 | } 22 | 23 | void 24 | CriticalSectionWindows::Enter() { 25 | EnterCriticalSection(&crit); 26 | } 27 | 28 | void 29 | CriticalSectionWindows::Leave() { 30 | LeaveCriticalSection(&crit); 31 | } 32 | 33 | } // namespace webrtc 34 | -------------------------------------------------------------------------------- /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 WEBRTC_MODULES_AUDIO_PROCESSING_VAD_COMMON_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_COMMON_H_ 13 | 14 | static const int kSampleRateHz = 16000; 15 | static const size_t kLength10Ms = kSampleRateHz / 100; 16 | static const size_t kMaxNumFrames = 4; 17 | 18 | struct AudioFeatures { 19 | double log_pitch_gain[kMaxNumFrames]; 20 | double pitch_lag_hz[kMaxNumFrames]; 21 | double spectral_peak[kMaxNumFrames]; 22 | double rms[kMaxNumFrames]; 23 | size_t num_frames; 24 | bool silence; 25 | }; 26 | 27 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_VAD_COMMON_H_ 28 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/include/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 WEBRTC_SYSTEM_WRAPPERS_INCLUDE_COMPILE_ASSERT_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_COMPILE_ASSERT_H_ 13 | 14 | #ifdef __cplusplus 15 | #error "Only use this for C files. For C++, use static_assert." 16 | #endif 17 | 18 | // Use this macro to verify at compile time that certain restrictions are met. 19 | // The argument is the boolean expression to evaluate. 20 | // Example: 21 | // COMPILE_ASSERT(sizeof(foo) < 128); 22 | #define COMPILE_ASSERT(expression) switch (0) {case 0: case expression:;} 23 | 24 | #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_COMPILE_ASSERT_H_ 25 | -------------------------------------------------------------------------------- /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 "webrtc/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 | -------------------------------------------------------------------------------- /cross-files/ios.txt: -------------------------------------------------------------------------------- 1 | [host_machine] 2 | system = 'ios' 3 | cpu_family = 'arm' 4 | cpu = 'armv7' 5 | endian = 'little' 6 | 7 | [binaries] 8 | c = 'clang' 9 | cpp = 'clang++' 10 | ar = 'ar' 11 | strip = 'strip' 12 | 13 | [properties] 14 | root = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer' 15 | 16 | c_args = ['-arch', 'armv7', '-miphoneos-version-min=8.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk'] 17 | cpp_args = ['-arch', 'armv7', '-miphoneos-version-min=8.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk'] 18 | c_link_args = ['-arch', 'armv7', '-miphoneos-version-min=8.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk'] 19 | cpp_link_args = ['-arch', 'armv7', '-miphoneos-version-min=8.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk'] 20 | 21 | has_function_printf = true 22 | has_function_hfkerhisadf = false 23 | -------------------------------------------------------------------------------- /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 WEBRTC_COMMON_AUDIO_WINDOW_GENERATOR_H_ 12 | #define WEBRTC_COMMON_AUDIO_WINDOW_GENERATOR_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/base/constructormagic.h" 17 | 18 | namespace webrtc { 19 | 20 | // Helper class with generators for various signal transform windows. 21 | class WindowGenerator { 22 | public: 23 | static void Hanning(int length, float* window); 24 | static void KaiserBesselDerived(float alpha, size_t length, float* window); 25 | 26 | private: 27 | RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WindowGenerator); 28 | }; 29 | 30 | } // namespace webrtc 31 | 32 | #endif // WEBRTC_COMMON_AUDIO_WINDOW_GENERATOR_H_ 33 | 34 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/metrics_default.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 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 | 10 | #include "webrtc/system_wrappers/include/metrics.h" 11 | 12 | // Default implementation of histogram methods for WebRTC clients that do not 13 | // want to provide their own implementation. 14 | 15 | namespace webrtc { 16 | namespace metrics { 17 | 18 | Histogram* HistogramFactoryGetCounts(const std::string& name, int min, int max, 19 | int bucket_count) { return NULL; } 20 | 21 | Histogram* HistogramFactoryGetEnumeration(const std::string& name, 22 | int boundary) { return NULL; } 23 | 24 | void HistogramAdd( 25 | Histogram* histogram_pointer, const std::string& name, int sample) {} 26 | 27 | } // namespace metrics 28 | } // namespace webrtc 29 | 30 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/thread.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 "webrtc/system_wrappers/include/thread_wrapper.h" 12 | 13 | #if defined(_WIN32) 14 | #include "webrtc/system_wrappers/source/thread_win.h" 15 | #else 16 | #include "webrtc/system_wrappers/source/thread_posix.h" 17 | #endif 18 | 19 | namespace webrtc { 20 | 21 | #if defined(_WIN32) 22 | typedef ThreadWindows ThreadType; 23 | #else 24 | typedef ThreadPosix ThreadType; 25 | #endif 26 | 27 | rtc::scoped_ptr ThreadWrapper::CreateThread( 28 | ThreadRunFunction func, void* obj, const char* thread_name) { 29 | return rtc::scoped_ptr( 30 | new ThreadType(func, obj, thread_name)).Pass(); 31 | } 32 | 33 | } // namespace webrtc 34 | -------------------------------------------------------------------------------- /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 "webrtc/modules/audio_processing/agc/utility.h" 12 | 13 | #include 14 | 15 | static const double kLog10 = 2.30258509299; 16 | static const double kLinear2DbScale = 20.0 / kLog10; 17 | static const double kLinear2LoudnessScale = 13.4 / kLog10; 18 | 19 | double Loudness2Db(double loudness) { 20 | return loudness * kLinear2DbScale / kLinear2LoudnessScale; 21 | } 22 | 23 | double Linear2Loudness(double rms) { 24 | if (rms == 0) 25 | return -15; 26 | return kLinear2LoudnessScale * log(rms); 27 | } 28 | 29 | double Db2Loudness(double db) { 30 | return db * kLinear2LoudnessScale / kLinear2DbScale; 31 | } 32 | 33 | double Dbfs2Loudness(double dbfs) { 34 | return Db2Loudness(90 + dbfs); 35 | } 36 | -------------------------------------------------------------------------------- /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 WEBRTC_MODULES_AUDIO_PROCESSING_COMMON_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_COMMON_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/modules/audio_processing/include/audio_processing.h" 17 | 18 | namespace webrtc { 19 | 20 | static inline int ChannelsFromLayout(AudioProcessing::ChannelLayout layout) { 21 | switch (layout) { 22 | case AudioProcessing::kMono: 23 | case AudioProcessing::kMonoAndKeyboard: 24 | return 1; 25 | case AudioProcessing::kStereo: 26 | case AudioProcessing::kStereoAndKeyboard: 27 | return 2; 28 | } 29 | assert(false); 30 | return -1; 31 | } 32 | 33 | } // namespace webrtc 34 | 35 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_COMMON_H_ 36 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/critical_section_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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ 13 | 14 | #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 15 | 16 | #include 17 | 18 | namespace webrtc { 19 | 20 | class CriticalSectionPosix : public CriticalSectionWrapper { 21 | public: 22 | CriticalSectionPosix(); 23 | 24 | ~CriticalSectionPosix() override; 25 | 26 | void Enter() override; 27 | void Leave() override; 28 | 29 | private: 30 | pthread_mutex_t mutex_; 31 | friend class ConditionVariablePosix; 32 | }; 33 | 34 | } // namespace webrtc 35 | 36 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ 37 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/rw_lock.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 "webrtc/system_wrappers/include/rw_lock_wrapper.h" 12 | 13 | #include 14 | 15 | #if defined(_WIN32) 16 | #include "webrtc/system_wrappers/source/rw_lock_generic.h" 17 | #include "webrtc/system_wrappers/source/rw_lock_win.h" 18 | #else 19 | #include "webrtc/system_wrappers/source/rw_lock_posix.h" 20 | #endif 21 | 22 | namespace webrtc { 23 | 24 | RWLockWrapper* RWLockWrapper::CreateRWLock() { 25 | #ifdef _WIN32 26 | // Native implementation is faster, so use that if available. 27 | RWLockWrapper* lock = RWLockWin::Create(); 28 | if (lock) { 29 | return lock; 30 | } 31 | return new RWLockGeneric(); 32 | #else 33 | return RWLockPosix::Create(); 34 | #endif 35 | } 36 | 37 | } // namespace webrtc 38 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_ 13 | 14 | #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" 15 | 16 | #include 17 | 18 | namespace webrtc { 19 | 20 | class RWLockWin : public RWLockWrapper { 21 | public: 22 | static RWLockWin* Create(); 23 | ~RWLockWin() {} 24 | 25 | virtual void AcquireLockExclusive(); 26 | virtual void ReleaseLockExclusive(); 27 | 28 | virtual void AcquireLockShared(); 29 | virtual void ReleaseLockShared(); 30 | 31 | private: 32 | RWLockWin(); 33 | static bool LoadModule(); 34 | 35 | SRWLOCK lock_; 36 | }; 37 | 38 | } // namespace webrtc 39 | 40 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_ 41 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/trace_win.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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WIN_H_ 13 | 14 | #include 15 | #include 16 | 17 | #include "webrtc/system_wrappers/source/trace_impl.h" 18 | 19 | namespace webrtc { 20 | 21 | class TraceWindows : public TraceImpl { 22 | public: 23 | TraceWindows(); 24 | virtual ~TraceWindows(); 25 | 26 | virtual int32_t AddTime(char* trace_message, const TraceLevel level) const; 27 | 28 | virtual int32_t AddDateTimeInfo(char* trace_message) const; 29 | private: 30 | volatile mutable uint32_t prev_api_tick_count_; 31 | volatile mutable uint32_t prev_tick_count_; 32 | }; 33 | 34 | } // namespace webrtc 35 | 36 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_WIN_H_ 37 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/event_timer_win.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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_WIN_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/system_wrappers/include/event_wrapper.h" 17 | 18 | #include "webrtc/typedefs.h" 19 | 20 | namespace webrtc { 21 | 22 | class EventTimerWin : public EventTimerWrapper { 23 | public: 24 | EventTimerWin(); 25 | virtual ~EventTimerWin(); 26 | 27 | virtual EventTypeWrapper Wait(unsigned long max_time); 28 | virtual bool Set(); 29 | 30 | virtual bool StartTimer(bool periodic, unsigned long time); 31 | virtual bool StopTimer(); 32 | 33 | private: 34 | HANDLE event_; 35 | uint32_t timerID_; 36 | }; 37 | 38 | } // namespace webrtc 39 | 40 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_WIN_H_ 41 | -------------------------------------------------------------------------------- /webrtc/base/thread_checker_impl.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 | // Borrowed from Chromium's src/base/threading/thread_checker_impl.cc. 12 | 13 | #include "webrtc/base/thread_checker_impl.h" 14 | 15 | namespace rtc { 16 | 17 | ThreadCheckerImpl::ThreadCheckerImpl() : valid_thread_(CurrentThreadRef()) { 18 | } 19 | 20 | ThreadCheckerImpl::~ThreadCheckerImpl() { 21 | } 22 | 23 | bool ThreadCheckerImpl::CalledOnValidThread() const { 24 | const PlatformThreadRef current_thread = CurrentThreadRef(); 25 | CritScope scoped_lock(&lock_); 26 | if (!valid_thread_) // Set if previously detached. 27 | valid_thread_ = current_thread; 28 | return IsThreadRefEqual(valid_thread_, current_thread); 29 | } 30 | 31 | void ThreadCheckerImpl::DetachFromThread() { 32 | CritScope scoped_lock(&lock_); 33 | valid_thread_ = 0; 34 | } 35 | 36 | } // namespace rtc 37 | -------------------------------------------------------------------------------- /webrtc/modules/audio_coding/meson.build: -------------------------------------------------------------------------------- 1 | audio_coding_sources = [ 2 | 'codecs/isac/main/source/arith_routines.c', 3 | 'codecs/isac/main/source/arith_routines_hist.c', 4 | 'codecs/isac/main/source/arith_routines_logist.c', 5 | 'codecs/isac/main/source/encode_lpc_swb.c', 6 | 'codecs/isac/main/source/entropy_coding.c', 7 | 'codecs/isac/main/source/filter_functions.c', 8 | 'codecs/isac/main/source/filterbanks.c', 9 | 'codecs/isac/main/source/filterbank_tables.c', 10 | 'codecs/isac/main/source/intialize.c', 11 | 'codecs/isac/main/source/lpc_analysis.c', 12 | 'codecs/isac/main/source/lpc_gain_swb_tables.c', 13 | 'codecs/isac/main/source/lpc_shape_swb12_tables.c', 14 | 'codecs/isac/main/source/lpc_shape_swb16_tables.c', 15 | 'codecs/isac/main/source/lpc_tables.c', 16 | 'codecs/isac/main/source/pitch_estimator.c', 17 | 'codecs/isac/main/source/pitch_filter.c', 18 | 'codecs/isac/main/source/pitch_gain_tables.c', 19 | 'codecs/isac/main/source/pitch_lag_tables.c', 20 | 'codecs/isac/main/source/spectrum_ar_model_tables.c', 21 | ] 22 | 23 | libaudio_coding = static_library('audio_coding', 24 | audio_coding_sources, 25 | dependencies: common_deps, 26 | include_directories: webrtc_inc, 27 | c_args: common_cflags, 28 | cpp_args: common_cxxflags 29 | ) 30 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/critical_section_win.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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WIN_H_ 13 | 14 | #include 15 | #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 16 | #include "webrtc/typedefs.h" 17 | 18 | namespace webrtc { 19 | 20 | class CriticalSectionWindows : public CriticalSectionWrapper { 21 | public: 22 | CriticalSectionWindows(); 23 | 24 | virtual ~CriticalSectionWindows(); 25 | 26 | virtual void Enter(); 27 | virtual void Leave(); 28 | 29 | private: 30 | CRITICAL_SECTION crit; 31 | 32 | friend class ConditionVariableEventWin; 33 | friend class ConditionVariableNativeWin; 34 | }; 35 | 36 | } // namespace webrtc 37 | 38 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WIN_H_ 39 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ 13 | 14 | #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" 15 | #include "webrtc/typedefs.h" 16 | 17 | #include 18 | 19 | namespace webrtc { 20 | 21 | class RWLockPosix : public RWLockWrapper { 22 | public: 23 | static RWLockPosix* Create(); 24 | ~RWLockPosix() override; 25 | 26 | void AcquireLockExclusive() override; 27 | void ReleaseLockExclusive() override; 28 | 29 | void AcquireLockShared() override; 30 | void ReleaseLockShared() override; 31 | 32 | private: 33 | RWLockPosix(); 34 | bool Init(); 35 | 36 | pthread_rwlock_t lock_; 37 | }; 38 | 39 | } // namespace webrtc 40 | 41 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ 42 | -------------------------------------------------------------------------------- /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 "webrtc/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 | -------------------------------------------------------------------------------- /webrtc/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 WEBRTC_BASE_ARRAYSIZE_H_ 12 | #define WEBRTC_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 char (&ArraySizeHelper(T (&array)[N]))[N]; 28 | 29 | #define arraysize(array) (sizeof(ArraySizeHelper(array))) 30 | 31 | #endif // WEBRTC_BASE_ARRAYSIZE_H_ 32 | -------------------------------------------------------------------------------- /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 "webrtc/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 | -------------------------------------------------------------------------------- /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 WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_INTERNAL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_INTERNAL_H_ 13 | 14 | // TODO(turajs): Write a description of this function. Also be consistent with 15 | // usage of |sampling_rate_hz| vs |kSamplingFreqHz|. 16 | void GetSubframesPitchParameters(int sampling_rate_hz, 17 | double* gains, 18 | double* lags, 19 | int num_in_frames, 20 | int num_out_frames, 21 | double* log_old_gain, 22 | double* old_lag, 23 | double* log_pitch_gain, 24 | double* pitch_lag_hz); 25 | 26 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_INTERNAL_H_ 27 | -------------------------------------------------------------------------------- /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 WEBRTC_COMMON_AUDIO_FIR_FILTER_SSE_H_ 12 | #define WEBRTC_COMMON_AUDIO_FIR_FILTER_SSE_H_ 13 | 14 | #include "webrtc/base/scoped_ptr.h" 15 | #include "webrtc/common_audio/fir_filter.h" 16 | #include "webrtc/system_wrappers/include/aligned_malloc.h" 17 | 18 | namespace webrtc { 19 | 20 | class FIRFilterSSE2 : public FIRFilter { 21 | public: 22 | FIRFilterSSE2(const float* coefficients, 23 | size_t coefficients_length, 24 | size_t max_input_length); 25 | 26 | void Filter(const float* in, size_t length, float* out) override; 27 | 28 | private: 29 | size_t coefficients_length_; 30 | size_t state_length_; 31 | rtc::scoped_ptr coefficients_; 32 | rtc::scoped_ptr state_; 33 | }; 34 | 35 | } // namespace webrtc 36 | 37 | #endif // WEBRTC_COMMON_AUDIO_FIR_FILTER_SSE_H_ 38 | -------------------------------------------------------------------------------- /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 WEBRTC_COMMON_AUDIO_FIR_FILTER_NEON_H_ 12 | #define WEBRTC_COMMON_AUDIO_FIR_FILTER_NEON_H_ 13 | 14 | #include "webrtc/base/scoped_ptr.h" 15 | #include "webrtc/common_audio/fir_filter.h" 16 | #include "webrtc/system_wrappers/include/aligned_malloc.h" 17 | 18 | namespace webrtc { 19 | 20 | class FIRFilterNEON : public FIRFilter { 21 | public: 22 | FIRFilterNEON(const float* coefficients, 23 | size_t coefficients_length, 24 | size_t max_input_length); 25 | 26 | void Filter(const float* in, size_t length, float* out) override; 27 | 28 | private: 29 | size_t coefficients_length_; 30 | size_t state_length_; 31 | rtc::scoped_ptr coefficients_; 32 | rtc::scoped_ptr state_; 33 | }; 34 | 35 | } // namespace webrtc 36 | 37 | #endif // WEBRTC_COMMON_AUDIO_FIR_FILTER_NEON_H_ 38 | -------------------------------------------------------------------------------- /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 "webrtc/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 | -------------------------------------------------------------------------------- /webrtc/common_audio/signal_processing/dot_product_with_scale.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 "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 12 | 13 | int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, 14 | const int16_t* vector2, 15 | size_t length, 16 | int scaling) { 17 | int32_t sum = 0; 18 | size_t i = 0; 19 | 20 | /* Unroll the loop to improve performance. */ 21 | for (i = 0; i + 3 < length; i += 4) { 22 | sum += (vector1[i + 0] * vector2[i + 0]) >> scaling; 23 | sum += (vector1[i + 1] * vector2[i + 1]) >> scaling; 24 | sum += (vector1[i + 2] * vector2[i + 2]) >> scaling; 25 | sum += (vector1[i + 3] * vector2[i + 3]) >> scaling; 26 | } 27 | for (; i < length; i++) { 28 | sum += (vector1[i] * vector2[i]) >> scaling; 29 | } 30 | 31 | return sum; 32 | } 33 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/aec/aec_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 WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_COMMON_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_COMMON_H_ 13 | 14 | #include "webrtc/typedefs.h" 15 | 16 | #ifdef _MSC_VER /* visual c++ */ 17 | #define ALIGN16_BEG __declspec(align(16)) 18 | #define ALIGN16_END 19 | #else /* gcc or icc */ 20 | #define ALIGN16_BEG 21 | #define ALIGN16_END __attribute__((aligned(16))) 22 | #endif 23 | 24 | extern ALIGN16_BEG const float ALIGN16_END WebRtcAec_sqrtHanning[65]; 25 | extern ALIGN16_BEG const float ALIGN16_END WebRtcAec_weightCurve[65]; 26 | extern ALIGN16_BEG const float ALIGN16_END WebRtcAec_overDriveCurve[65]; 27 | extern const float WebRtcAec_kExtendedSmoothingCoefficients[2][2]; 28 | extern const float WebRtcAec_kNormalSmoothingCoefficients[2][2]; 29 | extern const float WebRtcAec_kMinFarendPSD; 30 | 31 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_COMMON_H_ 32 | 33 | -------------------------------------------------------------------------------- /webrtc/base/platform_thread.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_BASE_PLATFORM_THREAD_H_ 12 | #define WEBRTC_BASE_PLATFORM_THREAD_H_ 13 | 14 | #if defined(WEBRTC_WIN) 15 | #include 16 | #include 17 | #elif defined(WEBRTC_POSIX) 18 | #include 19 | #include 20 | #endif 21 | 22 | namespace rtc { 23 | 24 | #if defined(WEBRTC_WIN) 25 | typedef DWORD PlatformThreadId; 26 | typedef DWORD PlatformThreadRef; 27 | #elif defined(WEBRTC_POSIX) 28 | typedef pid_t PlatformThreadId; 29 | typedef pthread_t PlatformThreadRef; 30 | #endif 31 | 32 | PlatformThreadId CurrentThreadId(); 33 | PlatformThreadRef CurrentThreadRef(); 34 | 35 | // Compares two thread identifiers for equality. 36 | bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b); 37 | 38 | // Sets the current thread name. 39 | void SetCurrentThreadName(const char* name); 40 | 41 | } // namespace rtc 42 | 43 | #endif // WEBRTC_BASE_PLATFORM_THREAD_H_ 44 | -------------------------------------------------------------------------------- /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 | 12 | #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ 13 | #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ 14 | 15 | #include 16 | #include "webrtc/typedefs.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 | return x_int; 30 | } 31 | #else // Do a slow but correct implementation of lrint 32 | 33 | static __inline long int WebRtcIsac_lrint(double x_dbl) { 34 | long int x_int; 35 | x_int = (long int)floor(x_dbl + 0.499999999999); 36 | return x_int; 37 | } 38 | 39 | #endif 40 | 41 | #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ 42 | -------------------------------------------------------------------------------- /webrtc/base/platform_file.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 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 "webrtc/base/platform_file.h" 12 | 13 | #if defined(WEBRTC_WIN) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | namespace rtc { 20 | 21 | #if defined(WEBRTC_WIN) 22 | const PlatformFile kInvalidPlatformFileValue = INVALID_HANDLE_VALUE; 23 | 24 | FILE* FdopenPlatformFileForWriting(PlatformFile file) { 25 | if (file == kInvalidPlatformFileValue) 26 | return NULL; 27 | int fd = _open_osfhandle(reinterpret_cast(file), 0); 28 | if (fd < 0) 29 | return NULL; 30 | 31 | return _fdopen(fd, "w"); 32 | } 33 | 34 | bool ClosePlatformFile(PlatformFile file) { 35 | return CloseHandle(file) != 0; 36 | } 37 | #else 38 | const PlatformFile kInvalidPlatformFileValue = -1; 39 | 40 | FILE* FdopenPlatformFileForWriting(PlatformFile file) { 41 | return fdopen(file, "w"); 42 | } 43 | 44 | bool ClosePlatformFile(PlatformFile file) { 45 | return close(file); 46 | } 47 | #endif 48 | 49 | } // namespace rtc 50 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/trace_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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_ 13 | 14 | #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 15 | #include "webrtc/system_wrappers/source/trace_impl.h" 16 | 17 | namespace webrtc { 18 | 19 | class TracePosix : public TraceImpl { 20 | public: 21 | TracePosix(); 22 | ~TracePosix() override; 23 | 24 | // This method can be called on several different threads different from 25 | // the creating thread. 26 | int32_t AddTime(char* trace_message, const TraceLevel level) const override; 27 | 28 | int32_t AddDateTimeInfo(char* trace_message) const override; 29 | 30 | private: 31 | volatile mutable uint32_t prev_api_tick_count_; 32 | volatile mutable uint32_t prev_tick_count_; 33 | 34 | CriticalSectionWrapper& crit_sect_; 35 | }; 36 | 37 | } // namespace webrtc 38 | 39 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_ 40 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/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 "webrtc/system_wrappers/source/rw_lock_posix.h" 12 | 13 | namespace webrtc { 14 | 15 | RWLockPosix::RWLockPosix() : lock_() { 16 | } 17 | 18 | RWLockPosix::~RWLockPosix() { 19 | pthread_rwlock_destroy(&lock_); 20 | } 21 | 22 | RWLockPosix* RWLockPosix::Create() { 23 | RWLockPosix* ret_val = new RWLockPosix(); 24 | if (!ret_val->Init()) { 25 | delete ret_val; 26 | return NULL; 27 | } 28 | return ret_val; 29 | } 30 | 31 | bool RWLockPosix::Init() { 32 | return pthread_rwlock_init(&lock_, 0) == 0; 33 | } 34 | 35 | void RWLockPosix::AcquireLockExclusive() { 36 | pthread_rwlock_wrlock(&lock_); 37 | } 38 | 39 | void RWLockPosix::ReleaseLockExclusive() { 40 | pthread_rwlock_unlock(&lock_); 41 | } 42 | 43 | void RWLockPosix::AcquireLockShared() { 44 | pthread_rwlock_rdlock(&lock_); 45 | } 46 | 47 | void RWLockPosix::ReleaseLockShared() { 48 | pthread_rwlock_unlock(&lock_); 49 | } 50 | 51 | } // namespace webrtc 52 | -------------------------------------------------------------------------------- /webrtc/base/platform_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 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 WEBRTC_BASE_PLATFORM_FILE_H_ 12 | #define WEBRTC_BASE_PLATFORM_FILE_H_ 13 | 14 | #include 15 | 16 | #if defined(WEBRTC_WIN) 17 | #include 18 | #endif 19 | 20 | namespace rtc { 21 | 22 | #if defined(WEBRTC_WIN) 23 | typedef HANDLE PlatformFile; 24 | #elif defined(WEBRTC_POSIX) 25 | typedef int PlatformFile; 26 | #else 27 | #error Unsupported platform 28 | #endif 29 | 30 | extern const PlatformFile kInvalidPlatformFileValue; 31 | 32 | // Associates a standard FILE stream with an existing PlatformFile. 33 | // Note that after this function has returned a valid FILE stream, 34 | // the PlatformFile should no longer be used. 35 | FILE* FdopenPlatformFileForWriting(PlatformFile file); 36 | 37 | // Closes a PlatformFile. 38 | // Don't use ClosePlatformFile to close a file opened with FdopenPlatformFile. 39 | // Use fclose instead. 40 | bool ClosePlatformFile(PlatformFile file); 41 | 42 | } // namespace rtc 43 | 44 | #endif // WEBRTC_BASE_PLATFORM_FILE_H_ 45 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/thread_win.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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_ 13 | 14 | #include "webrtc/system_wrappers/include/thread_wrapper.h" 15 | 16 | #include 17 | 18 | #include "webrtc/base/thread_checker.h" 19 | 20 | namespace webrtc { 21 | 22 | class ThreadWindows : public ThreadWrapper { 23 | public: 24 | ThreadWindows(ThreadRunFunction func, void* obj, const char* thread_name); 25 | ~ThreadWindows() override; 26 | 27 | bool Start() override; 28 | bool Stop() override; 29 | 30 | bool SetPriority(ThreadPriority priority) override; 31 | 32 | protected: 33 | void Run(); 34 | 35 | private: 36 | static DWORD WINAPI StartThread(void* param); 37 | 38 | ThreadRunFunction const run_function_; 39 | void* const obj_; 40 | bool stop_; 41 | HANDLE thread_; 42 | const std::string name_; 43 | rtc::ThreadChecker main_thread_; 44 | }; 45 | 46 | } // namespace webrtc 47 | 48 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_ 49 | -------------------------------------------------------------------------------- /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 WEBRTC_COMMON_AUDIO_REAL_FOURIER_OOURA_H_ 12 | #define WEBRTC_COMMON_AUDIO_REAL_FOURIER_OOURA_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/base/scoped_ptr.h" 17 | #include "webrtc/common_audio/real_fourier.h" 18 | 19 | namespace webrtc { 20 | 21 | class RealFourierOoura : public RealFourier { 22 | public: 23 | explicit RealFourierOoura(int fft_order); 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 | const int order_; 34 | const size_t length_; 35 | const size_t complex_length_; 36 | // These are work arrays for Ooura. The names are based on the comments in 37 | // fft4g.c. 38 | const rtc::scoped_ptr work_ip_; 39 | const rtc::scoped_ptr work_w_; 40 | }; 41 | 42 | } // namespace webrtc 43 | 44 | #endif // WEBRTC_COMMON_AUDIO_REAL_FOURIER_OOURA_H_ 45 | 46 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/critical_section_posix.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 | // General note: return values for the various pthread synchronization APIs 12 | // are explicitly ignored here. In Chromium, the same thing is done for release. 13 | // However, in debugging, failure in these APIs are logged. 14 | // TODO(henrike): add logging when pthread synchronization APIs are failing. 15 | 16 | #include "webrtc/system_wrappers/source/critical_section_posix.h" 17 | 18 | namespace webrtc { 19 | 20 | CriticalSectionPosix::CriticalSectionPosix() { 21 | pthread_mutexattr_t attr; 22 | (void) pthread_mutexattr_init(&attr); 23 | (void) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 24 | (void) pthread_mutex_init(&mutex_, &attr); 25 | } 26 | 27 | CriticalSectionPosix::~CriticalSectionPosix() { 28 | (void) pthread_mutex_destroy(&mutex_); 29 | } 30 | 31 | void 32 | CriticalSectionPosix::Enter() { 33 | (void) pthread_mutex_lock(&mutex_); 34 | } 35 | 36 | void 37 | CriticalSectionPosix::Leave() { 38 | (void) pthread_mutex_unlock(&mutex_); 39 | } 40 | 41 | } // namespace webrtc 42 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/meson.build: -------------------------------------------------------------------------------- 1 | system_wrappers_sources = [ 2 | 'source/aligned_malloc.cc', 3 | 'source/cpu_features.cc', 4 | 'source/event.cc', 5 | 'source/file_impl.cc', 6 | 'source/critical_section.cc', 7 | 'source/logging.cc', 8 | 'source/metrics_default.cc', 9 | 'source/rw_lock.cc', 10 | 'source/sleep.cc', 11 | 'source/thread.cc', 12 | 'source/trace_impl.cc', 13 | ] 14 | 15 | if have_posix 16 | system_wrappers_sources += [ 17 | 'source/critical_section_posix.cc', 18 | 'source/event_timer_posix.cc', 19 | 'source/rw_lock_posix.cc', 20 | 'source/thread_posix.cc', 21 | 'source/trace_posix.cc', 22 | ] 23 | endif 24 | 25 | if have_win 26 | system_wrappers_sources += [ 27 | 'source/critical_section_win.cc', 28 | 'source/condition_variable.cc', 29 | 'source/condition_variable_event_win.cc', 30 | 'source/condition_variable_native_win.cc', 31 | 'source/event_timer_win.cc', 32 | 'source/rw_lock_win.cc', 33 | 'source/rw_lock_generic.cc', 34 | 'source/thread_win.cc', 35 | 'source/trace_win.cc', 36 | ] 37 | endif 38 | 39 | system_headers = [ 40 | 'include/trace.h', 41 | ] 42 | 43 | install_headers(system_headers, 44 | subdir: 'webrtc_audio_processing/webrtc/system_wrappers/include' 45 | ) 46 | 47 | libsystem_wrappers = static_library('system_wrappers', 48 | system_wrappers_sources, 49 | dependencies: common_deps, 50 | include_directories: webrtc_inc, 51 | c_args : common_cflags, 52 | cpp_args : common_cxxflags 53 | ) 54 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/rw_lock_generic.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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_GENERIC_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_GENERIC_H_ 13 | 14 | #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" 15 | #include "webrtc/typedefs.h" 16 | 17 | namespace webrtc { 18 | 19 | class CriticalSectionWrapper; 20 | class ConditionVariableWrapper; 21 | 22 | class RWLockGeneric : public RWLockWrapper { 23 | public: 24 | RWLockGeneric(); 25 | ~RWLockGeneric() override; 26 | 27 | void AcquireLockExclusive() override; 28 | void ReleaseLockExclusive() override; 29 | 30 | void AcquireLockShared() override; 31 | void ReleaseLockShared() override; 32 | 33 | private: 34 | CriticalSectionWrapper* critical_section_; 35 | ConditionVariableWrapper* read_condition_; 36 | ConditionVariableWrapper* write_condition_; 37 | 38 | int readers_active_; 39 | bool writer_active_; 40 | int readers_waiting_; 41 | int writers_waiting_; 42 | }; 43 | 44 | } // namespace webrtc 45 | 46 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_GENERIC_H_ 47 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/logging/aec_logging_file_handling.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_PROCESSING_AEC_AEC_LOGGING_FILE_HANDLING_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_LOGGING_FILE_HANDLING_ 13 | 14 | #include 15 | 16 | #include "webrtc/common_audio/wav_file.h" 17 | #include "webrtc/typedefs.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #ifdef WEBRTC_AEC_DEBUG_DUMP 24 | // Opens a new Wav file for writing. If it was already open with a different 25 | // sample frequency, it closes it first. 26 | void WebRtcAec_ReopenWav(const char* name, 27 | int instance_index, 28 | int process_rate, 29 | int sample_rate, 30 | rtc_WavWriter** wav_file); 31 | 32 | // Opens dumpfile with instance-specific filename. 33 | void WebRtcAec_RawFileOpen(const char* name, int instance_index, FILE** file); 34 | 35 | #endif // WEBRTC_AEC_DEBUG_DUMP 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_LOGGING_FILE_HANDLING_ 42 | -------------------------------------------------------------------------------- /webrtc/base/constructormagic.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 WEBRTC_BASE_CONSTRUCTORMAGIC_H_ 12 | #define WEBRTC_BASE_CONSTRUCTORMAGIC_H_ 13 | 14 | // Put this in the declarations for a class to be unassignable. 15 | #define RTC_DISALLOW_ASSIGN(TypeName) \ 16 | void operator=(const TypeName&) = delete 17 | 18 | // A macro to disallow the copy constructor and operator= functions. This should 19 | // be used in the declarations for a class. 20 | #define RTC_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 21 | TypeName(const TypeName&) = delete; \ 22 | RTC_DISALLOW_ASSIGN(TypeName) 23 | 24 | // A macro to disallow all the implicit constructors, namely the default 25 | // constructor, copy constructor and operator= functions. 26 | // 27 | // This should be used in the declarations for a class that wants to prevent 28 | // anyone from instantiating it. This is especially useful for classes 29 | // containing only static methods. 30 | #define RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ 31 | TypeName() = delete; \ 32 | RTC_DISALLOW_COPY_AND_ASSIGN(TypeName) 33 | 34 | #endif // WEBRTC_BASE_CONSTRUCTORMAGIC_H_ 35 | -------------------------------------------------------------------------------- /webrtc/base/event.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 WEBRTC_BASE_EVENT_H__ 12 | #define WEBRTC_BASE_EVENT_H__ 13 | 14 | #if defined(WEBRTC_WIN) 15 | #include "webrtc/base/win32.h" // NOLINT: consider this a system header. 16 | #elif defined(WEBRTC_POSIX) 17 | #include 18 | #else 19 | #error "Must define either WEBRTC_WIN or WEBRTC_POSIX." 20 | #endif 21 | 22 | #include "webrtc/base/basictypes.h" 23 | 24 | namespace rtc { 25 | 26 | class Event { 27 | public: 28 | static const int kForever = -1; 29 | 30 | Event(bool manual_reset, bool initially_signaled); 31 | ~Event(); 32 | 33 | void Set(); 34 | void Reset(); 35 | 36 | // Wait for the event to become signaled, for the specified number of 37 | // |milliseconds|. To wait indefinetly, pass kForever. 38 | bool Wait(int milliseconds); 39 | 40 | private: 41 | #if defined(WEBRTC_WIN) 42 | HANDLE event_handle_; 43 | #elif defined(WEBRTC_POSIX) 44 | pthread_mutex_t event_mutex_; 45 | pthread_cond_t event_cond_; 46 | const bool is_manual_reset_; 47 | bool event_status_; 48 | #endif 49 | }; 50 | 51 | } // namespace rtc 52 | 53 | #endif // WEBRTC_BASE_EVENT_H__ 54 | -------------------------------------------------------------------------------- /webrtc/common_types.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 "webrtc/common_types.h" 12 | 13 | #include 14 | 15 | namespace webrtc { 16 | 17 | int InStream::Rewind() { return -1; } 18 | 19 | int OutStream::Rewind() { return -1; } 20 | 21 | StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {} 22 | 23 | RTPHeaderExtension::RTPHeaderExtension() 24 | : hasTransmissionTimeOffset(false), 25 | transmissionTimeOffset(0), 26 | hasAbsoluteSendTime(false), 27 | absoluteSendTime(0), 28 | hasTransportSequenceNumber(false), 29 | transportSequenceNumber(0), 30 | hasAudioLevel(false), 31 | voiceActivity(false), 32 | audioLevel(0), 33 | hasVideoRotation(false), 34 | videoRotation(0) { 35 | } 36 | 37 | RTPHeader::RTPHeader() 38 | : markerBit(false), 39 | payloadType(0), 40 | sequenceNumber(0), 41 | timestamp(0), 42 | ssrc(0), 43 | numCSRCs(0), 44 | paddingLength(0), 45 | headerLength(0), 46 | payload_type_frequency(0), 47 | extension() { 48 | memset(&arrOfCSRCs, 0, sizeof(arrOfCSRCs)); 49 | } 50 | 51 | } // namespace webrtc 52 | -------------------------------------------------------------------------------- /webrtc/common_audio/signal_processing/filter_ar_fast_q12.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 | #include 11 | 12 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 13 | 14 | // TODO(bjornv): Change the return type to report errors. 15 | 16 | void WebRtcSpl_FilterARFastQ12(const int16_t* data_in, 17 | int16_t* data_out, 18 | const int16_t* __restrict coefficients, 19 | size_t coefficients_length, 20 | size_t data_length) { 21 | size_t i = 0; 22 | size_t j = 0; 23 | 24 | assert(data_length > 0); 25 | assert(coefficients_length > 1); 26 | 27 | for (i = 0; i < data_length; i++) { 28 | int32_t output = 0; 29 | int32_t sum = 0; 30 | 31 | for (j = coefficients_length - 1; j > 0; j--) { 32 | sum += coefficients[j] * data_out[i - j]; 33 | } 34 | 35 | output = coefficients[0] * data_in[i]; 36 | output -= sum; 37 | 38 | // Saturate and store the output. 39 | output = WEBRTC_SPL_SAT(134215679, output, -134217728); 40 | data_out[i] = (int16_t)((output + 2048) >> 12); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /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 "webrtc/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 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Google Inc. 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 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/condition_variable_event_win.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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_EVENT_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_EVENT_WIN_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/system_wrappers/include/condition_variable_wrapper.h" 17 | 18 | namespace webrtc { 19 | 20 | class ConditionVariableEventWin : public ConditionVariableWrapper { 21 | public: 22 | ConditionVariableEventWin(); 23 | virtual ~ConditionVariableEventWin(); 24 | 25 | void SleepCS(CriticalSectionWrapper& crit_sect); 26 | bool SleepCS(CriticalSectionWrapper& crit_sect, unsigned long max_time_inMS); 27 | void Wake(); 28 | void WakeAll(); 29 | 30 | private: 31 | enum EventWakeUpType { 32 | WAKEALL_0 = 0, 33 | WAKEALL_1 = 1, 34 | WAKE = 2, 35 | EVENT_COUNT = 3 36 | }; 37 | 38 | unsigned int num_waiters_[2]; 39 | EventWakeUpType eventID_; 40 | CRITICAL_SECTION num_waiters_crit_sect_; 41 | HANDLE events_[EVENT_COUNT]; 42 | }; 43 | 44 | } // namespace webrtc 45 | 46 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_EVENT_WIN_H_ 47 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/include/condition_variable_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 WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CONDITION_VARIABLE_WRAPPER_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CONDITION_VARIABLE_WRAPPER_H_ 13 | 14 | namespace webrtc { 15 | 16 | class CriticalSectionWrapper; 17 | 18 | class ConditionVariableWrapper { 19 | public: 20 | // Factory method, constructor disabled. 21 | static ConditionVariableWrapper* CreateConditionVariable(); 22 | 23 | virtual ~ConditionVariableWrapper() {} 24 | 25 | // Calling thread will atomically release crit_sect and wait until next 26 | // some other thread calls Wake() or WakeAll(). 27 | virtual void SleepCS(CriticalSectionWrapper& crit_sect) = 0; 28 | 29 | // Same as above but with a timeout. 30 | virtual bool SleepCS(CriticalSectionWrapper& crit_sect, 31 | unsigned long max_time_in_ms) = 0; 32 | 33 | // Wakes one thread calling SleepCS(). 34 | virtual void Wake() = 0; 35 | 36 | // Wakes all threads calling SleepCS(). 37 | virtual void WakeAll() = 0; 38 | }; 39 | 40 | } // namespace webrtc 41 | 42 | #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CONDITION_VARIABLE_WRAPPER_H_ 43 | -------------------------------------------------------------------------------- /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 "webrtc/modules/audio_processing/transient/moving_moments.h" 12 | 13 | #include 14 | #include 15 | 16 | #include "webrtc/base/scoped_ptr.h" 17 | 18 | namespace webrtc { 19 | 20 | MovingMoments::MovingMoments(size_t length) 21 | : length_(length), 22 | queue_(), 23 | sum_(0.0), 24 | sum_of_squares_(0.0) { 25 | assert(length > 0); 26 | for (size_t i = 0; i < length; ++i) { 27 | queue_.push(0.0); 28 | } 29 | } 30 | 31 | MovingMoments::~MovingMoments() {} 32 | 33 | void MovingMoments::CalculateMoments(const float* in, size_t in_length, 34 | float* first, float* second) { 35 | assert(in && in_length > 0 && first && second); 36 | 37 | for (size_t i = 0; i < in_length; ++i) { 38 | const float old_value = queue_.front(); 39 | queue_.pop(); 40 | queue_.push(in[i]); 41 | 42 | sum_ += in[i] - old_value; 43 | sum_of_squares_ += in[i] * in[i] - old_value * old_value; 44 | first[i] = sum_ / length_; 45 | second[i] = sum_of_squares_ / length_; 46 | } 47 | } 48 | 49 | } // namespace webrtc 50 | -------------------------------------------------------------------------------- /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 WEBRTC_COMMON_AUDIO_FIR_FILTER_H_ 12 | #define WEBRTC_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 | // Creates a filter with the given coefficients. All initial state values will 22 | // be zeros. 23 | // The length of the chunks fed to the filter should never be greater than 24 | // |max_input_length|. This is needed because, when vectorizing it is 25 | // necessary to concatenate the input after the state, and resizing this array 26 | // dynamically is expensive. 27 | static FIRFilter* Create(const float* coefficients, 28 | size_t coefficients_length, 29 | size_t max_input_length); 30 | 31 | virtual ~FIRFilter() {} 32 | 33 | // Filters the |in| data supplied. 34 | // |out| must be previously allocated and it must be at least of |length|. 35 | virtual void Filter(const float* in, size_t length, float* out) = 0; 36 | }; 37 | 38 | } // namespace webrtc 39 | 40 | #endif // WEBRTC_COMMON_AUDIO_FIR_FILTER_H_ 41 | -------------------------------------------------------------------------------- /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 WEBRTC_COMMON_AUDIO_VAD_VAD_GMM_H_ 14 | #define WEBRTC_COMMON_AUDIO_VAD_VAD_GMM_H_ 15 | 16 | #include "webrtc/typedefs.h" 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 // WEBRTC_COMMON_AUDIO_VAD_VAD_GMM_H_ 40 | -------------------------------------------------------------------------------- /webrtc/common_audio/signal_processing/filter_ma_fast_q12.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_FilterMAFastQ12(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | void WebRtcSpl_FilterMAFastQ12(const int16_t* in_ptr, 21 | int16_t* out_ptr, 22 | const int16_t* B, 23 | size_t B_length, 24 | size_t length) 25 | { 26 | size_t i, j; 27 | for (i = 0; i < length; i++) 28 | { 29 | int32_t o = 0; 30 | 31 | for (j = 0; j < B_length; j++) 32 | { 33 | o += B[j] * in_ptr[i - j]; 34 | } 35 | 36 | // If output is higher than 32768, saturate it. Same with negative side 37 | // 2^27 = 134217728, which corresponds to 32768 in Q12 38 | 39 | // Saturate the output 40 | o = WEBRTC_SPL_SAT((int32_t)134215679, o, (int32_t)-134217728); 41 | 42 | *out_ptr++ = (int16_t)((o + (int32_t)2048) >> 12); 43 | } 44 | return; 45 | } 46 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/aec/aec_resampler.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 WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_RESAMPLER_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_RESAMPLER_H_ 13 | 14 | #include "webrtc/modules/audio_processing/aec/aec_core.h" 15 | 16 | enum { 17 | kResamplingDelay = 1 18 | }; 19 | enum { 20 | kResamplerBufferSize = FRAME_LEN * 4 21 | }; 22 | 23 | // Unless otherwise specified, functions return 0 on success and -1 on error. 24 | void* WebRtcAec_CreateResampler(); // Returns NULL on error. 25 | int WebRtcAec_InitResampler(void* resampInst, int deviceSampleRateHz); 26 | void WebRtcAec_FreeResampler(void* resampInst); 27 | 28 | // Estimates skew from raw measurement. 29 | int WebRtcAec_GetSkew(void* resampInst, int rawSkew, float* skewEst); 30 | 31 | // Resamples input using linear interpolation. 32 | void WebRtcAec_ResampleLinear(void* resampInst, 33 | const float* inspeech, 34 | size_t size, 35 | float skew, 36 | float* outspeech, 37 | size_t* size_out); 38 | 39 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_RESAMPLER_H_ 40 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/condition_variable.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 "webrtc/system_wrappers/include/condition_variable_wrapper.h" 12 | 13 | #if defined(_WIN32) 14 | #include 15 | #include "webrtc/system_wrappers/source/condition_variable_event_win.h" 16 | #include "webrtc/system_wrappers/source/condition_variable_native_win.h" 17 | #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) 18 | #include 19 | #include "webrtc/system_wrappers/source/condition_variable_posix.h" 20 | #endif 21 | 22 | namespace webrtc { 23 | 24 | ConditionVariableWrapper* ConditionVariableWrapper::CreateConditionVariable() { 25 | #if defined(_WIN32) 26 | // Try to create native condition variable implementation. 27 | ConditionVariableWrapper* ret_val = ConditionVariableNativeWin::Create(); 28 | if (!ret_val) { 29 | // Native condition variable implementation does not exist. Create generic 30 | // condition variable based on events. 31 | ret_val = new ConditionVariableEventWin(); 32 | } 33 | return ret_val; 34 | #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) 35 | return ConditionVariablePosix::Create(); 36 | #else 37 | return NULL; 38 | #endif 39 | } 40 | 41 | } // namespace webrtc 42 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/rms_level.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 "webrtc/modules/audio_processing/rms_level.h" 12 | 13 | #include 14 | #include 15 | 16 | namespace webrtc { 17 | 18 | static const float kMaxSquaredLevel = 32768 * 32768; 19 | 20 | RMSLevel::RMSLevel() 21 | : sum_square_(0), 22 | sample_count_(0) {} 23 | 24 | RMSLevel::~RMSLevel() {} 25 | 26 | void RMSLevel::Reset() { 27 | sum_square_ = 0; 28 | sample_count_ = 0; 29 | } 30 | 31 | void RMSLevel::Process(const int16_t* data, size_t length) { 32 | for (size_t i = 0; i < length; ++i) { 33 | sum_square_ += data[i] * data[i]; 34 | } 35 | sample_count_ += length; 36 | } 37 | 38 | void RMSLevel::ProcessMuted(size_t length) { 39 | sample_count_ += length; 40 | } 41 | 42 | int RMSLevel::RMS() { 43 | if (sample_count_ == 0 || sum_square_ == 0) { 44 | Reset(); 45 | return kMinLevel; 46 | } 47 | 48 | // Normalize by the max level. 49 | float rms = sum_square_ / (sample_count_ * kMaxSquaredLevel); 50 | // 20log_10(x^0.5) = 10log_10(x) 51 | rms = 10 * log10(rms); 52 | assert(rms <= 0); 53 | if (rms < -kMinLevel) 54 | rms = -kMinLevel; 55 | 56 | rms = -rms; 57 | Reset(); 58 | return static_cast(rms + 0.5); 59 | } 60 | 61 | } // namespace webrtc 62 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/thread_posix.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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ 13 | 14 | #include "webrtc/base/event.h" 15 | #include "webrtc/base/scoped_ptr.h" 16 | #include "webrtc/base/thread_checker.h" 17 | #include "webrtc/system_wrappers/include/thread_wrapper.h" 18 | 19 | #include 20 | 21 | namespace webrtc { 22 | 23 | int ConvertToSystemPriority(ThreadPriority priority, int min_prio, 24 | int max_prio); 25 | 26 | class ThreadPosix : public ThreadWrapper { 27 | public: 28 | ThreadPosix(ThreadRunFunction func, void* obj, const char* thread_name); 29 | ~ThreadPosix() override; 30 | 31 | // From ThreadWrapper. 32 | bool Start() override; 33 | bool Stop() override; 34 | 35 | bool SetPriority(ThreadPriority priority) override; 36 | 37 | private: 38 | static void* StartThread(void* param); 39 | 40 | void Run(); 41 | 42 | rtc::ThreadChecker thread_checker_; 43 | ThreadRunFunction const run_function_; 44 | void* const obj_; 45 | rtc::Event stop_event_; 46 | const std::string name_; 47 | 48 | pthread_t thread_; 49 | }; 50 | 51 | } // namespace webrtc 52 | 53 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ 54 | -------------------------------------------------------------------------------- /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 WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_ 13 | 14 | #include "webrtc/base/scoped_ptr.h" 15 | #include "webrtc/typedefs.h" 16 | 17 | namespace webrtc { 18 | 19 | class FIRFilter; 20 | 21 | // A single node of a Wavelet Packet Decomposition (WPD) tree. 22 | class WPDNode { 23 | public: 24 | // Creates a WPDNode. The data vector will contain zeros. The filter will have 25 | // the coefficients provided. 26 | WPDNode(size_t length, const float* coefficients, size_t coefficients_length); 27 | ~WPDNode(); 28 | 29 | // Updates the node data. |parent_data| / 2 must be equals to |length_|. 30 | // Returns 0 if correct, and -1 otherwise. 31 | int Update(const float* parent_data, size_t parent_data_length); 32 | 33 | const float* data() const { return data_.get(); } 34 | // Returns 0 if correct, and -1 otherwise. 35 | int set_data(const float* new_data, size_t length); 36 | size_t length() const { return length_; } 37 | 38 | private: 39 | rtc::scoped_ptr data_; 40 | size_t length_; 41 | rtc::scoped_ptr filter_; 42 | }; 43 | 44 | } // namespace webrtc 45 | 46 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_ 47 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/event.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 "webrtc/system_wrappers/include/event_wrapper.h" 12 | 13 | #if defined(_WIN32) 14 | #include 15 | #include "webrtc/system_wrappers/source/event_timer_win.h" 16 | #elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) 17 | #include 18 | #include 19 | #include "webrtc/system_wrappers/source/event_timer_posix.h" 20 | #else 21 | #include 22 | #include "webrtc/system_wrappers/source/event_timer_posix.h" 23 | #endif 24 | 25 | #include "webrtc/base/event.h" 26 | 27 | namespace webrtc { 28 | 29 | class EventWrapperImpl : public EventWrapper { 30 | public: 31 | EventWrapperImpl() : event_(false, false) {} 32 | ~EventWrapperImpl() override {} 33 | 34 | bool Set() override { 35 | event_.Set(); 36 | return true; 37 | } 38 | 39 | EventTypeWrapper Wait(unsigned long max_time) override { 40 | int to_wait = max_time == WEBRTC_EVENT_INFINITE ? 41 | rtc::Event::kForever : static_cast(max_time); 42 | return event_.Wait(to_wait) ? kEventSignaled : kEventTimeout; 43 | } 44 | 45 | private: 46 | rtc::Event event_; 47 | }; 48 | 49 | // static 50 | EventWrapper* EventWrapper::Create() { 51 | return new EventWrapperImpl(); 52 | } 53 | 54 | } // namespace webrtc 55 | -------------------------------------------------------------------------------- /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 WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ 13 | 14 | #if defined(__cplusplus) || defined(c_plusplus) 15 | extern "C" { 16 | #endif 17 | 18 | #include "webrtc/typedefs.h" 19 | 20 | // List of features in x86. 21 | typedef enum { 22 | kSSE2, 23 | kSSE3 24 | } CPUFeature; 25 | 26 | // List of features in ARM. 27 | enum { 28 | kCPUFeatureARMv7 = (1 << 0), 29 | kCPUFeatureVFPv3 = (1 << 1), 30 | kCPUFeatureNEON = (1 << 2), 31 | kCPUFeatureLDREXSTREX = (1 << 3) 32 | }; 33 | 34 | typedef int (*WebRtc_CPUInfo)(CPUFeature feature); 35 | 36 | // Returns true if the CPU supports the feature. 37 | extern WebRtc_CPUInfo WebRtc_GetCPUInfo; 38 | 39 | // No CPU feature is available => straight C path. 40 | extern WebRtc_CPUInfo WebRtc_GetCPUInfoNoASM; 41 | 42 | // Return the features in an ARM device. 43 | // It detects the features in the hardware platform, and returns supported 44 | // values in the above enum definition as a bitmask. 45 | extern uint64_t WebRtc_GetCPUFeaturesARM(void); 46 | 47 | #if defined(__cplusplus) || defined(c_plusplus) 48 | } // extern "C" 49 | #endif 50 | 51 | #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ 52 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/processing_component.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 WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/common.h" 17 | 18 | namespace webrtc { 19 | 20 | class ProcessingComponent { 21 | public: 22 | ProcessingComponent(); 23 | virtual ~ProcessingComponent(); 24 | 25 | virtual int Initialize(); 26 | virtual void SetExtraOptions(const Config& config) {} 27 | virtual int Destroy(); 28 | 29 | bool is_component_enabled() const; 30 | 31 | protected: 32 | virtual int Configure(); 33 | int EnableComponent(bool enable); 34 | void* handle(int index) const; 35 | int num_handles() const; 36 | 37 | private: 38 | virtual void* CreateHandle() const = 0; 39 | virtual int InitializeHandle(void* handle) const = 0; 40 | virtual int ConfigureHandle(void* handle) const = 0; 41 | virtual void DestroyHandle(void* handle) const = 0; 42 | virtual int num_handles_required() const = 0; 43 | virtual int GetHandleError(void* handle) const = 0; 44 | 45 | std::vector handles_; 46 | bool initialized_; 47 | bool enabled_; 48 | int num_handles_; 49 | }; 50 | 51 | } // namespace webrtc 52 | 53 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H__ 54 | -------------------------------------------------------------------------------- /webrtc/base/thread_checker_impl.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_impl.h. 12 | 13 | #ifndef WEBRTC_BASE_THREAD_CHECKER_IMPL_H_ 14 | #define WEBRTC_BASE_THREAD_CHECKER_IMPL_H_ 15 | 16 | #include "webrtc/base/criticalsection.h" 17 | #include "webrtc/base/platform_thread.h" 18 | 19 | namespace rtc { 20 | 21 | // Real implementation of ThreadChecker, for use in debug mode, or 22 | // for temporary use in release mode (e.g. to RTC_CHECK on a threading issue 23 | // seen only in the wild). 24 | // 25 | // Note: You should almost always use the ThreadChecker class to get the 26 | // right version for your build configuration. 27 | class ThreadCheckerImpl { 28 | public: 29 | ThreadCheckerImpl(); 30 | ~ThreadCheckerImpl(); 31 | 32 | bool CalledOnValidThread() const; 33 | 34 | // Changes the thread that is checked for in CalledOnValidThread. This may 35 | // be useful when an object may be created on one thread and then used 36 | // exclusively on another thread. 37 | void DetachFromThread(); 38 | 39 | private: 40 | mutable CriticalSection lock_; 41 | // This is mutable so that CalledOnValidThread can set it. 42 | // It's guarded by |lock_|. 43 | mutable PlatformThreadRef valid_thread_; 44 | }; 45 | 46 | } // namespace rtc 47 | 48 | #endif // WEBRTC_BASE_THREAD_CHECKER_IMPL_H_ 49 | -------------------------------------------------------------------------------- /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 WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_INTERNAL_H_ 14 | #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_INTERNAL_H_ 15 | 16 | #include "webrtc/modules/audio_processing/utility/delay_estimator.h" 17 | #include "webrtc/typedefs.h" 18 | 19 | typedef union { 20 | float float_; 21 | int32_t int32_; 22 | } SpectrumType; 23 | 24 | typedef struct { 25 | // Pointers to mean values of spectrum. 26 | SpectrumType* mean_far_spectrum; 27 | // |mean_far_spectrum| initialization indicator. 28 | int far_spectrum_initialized; 29 | 30 | int spectrum_size; 31 | 32 | // Far-end part of binary spectrum based delay estimation. 33 | BinaryDelayEstimatorFarend* binary_farend; 34 | } DelayEstimatorFarend; 35 | 36 | typedef struct { 37 | // Pointers to mean values of spectrum. 38 | SpectrumType* mean_near_spectrum; 39 | // |mean_near_spectrum| initialization indicator. 40 | int near_spectrum_initialized; 41 | 42 | int spectrum_size; 43 | 44 | // Binary spectrum based delay estimator 45 | BinaryDelayEstimator* binary_handle; 46 | } DelayEstimator; 47 | 48 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_INTERNAL_H_ 49 | -------------------------------------------------------------------------------- /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 WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_ 12 | #define WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_ 13 | 14 | #include "webrtc/base/checks.h" 15 | #include "webrtc/base/scoped_ptr.h" 16 | #include "webrtc/common_audio/vad/include/webrtc_vad.h" 17 | #include "webrtc/typedefs.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 | rtc::scoped_ptr CreateVad(Vad::Aggressiveness aggressiveness); 47 | 48 | } // namespace webrtc 49 | 50 | #endif // WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_ 51 | -------------------------------------------------------------------------------- /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 "webrtc/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 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/event_timer_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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_POSIX_H_ 13 | 14 | #include "webrtc/system_wrappers/include/event_wrapper.h" 15 | 16 | #include 17 | #include 18 | 19 | #include "webrtc/system_wrappers/include/thread_wrapper.h" 20 | 21 | namespace webrtc { 22 | 23 | enum State { 24 | kUp = 1, 25 | kDown = 2 26 | }; 27 | 28 | class EventTimerPosix : public EventTimerWrapper { 29 | public: 30 | EventTimerPosix(); 31 | ~EventTimerPosix() override; 32 | 33 | EventTypeWrapper Wait(unsigned long max_time) override; 34 | bool Set() override; 35 | 36 | bool StartTimer(bool periodic, unsigned long time) override; 37 | bool StopTimer() override; 38 | 39 | private: 40 | static bool Run(void* obj); 41 | bool Process(); 42 | EventTypeWrapper Wait(timespec* end_at); 43 | 44 | private: 45 | pthread_cond_t cond_; 46 | pthread_mutex_t mutex_; 47 | bool event_set_; 48 | 49 | rtc::scoped_ptr timer_thread_; 50 | rtc::scoped_ptr timer_event_; 51 | timespec created_at_; 52 | 53 | bool periodic_; 54 | unsigned long time_; // In ms 55 | unsigned long count_; 56 | }; 57 | 58 | } // namespace webrtc 59 | 60 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_POSIX_H_ 61 | -------------------------------------------------------------------------------- /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 "webrtc/common_audio/resampler/sinc_resampler.h" 15 | 16 | #include 17 | 18 | namespace webrtc { 19 | 20 | float SincResampler::Convolve_NEON(const float* input_ptr, const float* k1, 21 | const float* k2, 22 | double kernel_interpolation_factor) { 23 | float32x4_t m_input; 24 | float32x4_t m_sums1 = vmovq_n_f32(0); 25 | float32x4_t m_sums2 = vmovq_n_f32(0); 26 | 27 | const float* upper = input_ptr + kKernelSize; 28 | for (; input_ptr < upper; ) { 29 | m_input = vld1q_f32(input_ptr); 30 | input_ptr += 4; 31 | m_sums1 = vmlaq_f32(m_sums1, m_input, vld1q_f32(k1)); 32 | k1 += 4; 33 | m_sums2 = vmlaq_f32(m_sums2, m_input, vld1q_f32(k2)); 34 | k2 += 4; 35 | } 36 | 37 | // Linearly interpolate the two "convolutions". 38 | m_sums1 = vmlaq_f32( 39 | vmulq_f32(m_sums1, vmovq_n_f32(1.0 - kernel_interpolation_factor)), 40 | m_sums2, vmovq_n_f32(kernel_interpolation_factor)); 41 | 42 | // Sum components together. 43 | float32x2_t m_half = vadd_f32(vget_high_f32(m_sums1), vget_low_f32(m_sums1)); 44 | return vget_lane_f32(vpadd_f32(m_half, m_half), 0); 45 | } 46 | 47 | } // namespace webrtc 48 | -------------------------------------------------------------------------------- /webrtc/modules/audio_coding/codecs/isac/main/source/filterbank_tables.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 | /* filterbank_tables.c*/ 12 | /* This file contains variables that are used in filterbanks.c*/ 13 | 14 | #include "filterbank_tables.h" 15 | #include "settings.h" 16 | 17 | /* The composite all-pass filter factors */ 18 | const float WebRtcIsac_kCompositeApFactorsFloat[4] = { 19 | 0.03470000000000f, 0.15440000000000f, 0.38260000000000f, 0.74400000000000f}; 20 | 21 | /* The upper channel all-pass filter factors */ 22 | const float WebRtcIsac_kUpperApFactorsFloat[2] = { 23 | 0.03470000000000f, 0.38260000000000f}; 24 | 25 | /* The lower channel all-pass filter factors */ 26 | const float WebRtcIsac_kLowerApFactorsFloat[2] = { 27 | 0.15440000000000f, 0.74400000000000f}; 28 | 29 | /* The matrix for transforming the backward composite state to upper channel state */ 30 | const float WebRtcIsac_kTransform1Float[8] = { 31 | -0.00158678506084f, 0.00127157815343f, -0.00104805672709f, 0.00084837248079f, 32 | 0.00134467983258f, -0.00107756549387f, 0.00088814793277f, -0.00071893072525f}; 33 | 34 | /* The matrix for transforming the backward composite state to lower channel state */ 35 | const float WebRtcIsac_kTransform2Float[8] = { 36 | -0.00170686041697f, 0.00136780109829f, -0.00112736532350f, 0.00091257055385f, 37 | 0.00103094281812f, -0.00082615076557f, 0.00068092756088f, -0.00055119165484f}; 38 | -------------------------------------------------------------------------------- /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 WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_ 20 | #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_ 21 | 22 | #include "settings.h" 23 | #include "webrtc/typedefs.h" 24 | 25 | extern const double WebRtcIsac_kQSizeLpcGain; 26 | 27 | extern const double WebRtcIsac_kLeftRecPointLpcGain[SUBFRAMES]; 28 | 29 | extern const int16_t WebRtcIsac_kNumQCellLpcGain[SUBFRAMES]; 30 | 31 | extern const uint16_t WebRtcIsac_kLpcGainEntropySearch[SUBFRAMES]; 32 | 33 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec0[18]; 34 | 35 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec1[21]; 36 | 37 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec2[26]; 38 | 39 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec3[46]; 40 | 41 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec4[78]; 42 | 43 | extern const uint16_t WebRtcIsac_kLpcGainCdfVec5[171]; 44 | 45 | extern const uint16_t* WebRtcIsac_kLpcGainCdfMat[SUBFRAMES]; 46 | 47 | extern const double WebRtcIsac_kLpcGainDecorrMat[SUBFRAMES][SUBFRAMES]; 48 | 49 | #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_ 50 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/ns/noise_suppression_x.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 "webrtc/modules/audio_processing/ns/include/noise_suppression_x.h" 12 | 13 | #include 14 | 15 | #include "webrtc/common_audio/signal_processing/include/real_fft.h" 16 | #include "webrtc/modules/audio_processing/ns/nsx_core.h" 17 | #include "webrtc/modules/audio_processing/ns/nsx_defines.h" 18 | 19 | NsxHandle* WebRtcNsx_Create() { 20 | NoiseSuppressionFixedC* self = malloc(sizeof(NoiseSuppressionFixedC)); 21 | WebRtcSpl_Init(); 22 | self->real_fft = NULL; 23 | self->initFlag = 0; 24 | return (NsxHandle*)self; 25 | } 26 | 27 | void WebRtcNsx_Free(NsxHandle* nsxInst) { 28 | WebRtcSpl_FreeRealFFT(((NoiseSuppressionFixedC*)nsxInst)->real_fft); 29 | free(nsxInst); 30 | } 31 | 32 | int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs) { 33 | return WebRtcNsx_InitCore((NoiseSuppressionFixedC*)nsxInst, fs); 34 | } 35 | 36 | int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode) { 37 | return WebRtcNsx_set_policy_core((NoiseSuppressionFixedC*)nsxInst, mode); 38 | } 39 | 40 | void WebRtcNsx_Process(NsxHandle* nsxInst, 41 | const short* const* speechFrame, 42 | int num_bands, 43 | short* const* outFrame) { 44 | WebRtcNsx_ProcessCore((NoiseSuppressionFixedC*)nsxInst, speechFrame, 45 | num_bands, outFrame); 46 | } 47 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/include/fix_interlocked_exchange_pointer_win.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 | // Various inline functions and macros to fix compilation of 32 bit target 12 | // on MSVC with /Wp64 flag enabled. 13 | 14 | // The original code can be found here: 15 | // http://src.chromium.org/svn/trunk/src/base/fix_wp64.h 16 | 17 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_FIX_INTERLOCKED_EXCHANGE_POINTER_WINDOWS_H_ 18 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_FIX_INTERLOCKED_EXCHANGE_POINTER_WINDOWS_H_ 19 | 20 | #include 21 | 22 | // Platform SDK fixes when building with /Wp64 for a 32 bits target. 23 | #if !defined(_WIN64) && defined(_Wp64) 24 | 25 | #ifdef InterlockedExchangePointer 26 | #undef InterlockedExchangePointer 27 | // The problem is that the macro provided for InterlockedExchangePointer() is 28 | // doing a (LONG) C-style cast that triggers invariably the warning C4312 when 29 | // building on 32 bits. 30 | inline void* InterlockedExchangePointer(void* volatile* target, void* value) { 31 | return reinterpret_cast(static_cast(InterlockedExchange( 32 | reinterpret_cast(target), 33 | static_cast(reinterpret_cast(value))))); 34 | } 35 | #endif // #ifdef InterlockedExchangePointer 36 | 37 | #endif // #if !defined(_WIN64) && defined(_Wp64) 38 | 39 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_FIX_INTERLOCKED_EXCHANGE_POINTER_WINDOWS_H_ 40 | -------------------------------------------------------------------------------- /webrtc/modules/audio_coding/codecs/isac/main/source/pitch_gain_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 | * pitch_gain_tables.h 13 | * 14 | * This file contains tables for the pitch filter side-info in the entropy coder. 15 | * 16 | */ 17 | 18 | #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_GAIN_TABLES_H_ 19 | #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_GAIN_TABLES_H_ 20 | 21 | #include "webrtc/typedefs.h" 22 | 23 | /* header file for coding tables for the pitch filter side-info in the entropy coder */ 24 | /********************* Pitch Filter Gain Coefficient Tables ************************/ 25 | /* cdf for quantized pitch filter gains */ 26 | extern const uint16_t WebRtcIsac_kQPitchGainCdf[255]; 27 | 28 | /* index limits and ranges */ 29 | extern const int16_t WebRtcIsac_kIndexLowerLimitGain[3]; 30 | 31 | extern const int16_t WebRtcIsac_kIndexUpperLimitGain[3]; 32 | extern const uint16_t WebRtcIsac_kIndexMultsGain[2]; 33 | 34 | /* mean values of pitch filter gains */ 35 | //(Y) 36 | extern const int16_t WebRtcIsac_kQMeanGain1Q12[144]; 37 | extern const int16_t WebRtcIsac_kQMeanGain2Q12[144]; 38 | extern const int16_t WebRtcIsac_kQMeanGain3Q12[144]; 39 | extern const int16_t WebRtcIsac_kQMeanGain4Q12[144]; 40 | //(Y) 41 | 42 | /* size of cdf table */ 43 | extern const uint16_t WebRtcIsac_kQCdfTableSizeGain[1]; 44 | 45 | #endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_GAIN_TABLES_H_ */ 46 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/vad/pole_zero_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 WEBRTC_MODULES_AUDIO_PROCESSING_VAD_POLE_ZERO_FILTER_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_POLE_ZERO_FILTER_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/typedefs.h" 17 | 18 | namespace webrtc { 19 | 20 | class PoleZeroFilter { 21 | public: 22 | ~PoleZeroFilter() {} 23 | 24 | static PoleZeroFilter* Create(const float* numerator_coefficients, 25 | size_t order_numerator, 26 | const float* denominator_coefficients, 27 | size_t order_denominator); 28 | 29 | int Filter(const int16_t* in, size_t num_input_samples, float* output); 30 | 31 | private: 32 | PoleZeroFilter(const float* numerator_coefficients, 33 | size_t order_numerator, 34 | const float* denominator_coefficients, 35 | size_t order_denominator); 36 | 37 | static const int kMaxFilterOrder = 24; 38 | 39 | int16_t past_input_[kMaxFilterOrder * 2]; 40 | float past_output_[kMaxFilterOrder * 2]; 41 | 42 | float numerator_coefficients_[kMaxFilterOrder + 1]; 43 | float denominator_coefficients_[kMaxFilterOrder + 1]; 44 | 45 | size_t order_numerator_; 46 | size_t order_denominator_; 47 | size_t highest_order_; 48 | }; 49 | 50 | } // namespace webrtc 51 | 52 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_VAD_POLE_ZERO_FILTER_H_ 53 | -------------------------------------------------------------------------------- /webrtc/modules/audio_coding/codecs/isac/main/source/lpc_analysis.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 | * lpc_analysis.h 13 | * 14 | * LPC functions 15 | * 16 | */ 17 | 18 | #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYSIS_H_ 19 | #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYSIS_H_ 20 | 21 | #include "settings.h" 22 | #include "structs.h" 23 | 24 | double WebRtcIsac_LevDurb(double *a, double *k, double *r, size_t order); 25 | 26 | void WebRtcIsac_GetVars(const double *input, const int16_t *pitchGains_Q12, 27 | double *oldEnergy, double *varscale); 28 | 29 | void WebRtcIsac_GetLpcCoefLb(double *inLo, double *inHi, MaskFiltstr *maskdata, 30 | double signal_noise_ratio, const int16_t *pitchGains_Q12, 31 | double *lo_coeff, double *hi_coeff); 32 | 33 | 34 | void WebRtcIsac_GetLpcGain( 35 | double signal_noise_ratio, 36 | const double* filtCoeffVecs, 37 | int numVecs, 38 | double* gain, 39 | double corrLo[][UB_LPC_ORDER + 1], 40 | const double* varscale); 41 | 42 | void WebRtcIsac_GetLpcCoefUb( 43 | double* inSignal, 44 | MaskFiltstr* maskdata, 45 | double* lpCoeff, 46 | double corr[][UB_LPC_ORDER + 1], 47 | double* varscale, 48 | int16_t bandwidth); 49 | 50 | #endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYIS_H_ */ 51 | -------------------------------------------------------------------------------- /webrtc/common_audio/audio_util.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 "webrtc/common_audio/include/audio_util.h" 12 | 13 | #include "webrtc/typedefs.h" 14 | 15 | namespace webrtc { 16 | 17 | void FloatToS16(const float* src, size_t size, int16_t* dest) { 18 | for (size_t i = 0; i < size; ++i) 19 | dest[i] = FloatToS16(src[i]); 20 | } 21 | 22 | void S16ToFloat(const int16_t* src, size_t size, float* dest) { 23 | for (size_t i = 0; i < size; ++i) 24 | dest[i] = S16ToFloat(src[i]); 25 | } 26 | 27 | void FloatS16ToS16(const float* src, size_t size, int16_t* dest) { 28 | for (size_t i = 0; i < size; ++i) 29 | dest[i] = FloatS16ToS16(src[i]); 30 | } 31 | 32 | void FloatToFloatS16(const float* src, size_t size, float* dest) { 33 | for (size_t i = 0; i < size; ++i) 34 | dest[i] = FloatToFloatS16(src[i]); 35 | } 36 | 37 | void FloatS16ToFloat(const float* src, size_t size, float* dest) { 38 | for (size_t i = 0; i < size; ++i) 39 | dest[i] = FloatS16ToFloat(src[i]); 40 | } 41 | 42 | template <> 43 | void DownmixInterleavedToMono(const int16_t* interleaved, 44 | size_t num_frames, 45 | int num_channels, 46 | int16_t* deinterleaved) { 47 | DownmixInterleavedToMonoImpl(interleaved, num_frames, 48 | num_channels, deinterleaved); 49 | } 50 | 51 | } // namespace webrtc 52 | -------------------------------------------------------------------------------- /webrtc/modules/audio_coding/codecs/isac/main/source/filterbank_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 | * filterbank_tables.h 13 | * 14 | * Header file for variables that are defined in 15 | * filterbank_tables.c. 16 | * 17 | */ 18 | 19 | #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FILTERBANK_TABLES_H_ 20 | #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FILTERBANK_TABLES_H_ 21 | 22 | #include "structs.h" 23 | 24 | /********************* Coefficient Tables ************************/ 25 | /* The number of composite all-pass filter factors */ 26 | #define NUMBEROFCOMPOSITEAPSECTIONS 4 27 | 28 | /* The number of all-pass filter factors in an upper or lower channel*/ 29 | #define NUMBEROFCHANNELAPSECTIONS 2 30 | 31 | /* The composite all-pass filter factors */ 32 | extern const float WebRtcIsac_kCompositeApFactorsFloat[4]; 33 | 34 | /* The upper channel all-pass filter factors */ 35 | extern const float WebRtcIsac_kUpperApFactorsFloat[2]; 36 | 37 | /* The lower channel all-pass filter factors */ 38 | extern const float WebRtcIsac_kLowerApFactorsFloat[2]; 39 | 40 | /* The matrix for transforming the backward composite state to upper channel state */ 41 | extern const float WebRtcIsac_kTransform1Float[8]; 42 | 43 | /* The matrix for transforming the backward composite state to lower channel state */ 44 | extern const float WebRtcIsac_kTransform2Float[8]; 45 | 46 | #endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FILTERBANK_TABLES_H_ */ 47 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/high_pass_filter_impl.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 WEBRTC_MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_IMPL_H_ 13 | 14 | #include "webrtc/modules/audio_processing/include/audio_processing.h" 15 | #include "webrtc/modules/audio_processing/processing_component.h" 16 | 17 | namespace webrtc { 18 | 19 | class AudioBuffer; 20 | class CriticalSectionWrapper; 21 | 22 | class HighPassFilterImpl : public HighPassFilter, 23 | public ProcessingComponent { 24 | public: 25 | HighPassFilterImpl(const AudioProcessing* apm, CriticalSectionWrapper* crit); 26 | virtual ~HighPassFilterImpl(); 27 | 28 | int ProcessCaptureAudio(AudioBuffer* audio); 29 | 30 | // HighPassFilter implementation. 31 | bool is_enabled() const override; 32 | 33 | private: 34 | // HighPassFilter implementation. 35 | int Enable(bool enable) override; 36 | 37 | // ProcessingComponent implementation. 38 | void* CreateHandle() const override; 39 | int InitializeHandle(void* handle) const override; 40 | int ConfigureHandle(void* handle) const override; 41 | void DestroyHandle(void* handle) const override; 42 | int num_handles_required() const override; 43 | int GetHandleError(void* handle) const override; 44 | 45 | const AudioProcessing* apm_; 46 | CriticalSectionWrapper* crit_; 47 | }; 48 | } // namespace webrtc 49 | 50 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_IMPL_H_ 51 | -------------------------------------------------------------------------------- /webrtc/common_audio/signal_processing/downsample_fast.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 "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 12 | 13 | // TODO(Bjornv): Change the function parameter order to WebRTC code style. 14 | // C version of WebRtcSpl_DownsampleFast() for generic platforms. 15 | int WebRtcSpl_DownsampleFastC(const int16_t* data_in, 16 | size_t data_in_length, 17 | int16_t* data_out, 18 | size_t data_out_length, 19 | const int16_t* __restrict coefficients, 20 | size_t coefficients_length, 21 | int factor, 22 | size_t delay) { 23 | size_t i = 0; 24 | size_t j = 0; 25 | int32_t out_s32 = 0; 26 | size_t endpos = delay + factor * (data_out_length - 1) + 1; 27 | 28 | // Return error if any of the running conditions doesn't meet. 29 | if (data_out_length == 0 || coefficients_length == 0 30 | || data_in_length < endpos) { 31 | return -1; 32 | } 33 | 34 | for (i = delay; i < endpos; i += factor) { 35 | out_s32 = 2048; // Round value, 0.5 in Q12. 36 | 37 | for (j = 0; j < coefficients_length; j++) { 38 | out_s32 += coefficients[j] * data_in[i - j]; // Q12. 39 | } 40 | 41 | out_s32 >>= 12; // Q0. 42 | 43 | // Saturate and store the output. 44 | *data_out++ = WebRtcSpl_SatW32ToW16(out_s32); 45 | } 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/include/asm_defines.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 WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ASM_DEFINES_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ASM_DEFINES_H_ 13 | 14 | #if defined(__linux__) && defined(__ELF__) 15 | .section .note.GNU-stack,"",%progbits 16 | #endif 17 | 18 | // Define the macros used in ARM assembly code, so that for Mac or iOS builds 19 | // we add leading underscores for the function names. 20 | #ifdef __APPLE__ 21 | .macro GLOBAL_FUNCTION name 22 | .global _\name 23 | .private_extern _\name 24 | .endm 25 | .macro DEFINE_FUNCTION name 26 | _\name: 27 | .endm 28 | .macro CALL_FUNCTION name 29 | bl _\name 30 | .endm 31 | .macro GLOBAL_LABEL name 32 | .global _\name 33 | .private_extern _\name 34 | .endm 35 | #else 36 | .macro GLOBAL_FUNCTION name 37 | .global \name 38 | .hidden \name 39 | .endm 40 | .macro DEFINE_FUNCTION name 41 | #if defined(__linux__) && defined(__ELF__) 42 | .type \name,%function 43 | #endif 44 | \name: 45 | .endm 46 | .macro CALL_FUNCTION name 47 | bl \name 48 | .endm 49 | .macro GLOBAL_LABEL name 50 | .global \name 51 | .hidden \name 52 | .endm 53 | #endif 54 | 55 | // With Apple's clang compiler, for instructions ldrb, strh, etc., 56 | // the condition code is after the width specifier. Here we define 57 | // only the ones that are actually used in the assembly files. 58 | #if (defined __llvm__) && (defined __APPLE__) 59 | .macro streqh reg1, reg2, num 60 | strheq \reg1, \reg2, \num 61 | .endm 62 | #endif 63 | 64 | .text 65 | 66 | #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ASM_DEFINES_H_ 67 | -------------------------------------------------------------------------------- /webrtc/common_audio/vad/vad.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 "webrtc/common_audio/vad/include/vad.h" 12 | 13 | #include "webrtc/base/checks.h" 14 | 15 | namespace webrtc { 16 | 17 | namespace { 18 | 19 | class VadImpl final : public Vad { 20 | public: 21 | explicit VadImpl(Aggressiveness aggressiveness) 22 | : handle_(nullptr), aggressiveness_(aggressiveness) { 23 | Reset(); 24 | } 25 | 26 | ~VadImpl() override { WebRtcVad_Free(handle_); } 27 | 28 | Activity VoiceActivity(const int16_t* audio, 29 | size_t num_samples, 30 | int sample_rate_hz) override { 31 | int ret = WebRtcVad_Process(handle_, sample_rate_hz, audio, num_samples); 32 | switch (ret) { 33 | case 0: 34 | return kPassive; 35 | case 1: 36 | return kActive; 37 | default: 38 | RTC_DCHECK(false) << "WebRtcVad_Process returned an error."; 39 | return kError; 40 | } 41 | } 42 | 43 | void Reset() override { 44 | if (handle_) 45 | WebRtcVad_Free(handle_); 46 | handle_ = WebRtcVad_Create(); 47 | RTC_CHECK(handle_); 48 | RTC_CHECK_EQ(WebRtcVad_Init(handle_), 0); 49 | RTC_CHECK_EQ(WebRtcVad_set_mode(handle_, aggressiveness_), 0); 50 | } 51 | 52 | private: 53 | VadInst* handle_; 54 | Aggressiveness aggressiveness_; 55 | }; 56 | 57 | } // namespace 58 | 59 | rtc::scoped_ptr CreateVad(Vad::Aggressiveness aggressiveness) { 60 | return rtc::scoped_ptr(new VadImpl(aggressiveness)); 61 | } 62 | 63 | } // namespace webrtc 64 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/vad/gmm.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 WEBRTC_MODULES_AUDIO_PROCESSING_VAD_GMM_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_GMM_H_ 13 | 14 | namespace webrtc { 15 | 16 | // A structure that specifies a GMM. 17 | // A GMM is formulated as 18 | // f(x) = w[0] * mixture[0] + w[1] * mixture[1] + ... + 19 | // w[num_mixtures - 1] * mixture[num_mixtures - 1]; 20 | // Where a 'mixture' is a Gaussian density. 21 | 22 | struct GmmParameters { 23 | // weight[n] = log(w[n]) - |dimension|/2 * log(2*pi) - 1/2 * log(det(cov[n])); 24 | // where cov[n] is the covariance matrix of mixture n; 25 | const double* weight; 26 | // pointer to the first element of a |num_mixtures|x|dimension| matrix 27 | // where kth row is the mean of the kth mixture. 28 | const double* mean; 29 | // pointer to the first element of a |num_mixtures|x|dimension|x|dimension| 30 | // 3D-matrix, where the kth 2D-matrix is the inverse of the covariance 31 | // matrix of the kth mixture. 32 | const double* covar_inverse; 33 | // Dimensionality of the mixtures. 34 | int dimension; 35 | // number of the mixtures. 36 | int num_mixtures; 37 | }; 38 | 39 | // Evaluate the given GMM, according to |gmm_parameters|, at the given point 40 | // |x|. If the dimensionality of the given GMM is larger that the maximum 41 | // acceptable dimension by the following function -1 is returned. 42 | double EvaluateGmm(const double* x, const GmmParameters& gmm_parameters); 43 | 44 | } // namespace webrtc 45 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_VAD_GMM_H_ 46 | -------------------------------------------------------------------------------- /webrtc/common_audio/signal_processing/resample_by_2_internal.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 | /* 13 | * This header file contains some internal resampling functions. 14 | * 15 | */ 16 | 17 | #ifndef WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_ 18 | #define WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_ 19 | 20 | #include "webrtc/typedefs.h" 21 | 22 | /******************************************************************* 23 | * resample_by_2_fast.c 24 | * Functions for internal use in the other resample functions 25 | ******************************************************************/ 26 | void WebRtcSpl_DownBy2IntToShort(int32_t *in, int32_t len, int16_t *out, 27 | int32_t *state); 28 | 29 | void WebRtcSpl_DownBy2ShortToInt(const int16_t *in, int32_t len, 30 | int32_t *out, int32_t *state); 31 | 32 | void WebRtcSpl_UpBy2ShortToInt(const int16_t *in, int32_t len, 33 | int32_t *out, int32_t *state); 34 | 35 | void WebRtcSpl_UpBy2IntToInt(const int32_t *in, int32_t len, int32_t *out, 36 | int32_t *state); 37 | 38 | void WebRtcSpl_UpBy2IntToShort(const int32_t *in, int32_t len, 39 | int16_t *out, int32_t *state); 40 | 41 | void WebRtcSpl_LPBy2ShortToInt(const int16_t* in, int32_t len, 42 | int32_t* out, int32_t* state); 43 | 44 | void WebRtcSpl_LPBy2IntToInt(const int32_t* in, int32_t len, int32_t* out, 45 | int32_t* state); 46 | 47 | #endif // WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_ 48 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/level_estimator_impl.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 WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_ESTIMATOR_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_ESTIMATOR_IMPL_H_ 13 | 14 | #include "webrtc/modules/audio_processing/include/audio_processing.h" 15 | #include "webrtc/modules/audio_processing/processing_component.h" 16 | #include "webrtc/modules/audio_processing/rms_level.h" 17 | 18 | namespace webrtc { 19 | 20 | class AudioBuffer; 21 | class CriticalSectionWrapper; 22 | 23 | class LevelEstimatorImpl : public LevelEstimator, 24 | public ProcessingComponent { 25 | public: 26 | LevelEstimatorImpl(const AudioProcessing* apm, 27 | CriticalSectionWrapper* crit); 28 | virtual ~LevelEstimatorImpl(); 29 | 30 | int ProcessStream(AudioBuffer* audio); 31 | 32 | // LevelEstimator implementation. 33 | bool is_enabled() const override; 34 | 35 | private: 36 | // LevelEstimator implementation. 37 | int Enable(bool enable) override; 38 | int RMS() override; 39 | 40 | // ProcessingComponent implementation. 41 | void* CreateHandle() const override; 42 | int InitializeHandle(void* handle) const override; 43 | int ConfigureHandle(void* handle) const override; 44 | void DestroyHandle(void* handle) const override; 45 | int num_handles_required() const override; 46 | int GetHandleError(void* handle) const override; 47 | 48 | CriticalSectionWrapper* crit_; 49 | }; 50 | 51 | } // namespace webrtc 52 | 53 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_ESTIMATOR_IMPL_H_ 54 | -------------------------------------------------------------------------------- /webrtc/common_audio/resampler/include/push_resampler.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 WEBRTC_COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_ 12 | #define WEBRTC_COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_ 13 | 14 | #include "webrtc/base/scoped_ptr.h" 15 | #include "webrtc/typedefs.h" 16 | 17 | namespace webrtc { 18 | 19 | class PushSincResampler; 20 | 21 | // Wraps PushSincResampler to provide stereo support. 22 | // TODO(ajm): add support for an arbitrary number of channels. 23 | template 24 | class PushResampler { 25 | public: 26 | PushResampler(); 27 | virtual ~PushResampler(); 28 | 29 | // Must be called whenever the parameters change. Free to be called at any 30 | // time as it is a no-op if parameters have not changed since the last call. 31 | int InitializeIfNeeded(int src_sample_rate_hz, int dst_sample_rate_hz, 32 | int num_channels); 33 | 34 | // Returns the total number of samples provided in destination (e.g. 32 kHz, 35 | // 2 channel audio gives 640 samples). 36 | int Resample(const T* src, size_t src_length, T* dst, size_t dst_capacity); 37 | 38 | private: 39 | rtc::scoped_ptr sinc_resampler_; 40 | rtc::scoped_ptr sinc_resampler_right_; 41 | int src_sample_rate_hz_; 42 | int dst_sample_rate_hz_; 43 | int num_channels_; 44 | rtc::scoped_ptr src_left_; 45 | rtc::scoped_ptr src_right_; 46 | rtc::scoped_ptr dst_left_; 47 | rtc::scoped_ptr dst_right_; 48 | }; 49 | 50 | } // namespace webrtc 51 | 52 | #endif // WEBRTC_COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_ 53 | -------------------------------------------------------------------------------- /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 "webrtc/common_audio/real_fourier.h" 12 | 13 | #include "webrtc/base/checks.h" 14 | #include "webrtc/common_audio/real_fourier_ooura.h" 15 | #include "webrtc/common_audio/real_fourier_openmax.h" 16 | #include "webrtc/common_audio/signal_processing/include/spl_inl.h" 17 | 18 | namespace webrtc { 19 | 20 | using std::complex; 21 | 22 | const int RealFourier::kFftBufferAlignment = 32; 23 | 24 | rtc::scoped_ptr RealFourier::Create(int fft_order) { 25 | #if defined(RTC_USE_OPENMAX_DL) 26 | return rtc::scoped_ptr(new RealFourierOpenmax(fft_order)); 27 | #else 28 | return rtc::scoped_ptr(new RealFourierOoura(fft_order)); 29 | #endif 30 | } 31 | 32 | int RealFourier::FftOrder(size_t length) { 33 | RTC_CHECK_GT(length, 0U); 34 | return WebRtcSpl_GetSizeInBits(static_cast(length - 1)); 35 | } 36 | 37 | size_t RealFourier::FftLength(int order) { 38 | RTC_CHECK_GE(order, 0); 39 | return static_cast(1 << order); 40 | } 41 | 42 | size_t RealFourier::ComplexLength(int order) { 43 | return FftLength(order) / 2 + 1; 44 | } 45 | 46 | RealFourier::fft_real_scoper RealFourier::AllocRealBuffer(int count) { 47 | return fft_real_scoper(static_cast( 48 | AlignedMalloc(sizeof(float) * count, kFftBufferAlignment))); 49 | } 50 | 51 | RealFourier::fft_cplx_scoper RealFourier::AllocCplxBuffer(int count) { 52 | return fft_cplx_scoper(static_cast*>( 53 | AlignedMalloc(sizeof(complex) * count, kFftBufferAlignment))); 54 | } 55 | 56 | } // namespace webrtc 57 | 58 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/aec/echo_cancellation_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 WEBRTC_MODULES_AUDIO_PROCESSING_AEC_ECHO_CANCELLATION_INTERNAL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_ECHO_CANCELLATION_INTERNAL_H_ 13 | 14 | #include "webrtc/common_audio/ring_buffer.h" 15 | #include "webrtc/modules/audio_processing/aec/aec_core.h" 16 | 17 | typedef struct { 18 | int delayCtr; 19 | int sampFreq; 20 | int splitSampFreq; 21 | int scSampFreq; 22 | float sampFactor; // scSampRate / sampFreq 23 | short skewMode; 24 | int bufSizeStart; 25 | int knownDelay; 26 | int rate_factor; 27 | 28 | short initFlag; // indicates if AEC has been initialized 29 | 30 | // Variables used for averaging far end buffer size 31 | short counter; 32 | int sum; 33 | short firstVal; 34 | short checkBufSizeCtr; 35 | 36 | // Variables used for delay shifts 37 | short msInSndCardBuf; 38 | short filtDelay; // Filtered delay estimate. 39 | int timeForDelayChange; 40 | int startup_phase; 41 | int checkBuffSize; 42 | short lastDelayDiff; 43 | 44 | #ifdef WEBRTC_AEC_DEBUG_DUMP 45 | FILE* bufFile; 46 | FILE* delayFile; 47 | FILE* skewFile; 48 | #endif 49 | 50 | // Structures 51 | void* resampler; 52 | 53 | int skewFrCtr; 54 | int resample; // if the skew is small enough we don't resample 55 | int highSkewCtr; 56 | float skew; 57 | 58 | RingBuffer* far_pre_buf; // Time domain far-end pre-buffer. 59 | 60 | int lastError; 61 | 62 | int farend_started; 63 | 64 | AecCore* aec; 65 | } Aec; 66 | 67 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_ECHO_CANCELLATION_INTERNAL_H_ 68 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/condition_variable_native_win.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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_NATIVE_WIN_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_NATIVE_WIN_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/system_wrappers/include/condition_variable_wrapper.h" 17 | 18 | namespace webrtc { 19 | 20 | #if !defined CONDITION_VARIABLE_INIT 21 | typedef struct RTL_CONDITION_VARIABLE_ { 22 | void* Ptr; 23 | } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE; 24 | 25 | typedef RTL_CONDITION_VARIABLE CONDITION_VARIABLE, *PCONDITION_VARIABLE; 26 | #endif 27 | 28 | typedef void (WINAPI* PInitializeConditionVariable)(PCONDITION_VARIABLE); 29 | typedef BOOL (WINAPI* PSleepConditionVariableCS)(PCONDITION_VARIABLE, 30 | PCRITICAL_SECTION, DWORD); 31 | typedef void (WINAPI* PWakeConditionVariable)(PCONDITION_VARIABLE); 32 | typedef void (WINAPI* PWakeAllConditionVariable)(PCONDITION_VARIABLE); 33 | 34 | class ConditionVariableNativeWin : public ConditionVariableWrapper { 35 | public: 36 | static ConditionVariableWrapper* Create(); 37 | virtual ~ConditionVariableNativeWin(); 38 | 39 | void SleepCS(CriticalSectionWrapper& crit_sect); 40 | bool SleepCS(CriticalSectionWrapper& crit_sect, unsigned long max_time_inMS); 41 | void Wake(); 42 | void WakeAll(); 43 | 44 | private: 45 | ConditionVariableNativeWin(); 46 | 47 | bool Init(); 48 | 49 | CONDITION_VARIABLE condition_variable_; 50 | }; 51 | 52 | } // namespace webrtc 53 | 54 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_NATIVE_WIN_H_ 55 | -------------------------------------------------------------------------------- /webrtc/common_audio/vad/vad_filterbank.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 | /* 12 | * This file includes feature calculating functionality used in vad_core.c. 13 | */ 14 | 15 | #ifndef WEBRTC_COMMON_AUDIO_VAD_VAD_FILTERBANK_H_ 16 | #define WEBRTC_COMMON_AUDIO_VAD_VAD_FILTERBANK_H_ 17 | 18 | #include "webrtc/common_audio/vad/vad_core.h" 19 | #include "webrtc/typedefs.h" 20 | 21 | // Takes |data_length| samples of |data_in| and calculates the logarithm of the 22 | // energy of each of the |kNumChannels| = 6 frequency bands used by the VAD: 23 | // 80 Hz - 250 Hz 24 | // 250 Hz - 500 Hz 25 | // 500 Hz - 1000 Hz 26 | // 1000 Hz - 2000 Hz 27 | // 2000 Hz - 3000 Hz 28 | // 3000 Hz - 4000 Hz 29 | // 30 | // The values are given in Q4 and written to |features|. Further, an approximate 31 | // overall energy is returned. The return value is used in 32 | // WebRtcVad_GmmProbability() as a signal indicator, hence it is arbitrary above 33 | // the threshold |kMinEnergy|. 34 | // 35 | // - self [i/o] : State information of the VAD. 36 | // - data_in [i] : Input audio data, for feature extraction. 37 | // - data_length [i] : Audio data size, in number of samples. 38 | // - features [o] : 10 * log10(energy in each frequency band), Q4. 39 | // - returns : Total energy of the signal (NOTE! This value is not 40 | // exact. It is only used in a comparison.) 41 | int16_t WebRtcVad_CalculateFeatures(VadInstT* self, const int16_t* data_in, 42 | size_t data_length, int16_t* features); 43 | 44 | #endif // WEBRTC_COMMON_AUDIO_VAD_VAD_FILTERBANK_H_ 45 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/include/critical_section_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 WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_ 13 | 14 | // If the critical section is heavily contended it may be beneficial to use 15 | // read/write locks instead. 16 | 17 | #include "webrtc/base/thread_annotations.h" 18 | #include "webrtc/common_types.h" 19 | 20 | namespace webrtc { 21 | class LOCKABLE CriticalSectionWrapper { 22 | public: 23 | // Factory method, constructor disabled 24 | static CriticalSectionWrapper* CreateCriticalSection(); 25 | 26 | virtual ~CriticalSectionWrapper() {} 27 | 28 | // Tries to grab lock, beginning of a critical section. Will wait for the 29 | // lock to become available if the grab failed. 30 | virtual void Enter() EXCLUSIVE_LOCK_FUNCTION() = 0; 31 | 32 | // Returns a grabbed lock, end of critical section. 33 | virtual void Leave() UNLOCK_FUNCTION() = 0; 34 | }; 35 | 36 | // RAII extension of the critical section. Prevents Enter/Leave mismatches and 37 | // provides more compact critical section syntax. 38 | class SCOPED_LOCKABLE CriticalSectionScoped { 39 | public: 40 | explicit CriticalSectionScoped(CriticalSectionWrapper* critsec) 41 | EXCLUSIVE_LOCK_FUNCTION(critsec) 42 | : ptr_crit_sec_(critsec) { 43 | ptr_crit_sec_->Enter(); 44 | } 45 | 46 | ~CriticalSectionScoped() UNLOCK_FUNCTION() { ptr_crit_sec_->Leave(); } 47 | 48 | private: 49 | CriticalSectionWrapper* ptr_crit_sec_; 50 | }; 51 | 52 | } // namespace webrtc 53 | 54 | #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CRITICAL_SECTION_WRAPPER_H_ 55 | -------------------------------------------------------------------------------- /webrtc/common_audio/sparse_fir_filter.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_SPARSE_FIR_FILTER_H_ 12 | #define WEBRTC_COMMON_AUDIO_SPARSE_FIR_FILTER_H_ 13 | 14 | #include 15 | #include 16 | 17 | #include "webrtc/base/constructormagic.h" 18 | 19 | namespace webrtc { 20 | 21 | // A Finite Impulse Response filter implementation which takes advantage of a 22 | // sparse structure with uniformly distributed non-zero coefficients. 23 | class SparseFIRFilter final { 24 | public: 25 | // |num_nonzero_coeffs| is the number of non-zero coefficients, 26 | // |nonzero_coeffs|. They are assumed to be uniformly distributed every 27 | // |sparsity| samples and with an initial |offset|. The rest of the filter 28 | // coefficients will be assumed zeros. For example, with sparsity = 3, and 29 | // offset = 1 the filter coefficients will be: 30 | // B = [0 coeffs[0] 0 0 coeffs[1] 0 0 coeffs[2] ... ] 31 | // All initial state values will be zeros. 32 | SparseFIRFilter(const float* nonzero_coeffs, 33 | size_t num_nonzero_coeffs, 34 | size_t sparsity, 35 | size_t offset); 36 | 37 | // Filters the |in| data supplied. 38 | // |out| must be previously allocated and it must be at least of |length|. 39 | void Filter(const float* in, size_t length, float* out); 40 | 41 | private: 42 | const size_t sparsity_; 43 | const size_t offset_; 44 | const std::vector nonzero_coeffs_; 45 | std::vector state_; 46 | 47 | RTC_DISALLOW_COPY_AND_ASSIGN(SparseFIRFilter); 48 | }; 49 | 50 | } // namespace webrtc 51 | 52 | #endif // WEBRTC_COMMON_AUDIO_SPARSE_FIR_FILTER_H_ 53 | -------------------------------------------------------------------------------- /webrtc/common_audio/signal_processing/lpc_to_refl_coef.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_LpcToReflCoef(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | #define SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER 50 21 | 22 | void WebRtcSpl_LpcToReflCoef(int16_t* a16, int use_order, int16_t* k16) 23 | { 24 | int m, k; 25 | int32_t tmp32[SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER]; 26 | int32_t tmp_inv_denom32; 27 | int16_t tmp_inv_denom16; 28 | 29 | k16[use_order - 1] = a16[use_order] << 3; // Q12<<3 => Q15 30 | for (m = use_order - 1; m > 0; m--) 31 | { 32 | // (1 - k^2) in Q30 33 | tmp_inv_denom32 = 1073741823 - k16[m] * k16[m]; 34 | // (1 - k^2) in Q15 35 | tmp_inv_denom16 = (int16_t)(tmp_inv_denom32 >> 15); 36 | 37 | for (k = 1; k <= m; k++) 38 | { 39 | // tmp[k] = (a[k] - RC[m] * a[m-k+1]) / (1.0 - RC[m]*RC[m]); 40 | 41 | // [Q12<<16 - (Q15*Q12)<<1] = [Q28 - Q28] = Q28 42 | tmp32[k] = (a16[k] << 16) - (k16[m] * a16[m - k + 1] << 1); 43 | 44 | tmp32[k] = WebRtcSpl_DivW32W16(tmp32[k], tmp_inv_denom16); //Q28/Q15 = Q13 45 | } 46 | 47 | for (k = 1; k < m; k++) 48 | { 49 | a16[k] = (int16_t)(tmp32[k] >> 1); // Q13>>1 => Q12 50 | } 51 | 52 | tmp32[m] = WEBRTC_SPL_SAT(8191, tmp32[m], -8191); 53 | k16[m - 1] = (int16_t)WEBRTC_SPL_LSHIFT_W32(tmp32[m], 2); //Q13<<2 => Q15 54 | } 55 | return; 56 | } 57 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | Release 0.3 2 | ----------- 3 | 4 | Minor build fixes. 5 | 6 | 7 | Release 0.2 8 | ----------- 9 | 10 | Updated AudioProcessing code to be more current. 11 | 12 | Contains API breaking changes. 13 | 14 | Upstream changes include: 15 | 16 | * Rewritten AGC and voice activity detection 17 | * Intelligibility enhancer 18 | * Extended AEC filter 19 | * Beamformer 20 | * Transient suppressor 21 | * ARM, NEON and MIPS optimisations (MIPS optimisations are not hooked up) 22 | 23 | API changes: 24 | 25 | * We no longer include a top-level audio_processing.h. The webrtc tree format 26 | is used, so use webrtc/modules/audio_processing/include/audio_processing.h 27 | * The top-level module_common_types.h has also been moved to 28 | webrtc/modules/interface/module_common_types.h 29 | * C++11 support is now required while compiling client code 30 | * AudioProcessing::Create() does not take any arguments any more 31 | * AudioProcessing::Destroy() is gone, use standard C++ "delete" instead 32 | * Stream parameters are now configured via StreamConfig and ProcessingConfig 33 | rather than set_sample_rate(), set_num_channels(), etc. 34 | * AudioFrame field names have changed 35 | * Use config API for newer audio processing options 36 | * Use ProcessReverseStream() instead of AnalyzeReverseStream(), particularly 37 | when using the intelligibility enhancer 38 | * GainControl::set_analog_level_limits() is broken. The AGC implementation 39 | hard codes 0-255 as the volume range 40 | 41 | Other notes: 42 | 43 | * The new audio processing parameters are not all tested, and a few are not 44 | enabled upstream (in Chromium) either 45 | * The rewritten AGC appears to be less sensitive, and it might make sense to 46 | initialise the capture volume to something reasonable (33% or 50%, for 47 | example) to make sure there is sufficient energy in the stream to trigger 48 | the AGC mechanism 49 | 50 | 51 | Release 0.1 52 | ----------- 53 | 54 | Initial release, consisting of the WebRTC AudioProcessing module with a 55 | distributor-friendly build system. 56 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/beamformer/beamformer.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_PROCESSING_BEAMFORMER_BEAMFORMER_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_BEAMFORMER_H_ 13 | 14 | #include "webrtc/common_audio/channel_buffer.h" 15 | #include "webrtc/modules/audio_processing/beamformer/array_util.h" 16 | 17 | namespace webrtc { 18 | 19 | template 20 | class Beamformer { 21 | public: 22 | virtual ~Beamformer() {} 23 | 24 | // Process one time-domain chunk of audio. The audio is expected to be split 25 | // into frequency bands inside the ChannelBuffer. The number of frames and 26 | // channels must correspond to the constructor parameters. The same 27 | // ChannelBuffer can be passed in as |input| and |output|. 28 | virtual void ProcessChunk(const ChannelBuffer& input, 29 | ChannelBuffer* output) = 0; 30 | 31 | // Sample rate corresponds to the lower band. 32 | // Needs to be called before the the Beamformer can be used. 33 | virtual void Initialize(int chunk_size_ms, int sample_rate_hz) = 0; 34 | 35 | // Aim the beamformer at a point in space. 36 | virtual void AimAt(const SphericalPointf& spherical_point) = 0; 37 | 38 | // Indicates whether a given point is inside of the beam. 39 | virtual bool IsInBeam(const SphericalPointf& spherical_point) { return true; } 40 | 41 | // Returns true if the current data contains the target signal. 42 | // Which signals are considered "targets" is implementation dependent. 43 | virtual bool is_target_present() = 0; 44 | }; 45 | 46 | } // namespace webrtc 47 | 48 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_BEAMFORMER_H_ 49 | -------------------------------------------------------------------------------- /webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.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 | // Modified from the Chromium original here: 12 | // src/media/base/sinc_resampler_unittest.cc 13 | 14 | #ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_SINUSOIDAL_LINEAR_CHIRP_SOURCE_H_ 15 | #define WEBRTC_COMMON_AUDIO_RESAMPLER_SINUSOIDAL_LINEAR_CHIRP_SOURCE_H_ 16 | 17 | #include "webrtc/base/constructormagic.h" 18 | #include "webrtc/common_audio/resampler/sinc_resampler.h" 19 | 20 | namespace webrtc { 21 | 22 | // Fake audio source for testing the resampler. Generates a sinusoidal linear 23 | // chirp (http://en.wikipedia.org/wiki/Chirp) which can be tuned to stress the 24 | // resampler for the specific sample rate conversion being used. 25 | class SinusoidalLinearChirpSource : public SincResamplerCallback { 26 | public: 27 | // |delay_samples| can be used to insert a fractional sample delay into the 28 | // source. It will produce zeros until non-negative time is reached. 29 | SinusoidalLinearChirpSource(int sample_rate, size_t samples, 30 | double max_frequency, double delay_samples); 31 | 32 | virtual ~SinusoidalLinearChirpSource() {} 33 | 34 | void Run(size_t frames, float* destination) override; 35 | 36 | double Frequency(size_t position); 37 | 38 | private: 39 | enum { 40 | kMinFrequency = 5 41 | }; 42 | 43 | int sample_rate_; 44 | size_t total_samples_; 45 | double max_frequency_; 46 | double k_; 47 | size_t current_index_; 48 | double delay_samples_; 49 | 50 | RTC_DISALLOW_COPY_AND_ASSIGN(SinusoidalLinearChirpSource); 51 | }; 52 | 53 | } // namespace webrtc 54 | 55 | #endif // WEBRTC_COMMON_AUDIO_RESAMPLER_SINUSOIDAL_LINEAR_CHIRP_SOURCE_H_ 56 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/ns/noise_suppression.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 "webrtc/modules/audio_processing/ns/include/noise_suppression.h" 12 | 13 | #include 14 | #include 15 | 16 | #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 17 | #include "webrtc/modules/audio_processing/ns/defines.h" 18 | #include "webrtc/modules/audio_processing/ns/ns_core.h" 19 | 20 | NsHandle* WebRtcNs_Create() { 21 | NoiseSuppressionC* self = malloc(sizeof(NoiseSuppressionC)); 22 | self->initFlag = 0; 23 | return (NsHandle*)self; 24 | } 25 | 26 | void WebRtcNs_Free(NsHandle* NS_inst) { 27 | free(NS_inst); 28 | } 29 | 30 | int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs) { 31 | return WebRtcNs_InitCore((NoiseSuppressionC*)NS_inst, fs); 32 | } 33 | 34 | int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) { 35 | return WebRtcNs_set_policy_core((NoiseSuppressionC*)NS_inst, mode); 36 | } 37 | 38 | void WebRtcNs_Analyze(NsHandle* NS_inst, const float* spframe) { 39 | WebRtcNs_AnalyzeCore((NoiseSuppressionC*)NS_inst, spframe); 40 | } 41 | 42 | void WebRtcNs_Process(NsHandle* NS_inst, 43 | const float* const* spframe, 44 | size_t num_bands, 45 | float* const* outframe) { 46 | WebRtcNs_ProcessCore((NoiseSuppressionC*)NS_inst, spframe, num_bands, 47 | outframe); 48 | } 49 | 50 | float WebRtcNs_prior_speech_probability(NsHandle* handle) { 51 | NoiseSuppressionC* self = (NoiseSuppressionC*)handle; 52 | if (handle == NULL) { 53 | return -1; 54 | } 55 | if (self->initFlag == 0) { 56 | return -1; 57 | } 58 | return self->priorSpeechProb; 59 | } 60 | -------------------------------------------------------------------------------- /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 WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_H_ 13 | 14 | #include "webrtc/base/scoped_ptr.h" 15 | #include "webrtc/modules/audio_processing/vad/voice_activity_detector.h" 16 | #include "webrtc/typedefs.h" 17 | 18 | namespace webrtc { 19 | 20 | class AudioFrame; 21 | class Histogram; 22 | 23 | class Agc { 24 | public: 25 | Agc(); 26 | virtual ~Agc(); 27 | 28 | // Returns the proportion of samples in the buffer which are at full-scale 29 | // (and presumably clipped). 30 | virtual float AnalyzePreproc(const int16_t* audio, size_t length); 31 | // |audio| must be mono; in a multi-channel stream, provide the first (usually 32 | // left) channel. 33 | virtual int Process(const int16_t* audio, size_t length, int sample_rate_hz); 34 | 35 | // Retrieves the difference between the target RMS level and the current 36 | // signal RMS level in dB. Returns true if an update is available and false 37 | // otherwise, in which case |error| should be ignored and no action taken. 38 | virtual bool GetRmsErrorDb(int* error); 39 | virtual void Reset(); 40 | 41 | virtual int set_target_level_dbfs(int level); 42 | virtual int target_level_dbfs() const { return target_level_dbfs_; } 43 | 44 | virtual float voice_probability() const { 45 | return vad_.last_voice_probability(); 46 | } 47 | 48 | private: 49 | double target_level_loudness_; 50 | int target_level_dbfs_; 51 | rtc::scoped_ptr histogram_; 52 | rtc::scoped_ptr inactive_histogram_; 53 | VoiceActivityDetector vad_; 54 | }; 55 | 56 | } // namespace webrtc 57 | 58 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_H_ 59 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/noise_suppression_impl.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 WEBRTC_MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_ 13 | 14 | #include "webrtc/modules/audio_processing/include/audio_processing.h" 15 | #include "webrtc/modules/audio_processing/processing_component.h" 16 | 17 | namespace webrtc { 18 | 19 | class AudioBuffer; 20 | class CriticalSectionWrapper; 21 | 22 | class NoiseSuppressionImpl : public NoiseSuppression, 23 | public ProcessingComponent { 24 | public: 25 | NoiseSuppressionImpl(const AudioProcessing* apm, 26 | CriticalSectionWrapper* crit); 27 | virtual ~NoiseSuppressionImpl(); 28 | 29 | int AnalyzeCaptureAudio(AudioBuffer* audio); 30 | int ProcessCaptureAudio(AudioBuffer* audio); 31 | 32 | // NoiseSuppression implementation. 33 | bool is_enabled() const override; 34 | float speech_probability() const override; 35 | Level level() const override; 36 | 37 | private: 38 | // NoiseSuppression implementation. 39 | int Enable(bool enable) override; 40 | int set_level(Level level) override; 41 | 42 | // ProcessingComponent implementation. 43 | void* CreateHandle() const override; 44 | int InitializeHandle(void* handle) const override; 45 | int ConfigureHandle(void* handle) const override; 46 | void DestroyHandle(void* handle) const override; 47 | int num_handles_required() const override; 48 | int GetHandleError(void* handle) const override; 49 | 50 | const AudioProcessing* apm_; 51 | CriticalSectionWrapper* crit_; 52 | Level level_; 53 | }; 54 | 55 | } // namespace webrtc 56 | 57 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_ 58 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/transient/moving_moments.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 WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/base/scoped_ptr.h" 17 | 18 | namespace webrtc { 19 | 20 | // Calculates the first and second moments for each value of a buffer taking 21 | // into account a given number of previous values. 22 | // It preserves its state, so it can be multiple-called. 23 | // TODO(chadan): Implement a function that takes a buffer of first moments and a 24 | // buffer of second moments; and calculates the variances. When needed. 25 | // TODO(chadan): Add functionality to update with a buffer but only output are 26 | // the last values of the moments. When needed. 27 | class MovingMoments { 28 | public: 29 | // Creates a Moving Moments object, that uses the last |length| values 30 | // (including the new value introduced in every new calculation). 31 | explicit MovingMoments(size_t length); 32 | ~MovingMoments(); 33 | 34 | // Calculates the new values using |in|. Results will be in the out buffers. 35 | // |first| and |second| must be allocated with at least |in_length|. 36 | void CalculateMoments(const float* in, size_t in_length, 37 | float* first, float* second); 38 | 39 | private: 40 | size_t length_; 41 | // A queue holding the |length_| latest input values. 42 | std::queue queue_; 43 | // Sum of the values of the queue. 44 | float sum_; 45 | // Sum of the squares of the values of the queue. 46 | float sum_of_squares_; 47 | }; 48 | 49 | } // namespace webrtc 50 | 51 | 52 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_ 53 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/rms_level.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 WEBRTC_MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/typedefs.h" 17 | 18 | namespace webrtc { 19 | 20 | // Computes the root mean square (RMS) level in dBFs (decibels from digital 21 | // full-scale) of audio data. The computation follows RFC 6465: 22 | // https://tools.ietf.org/html/rfc6465 23 | // with the intent that it can provide the RTP audio level indication. 24 | // 25 | // The expected approach is to provide constant-sized chunks of audio to 26 | // Process(). When enough chunks have been accumulated to form a packet, call 27 | // RMS() to get the audio level indicator for the RTP header. 28 | class RMSLevel { 29 | public: 30 | static const int kMinLevel = 127; 31 | 32 | RMSLevel(); 33 | ~RMSLevel(); 34 | 35 | // Can be called to reset internal states, but is not required during normal 36 | // operation. 37 | void Reset(); 38 | 39 | // Pass each chunk of audio to Process() to accumulate the level. 40 | void Process(const int16_t* data, size_t length); 41 | 42 | // If all samples with the given |length| have a magnitude of zero, this is 43 | // a shortcut to avoid some computation. 44 | void ProcessMuted(size_t length); 45 | 46 | // Computes the RMS level over all data passed to Process() since the last 47 | // call to RMS(). The returned value is positive but should be interpreted as 48 | // negative as per the RFC. It is constrained to [0, 127]. 49 | int RMS(); 50 | 51 | private: 52 | float sum_square_; 53 | size_t sample_count_; 54 | }; 55 | 56 | } // namespace webrtc 57 | 58 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_ 59 | 60 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/logging.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 "webrtc/system_wrappers/include/logging.h" 12 | 13 | #include 14 | 15 | #include 16 | 17 | #include "webrtc/common_types.h" 18 | #include "webrtc/system_wrappers/include/trace.h" 19 | 20 | namespace webrtc { 21 | namespace { 22 | 23 | TraceLevel WebRtcSeverity(LoggingSeverity sev) { 24 | switch (sev) { 25 | // TODO(ajm): SENSITIVE doesn't have a corresponding webrtc level. 26 | case LS_SENSITIVE: return kTraceInfo; 27 | case LS_VERBOSE: return kTraceInfo; 28 | case LS_INFO: return kTraceTerseInfo; 29 | case LS_WARNING: return kTraceWarning; 30 | case LS_ERROR: return kTraceError; 31 | default: return kTraceNone; 32 | } 33 | } 34 | 35 | // Return the filename portion of the string (that following the last slash). 36 | const char* FilenameFromPath(const char* file) { 37 | const char* end1 = ::strrchr(file, '/'); 38 | const char* end2 = ::strrchr(file, '\\'); 39 | if (!end1 && !end2) 40 | return file; 41 | else 42 | return (end1 > end2) ? end1 + 1 : end2 + 1; 43 | } 44 | 45 | } // namespace 46 | 47 | LogMessage::LogMessage(const char* file, int line, LoggingSeverity sev) 48 | : severity_(sev) { 49 | print_stream_ << "(" << FilenameFromPath(file) << ":" << line << "): "; 50 | } 51 | 52 | bool LogMessage::Loggable(LoggingSeverity sev) { 53 | // |level_filter| is a bitmask, unlike libjingle's minimum severity value. 54 | return WebRtcSeverity(sev) & Trace::level_filter() ? true : false; 55 | } 56 | 57 | LogMessage::~LogMessage() { 58 | const std::string& str = print_stream_.str(); 59 | Trace::Add(WebRtcSeverity(severity_), kTraceUndefined, 0, "%s", str.c_str()); 60 | } 61 | 62 | } // namespace webrtc 63 | -------------------------------------------------------------------------------- /webrtc/modules/audio_coding/codecs/isac/main/source/arith_routines.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 | #include "arith_routines.h" 12 | #include "settings.h" 13 | 14 | 15 | /* 16 | * terminate and return byte stream; 17 | * returns the number of bytes in the stream 18 | */ 19 | int WebRtcIsac_EncTerminate(Bitstr *streamdata) /* in-/output struct containing bitstream */ 20 | { 21 | uint8_t *stream_ptr; 22 | 23 | 24 | /* point to the right place in the stream buffer */ 25 | stream_ptr = streamdata->stream + streamdata->stream_index; 26 | 27 | /* find minimum length (determined by current interval width) */ 28 | if ( streamdata->W_upper > 0x01FFFFFF ) 29 | { 30 | streamdata->streamval += 0x01000000; 31 | /* add carry to buffer */ 32 | if (streamdata->streamval < 0x01000000) 33 | { 34 | /* propagate carry */ 35 | while ( !(++(*--stream_ptr)) ); 36 | /* put pointer back to the old value */ 37 | stream_ptr = streamdata->stream + streamdata->stream_index; 38 | } 39 | /* write remaining data to bitstream */ 40 | *stream_ptr++ = (uint8_t) (streamdata->streamval >> 24); 41 | } 42 | else 43 | { 44 | streamdata->streamval += 0x00010000; 45 | /* add carry to buffer */ 46 | if (streamdata->streamval < 0x00010000) 47 | { 48 | /* propagate carry */ 49 | while ( !(++(*--stream_ptr)) ); 50 | /* put pointer back to the old value */ 51 | stream_ptr = streamdata->stream + streamdata->stream_index; 52 | } 53 | /* write remaining data to bitstream */ 54 | *stream_ptr++ = (uint8_t) (streamdata->streamval >> 24); 55 | *stream_ptr++ = (uint8_t) ((streamdata->streamval >> 16) & 0x00FF); 56 | } 57 | 58 | /* calculate stream length */ 59 | return (int)(stream_ptr - streamdata->stream); 60 | } 61 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/file_impl.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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_FILE_IMPL_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_FILE_IMPL_H_ 13 | 14 | #include 15 | 16 | #include "webrtc/base/scoped_ptr.h" 17 | #include "webrtc/system_wrappers/include/file_wrapper.h" 18 | 19 | namespace webrtc { 20 | 21 | class RWLockWrapper; 22 | 23 | class FileWrapperImpl : public FileWrapper { 24 | public: 25 | FileWrapperImpl(); 26 | ~FileWrapperImpl() override; 27 | 28 | int FileName(char* file_name_utf8, size_t size) const override; 29 | 30 | bool Open() const override; 31 | 32 | int OpenFile(const char* file_name_utf8, 33 | bool read_only, 34 | bool loop = false, 35 | bool text = false) override; 36 | 37 | int OpenFromFileHandle(FILE* handle, 38 | bool manage_file, 39 | bool read_only, 40 | bool loop = false) override; 41 | 42 | int CloseFile() override; 43 | int SetMaxFileSize(size_t bytes) override; 44 | int Flush() override; 45 | 46 | int Read(void* buf, size_t length) override; 47 | bool Write(const void* buf, size_t length) override; 48 | int WriteText(const char* format, ...) override; 49 | int Rewind() override; 50 | 51 | private: 52 | int CloseFileImpl(); 53 | int FlushImpl(); 54 | 55 | rtc::scoped_ptr rw_lock_; 56 | 57 | FILE* id_; 58 | bool managed_file_handle_; 59 | bool open_; 60 | bool looping_; 61 | bool read_only_; 62 | size_t max_size_in_bytes_; // -1 indicates file size limitation is off 63 | size_t size_in_bytes_; 64 | char file_name_utf8_[kMaxFileNameSize]; 65 | }; 66 | 67 | } // namespace webrtc 68 | 69 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_FILE_IMPL_H_ 70 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/logging/aec_logging_file_handling.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 "webrtc/modules/audio_processing/logging/aec_logging_file_handling.h" 12 | 13 | #include 14 | #include 15 | 16 | #include "webrtc/base/checks.h" 17 | #include "webrtc/base/stringutils.h" 18 | #include "webrtc/common_audio/wav_file.h" 19 | #include "webrtc/typedefs.h" 20 | 21 | #ifdef WEBRTC_AEC_DEBUG_DUMP 22 | void WebRtcAec_ReopenWav(const char* name, 23 | int instance_index, 24 | int process_rate, 25 | int sample_rate, 26 | rtc_WavWriter** wav_file) { 27 | if (*wav_file) { 28 | if (rtc_WavSampleRate(*wav_file) == sample_rate) 29 | return; 30 | rtc_WavClose(*wav_file); 31 | } 32 | char filename[64]; 33 | int written = rtc::sprintfn(filename, sizeof(filename), "%s%d-%d.wav", name, 34 | instance_index, process_rate); 35 | 36 | // Ensure there was no buffer output error. 37 | RTC_DCHECK_GE(written, 0); 38 | // Ensure that the buffer size was sufficient. 39 | RTC_DCHECK_LT(static_cast(written), sizeof(filename)); 40 | 41 | *wav_file = rtc_WavOpen(filename, sample_rate, 1); 42 | } 43 | 44 | void WebRtcAec_RawFileOpen(const char* name, int instance_index, FILE** file) { 45 | char filename[64]; 46 | int written = rtc::sprintfn(filename, sizeof(filename), "%s_%d.dat", name, 47 | instance_index); 48 | 49 | // Ensure there was no buffer output error. 50 | RTC_DCHECK_GE(written, 0); 51 | // Ensure that the buffer size was sufficient. 52 | RTC_DCHECK_LT(static_cast(written), sizeof(filename)); 53 | 54 | *file = fopen(filename, "wb"); 55 | } 56 | 57 | #endif // WEBRTC_AEC_DEBUG_DUMP 58 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/vad/gmm.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 "webrtc/modules/audio_processing/vad/gmm.h" 12 | 13 | #include 14 | #include 15 | 16 | #include "webrtc/typedefs.h" 17 | 18 | namespace webrtc { 19 | 20 | static const int kMaxDimension = 10; 21 | 22 | static void RemoveMean(const double* in, 23 | const double* mean_vec, 24 | int dimension, 25 | double* out) { 26 | for (int n = 0; n < dimension; ++n) 27 | out[n] = in[n] - mean_vec[n]; 28 | } 29 | 30 | static double ComputeExponent(const double* in, 31 | const double* covar_inv, 32 | int dimension) { 33 | double q = 0; 34 | for (int i = 0; i < dimension; ++i) { 35 | double v = 0; 36 | for (int j = 0; j < dimension; j++) 37 | v += (*covar_inv++) * in[j]; 38 | q += v * in[i]; 39 | } 40 | q *= -0.5; 41 | return q; 42 | } 43 | 44 | double EvaluateGmm(const double* x, const GmmParameters& gmm_parameters) { 45 | if (gmm_parameters.dimension > kMaxDimension) { 46 | return -1; // This is invalid pdf so the caller can check this. 47 | } 48 | double f = 0; 49 | double v[kMaxDimension]; 50 | const double* mean_vec = gmm_parameters.mean; 51 | const double* covar_inv = gmm_parameters.covar_inverse; 52 | 53 | for (int n = 0; n < gmm_parameters.num_mixtures; n++) { 54 | RemoveMean(x, mean_vec, gmm_parameters.dimension, v); 55 | double q = ComputeExponent(v, covar_inv, gmm_parameters.dimension) + 56 | gmm_parameters.weight[n]; 57 | f += exp(q); 58 | mean_vec += gmm_parameters.dimension; 59 | covar_inv += gmm_parameters.dimension * gmm_parameters.dimension; 60 | } 61 | return f; 62 | } 63 | 64 | } // namespace webrtc 65 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/vad/pitch_based_vad.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 WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_ 13 | 14 | #include "webrtc/base/scoped_ptr.h" 15 | #include "webrtc/modules/audio_processing/vad/common.h" 16 | #include "webrtc/modules/audio_processing/vad/gmm.h" 17 | #include "webrtc/typedefs.h" 18 | 19 | namespace webrtc { 20 | 21 | class AudioFrame; 22 | class VadCircularBuffer; 23 | 24 | // Computes the probability of the input audio frame to be active given 25 | // the corresponding pitch-gain and lag of the frame. 26 | class PitchBasedVad { 27 | public: 28 | PitchBasedVad(); 29 | ~PitchBasedVad(); 30 | 31 | // Compute pitch-based voicing probability, given the features. 32 | // features: a structure containing features required for computing voicing 33 | // probabilities. 34 | // 35 | // p_combined: an array which contains the combined activity probabilities 36 | // computed prior to the call of this function. The method, 37 | // then, computes the voicing probabilities and combine them 38 | // with the given values. The result are returned in |p|. 39 | int VoicingProbability(const AudioFeatures& features, double* p_combined); 40 | 41 | private: 42 | int UpdatePrior(double p); 43 | 44 | // TODO(turajs): maybe defining this at a higher level (maybe enum) so that 45 | // all the code recognize it as "no-error." 46 | static const int kNoError = 0; 47 | 48 | GmmParameters noise_gmm_; 49 | GmmParameters voice_gmm_; 50 | 51 | double p_prior_; 52 | 53 | rtc::scoped_ptr circular_buffer_; 54 | }; 55 | 56 | } // namespace webrtc 57 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_ 58 | -------------------------------------------------------------------------------- /webrtc/common_audio/window_generator.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 | #define _USE_MATH_DEFINES 12 | 13 | #include "webrtc/common_audio/window_generator.h" 14 | 15 | #include 16 | #include 17 | 18 | #include "webrtc/base/checks.h" 19 | 20 | using std::complex; 21 | 22 | namespace { 23 | 24 | // Modified Bessel function of order 0 for complex inputs. 25 | complex I0(complex x) { 26 | complex y = x / 3.75f; 27 | y *= y; 28 | return 1.0f + y * ( 29 | 3.5156229f + y * ( 30 | 3.0899424f + y * ( 31 | 1.2067492f + y * ( 32 | 0.2659732f + y * ( 33 | 0.360768e-1f + y * 0.45813e-2f))))); 34 | } 35 | 36 | } // namespace 37 | 38 | namespace webrtc { 39 | 40 | void WindowGenerator::Hanning(int length, float* window) { 41 | RTC_CHECK_GT(length, 1); 42 | RTC_CHECK(window != nullptr); 43 | for (int i = 0; i < length; ++i) { 44 | window[i] = 0.5f * (1 - cosf(2 * static_cast(M_PI) * i / 45 | (length - 1))); 46 | } 47 | } 48 | 49 | void WindowGenerator::KaiserBesselDerived(float alpha, size_t length, 50 | float* window) { 51 | RTC_CHECK_GT(length, 1U); 52 | RTC_CHECK(window != nullptr); 53 | 54 | const size_t half = (length + 1) / 2; 55 | float sum = 0.0f; 56 | 57 | for (size_t i = 0; i <= half; ++i) { 58 | complex r = (4.0f * i) / length - 1.0f; 59 | sum += I0(static_cast(M_PI) * alpha * sqrt(1.0f - r * r)).real(); 60 | window[i] = sum; 61 | } 62 | for (size_t i = length - 1; i >= half; --i) { 63 | window[length - i - 1] = sqrtf(window[length - i - 1] / sum); 64 | window[i] = window[length - i - 1]; 65 | } 66 | if (length % 2 == 1) { 67 | window[half - 1] = sqrtf(window[half - 1] / sum); 68 | } 69 | } 70 | 71 | } // namespace webrtc 72 | 73 | -------------------------------------------------------------------------------- /webrtc/common_audio/audio_ring_buffer.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 | #ifndef WEBRTC_COMMON_AUDIO_AUDIO_RING_BUFFER_H_ 11 | #define WEBRTC_COMMON_AUDIO_AUDIO_RING_BUFFER_H_ 12 | 13 | #include 14 | #include 15 | 16 | struct RingBuffer; 17 | 18 | namespace webrtc { 19 | 20 | // A ring buffer tailored for float deinterleaved audio. Any operation that 21 | // cannot be performed as requested will cause a crash (e.g. insufficient data 22 | // in the buffer to fulfill a read request.) 23 | class AudioRingBuffer final { 24 | public: 25 | // Specify the number of channels and maximum number of frames the buffer will 26 | // contain. 27 | AudioRingBuffer(size_t channels, size_t max_frames); 28 | ~AudioRingBuffer(); 29 | 30 | // Copies |data| to the buffer and advances the write pointer. |channels| must 31 | // be the same as at creation time. 32 | void Write(const float* const* data, size_t channels, size_t frames); 33 | 34 | // Copies from the buffer to |data| and advances the read pointer. |channels| 35 | // must be the same as at creation time. 36 | void Read(float* const* data, size_t channels, size_t frames); 37 | 38 | size_t ReadFramesAvailable() const; 39 | size_t WriteFramesAvailable() const; 40 | 41 | // Moves the read position. The forward version advances the read pointer 42 | // towards the write pointer and the backward verison withdraws the read 43 | // pointer away from the write pointer (i.e. flushing and stuffing the buffer 44 | // respectively.) 45 | void MoveReadPositionForward(size_t frames); 46 | void MoveReadPositionBackward(size_t frames); 47 | 48 | private: 49 | // We don't use a ScopedVector because it doesn't support a specialized 50 | // deleter (like scoped_ptr for instance.) 51 | std::vector buffers_; 52 | }; 53 | 54 | } // namespace webrtc 55 | 56 | #endif // WEBRTC_COMMON_AUDIO_AUDIO_RING_BUFFER_H_ 57 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/cpu_features.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 | // Parts of this file derived from Chromium's base/cpu.cc. 12 | 13 | #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" 14 | 15 | #if defined(WEBRTC_ARCH_X86_FAMILY) && defined(_MSC_VER) 16 | #include 17 | #endif 18 | 19 | #include "webrtc/typedefs.h" 20 | 21 | // No CPU feature is available => straight C path. 22 | int GetCPUInfoNoASM(CPUFeature feature) { 23 | (void)feature; 24 | return 0; 25 | } 26 | 27 | #if defined(WEBRTC_ARCH_X86_FAMILY) 28 | #ifndef _MSC_VER 29 | // Intrinsic for "cpuid". 30 | #if defined(__pic__) && defined(__i386__) 31 | static inline void __cpuid(int cpu_info[4], int info_type) { 32 | __asm__ volatile( 33 | "mov %%ebx, %%edi\n" 34 | "cpuid\n" 35 | "xchg %%edi, %%ebx\n" 36 | : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) 37 | : "a"(info_type)); 38 | } 39 | #else 40 | static inline void __cpuid(int cpu_info[4], int info_type) { 41 | __asm__ volatile( 42 | "cpuid\n" 43 | : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) 44 | : "a"(info_type)); 45 | } 46 | #endif 47 | #endif // _MSC_VER 48 | #endif // WEBRTC_ARCH_X86_FAMILY 49 | 50 | #if defined(WEBRTC_ARCH_X86_FAMILY) 51 | // Actual feature detection for x86. 52 | static int GetCPUInfo(CPUFeature feature) { 53 | int cpu_info[4]; 54 | __cpuid(cpu_info, 1); 55 | if (feature == kSSE2) { 56 | return 0 != (cpu_info[3] & 0x04000000); 57 | } 58 | if (feature == kSSE3) { 59 | return 0 != (cpu_info[2] & 0x00000001); 60 | } 61 | return 0; 62 | } 63 | #else 64 | // Default to straight C for other platforms. 65 | static int GetCPUInfo(CPUFeature feature) { 66 | (void)feature; 67 | return 0; 68 | } 69 | #endif 70 | 71 | WebRtc_CPUInfo WebRtc_GetCPUInfo = GetCPUInfo; 72 | WebRtc_CPUInfo WebRtc_GetCPUInfoNoASM = GetCPUInfoNoASM; 73 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/include/rw_lock_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 WEBRTC_SYSTEM_WRAPPERS_INCLUDE_RW_LOCK_WRAPPER_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_RW_LOCK_WRAPPER_H_ 13 | 14 | #include "webrtc/base/thread_annotations.h" 15 | 16 | // Note, Windows pre-Vista version of RW locks are not supported natively. For 17 | // these OSs regular critical sections have been used to approximate RW lock 18 | // functionality and will therefore have worse performance. 19 | 20 | namespace webrtc { 21 | 22 | class LOCKABLE RWLockWrapper { 23 | public: 24 | static RWLockWrapper* CreateRWLock(); 25 | virtual ~RWLockWrapper() {} 26 | 27 | virtual void AcquireLockExclusive() EXCLUSIVE_LOCK_FUNCTION() = 0; 28 | virtual void ReleaseLockExclusive() UNLOCK_FUNCTION() = 0; 29 | 30 | virtual void AcquireLockShared() SHARED_LOCK_FUNCTION() = 0; 31 | virtual void ReleaseLockShared() UNLOCK_FUNCTION() = 0; 32 | }; 33 | 34 | // RAII extensions of the RW lock. Prevents Acquire/Release missmatches and 35 | // provides more compact locking syntax. 36 | class SCOPED_LOCKABLE ReadLockScoped { 37 | public: 38 | ReadLockScoped(RWLockWrapper& rw_lock) SHARED_LOCK_FUNCTION(rw_lock) 39 | : rw_lock_(rw_lock) { 40 | rw_lock_.AcquireLockShared(); 41 | } 42 | 43 | ~ReadLockScoped() UNLOCK_FUNCTION() { 44 | rw_lock_.ReleaseLockShared(); 45 | } 46 | 47 | private: 48 | RWLockWrapper& rw_lock_; 49 | }; 50 | 51 | class SCOPED_LOCKABLE WriteLockScoped { 52 | public: 53 | WriteLockScoped(RWLockWrapper& rw_lock) EXCLUSIVE_LOCK_FUNCTION(rw_lock) 54 | : rw_lock_(rw_lock) { 55 | rw_lock_.AcquireLockExclusive(); 56 | } 57 | 58 | ~WriteLockScoped() UNLOCK_FUNCTION() { 59 | rw_lock_.ReleaseLockExclusive(); 60 | } 61 | 62 | private: 63 | RWLockWrapper& rw_lock_; 64 | }; 65 | 66 | } // namespace webrtc 67 | 68 | #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_RW_LOCK_WRAPPER_H_ 69 | -------------------------------------------------------------------------------- /webrtc/common_audio/channel_buffer.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 "webrtc/common_audio/channel_buffer.h" 12 | 13 | namespace webrtc { 14 | 15 | IFChannelBuffer::IFChannelBuffer(size_t num_frames, 16 | int num_channels, 17 | size_t num_bands) 18 | : ivalid_(true), 19 | ibuf_(num_frames, num_channels, num_bands), 20 | fvalid_(true), 21 | fbuf_(num_frames, num_channels, num_bands) {} 22 | 23 | ChannelBuffer* IFChannelBuffer::ibuf() { 24 | RefreshI(); 25 | fvalid_ = false; 26 | return &ibuf_; 27 | } 28 | 29 | ChannelBuffer* IFChannelBuffer::fbuf() { 30 | RefreshF(); 31 | ivalid_ = false; 32 | return &fbuf_; 33 | } 34 | 35 | const ChannelBuffer* IFChannelBuffer::ibuf_const() const { 36 | RefreshI(); 37 | return &ibuf_; 38 | } 39 | 40 | const ChannelBuffer* IFChannelBuffer::fbuf_const() const { 41 | RefreshF(); 42 | return &fbuf_; 43 | } 44 | 45 | void IFChannelBuffer::RefreshF() const { 46 | if (!fvalid_) { 47 | assert(ivalid_); 48 | const int16_t* const* int_channels = ibuf_.channels(); 49 | float* const* float_channels = fbuf_.channels(); 50 | for (int i = 0; i < ibuf_.num_channels(); ++i) { 51 | for (size_t j = 0; j < ibuf_.num_frames(); ++j) { 52 | float_channels[i][j] = int_channels[i][j]; 53 | } 54 | } 55 | fvalid_ = true; 56 | } 57 | } 58 | 59 | void IFChannelBuffer::RefreshI() const { 60 | if (!ivalid_) { 61 | assert(fvalid_); 62 | int16_t* const* int_channels = ibuf_.channels(); 63 | const float* const* float_channels = fbuf_.channels(); 64 | for (int i = 0; i < ibuf_.num_channels(); ++i) { 65 | FloatS16ToS16(float_channels[i], 66 | ibuf_.num_frames(), 67 | int_channels[i]); 68 | } 69 | ivalid_ = true; 70 | } 71 | } 72 | 73 | } // namespace webrtc 74 | -------------------------------------------------------------------------------- /webrtc/common_audio/vad/vad_sp.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 | // This file includes specific signal processing tools used in vad_core.c. 13 | 14 | #ifndef WEBRTC_COMMON_AUDIO_VAD_VAD_SP_H_ 15 | #define WEBRTC_COMMON_AUDIO_VAD_VAD_SP_H_ 16 | 17 | #include "webrtc/common_audio/vad/vad_core.h" 18 | #include "webrtc/typedefs.h" 19 | 20 | // Downsamples the signal by a factor 2, eg. 32->16 or 16->8. 21 | // 22 | // Inputs: 23 | // - signal_in : Input signal. 24 | // - in_length : Length of input signal in samples. 25 | // 26 | // Input & Output: 27 | // - filter_state : Current filter states of the two all-pass filters. The 28 | // |filter_state| is updated after all samples have been 29 | // processed. 30 | // 31 | // Output: 32 | // - signal_out : Downsampled signal (of length |in_length| / 2). 33 | void WebRtcVad_Downsampling(const int16_t* signal_in, 34 | int16_t* signal_out, 35 | int32_t* filter_state, 36 | size_t in_length); 37 | 38 | // Updates and returns the smoothed feature minimum. As minimum we use the 39 | // median of the five smallest feature values in a 100 frames long window. 40 | // As long as |handle->frame_counter| is zero, that is, we haven't received any 41 | // "valid" data, FindMinimum() outputs the default value of 1600. 42 | // 43 | // Inputs: 44 | // - feature_value : New feature value to update with. 45 | // - channel : Channel number. 46 | // 47 | // Input & Output: 48 | // - handle : State information of the VAD. 49 | // 50 | // Returns: 51 | // : Smoothed minimum value for a moving window. 52 | int16_t WebRtcVad_FindMinimum(VadInstT* handle, 53 | int16_t feature_value, 54 | int channel); 55 | 56 | #endif // WEBRTC_COMMON_AUDIO_VAD_VAD_SP_H_ 57 | -------------------------------------------------------------------------------- /webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.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 | // MSVC++ requires this to be set before any other includes to get M_PI. 12 | #define _USE_MATH_DEFINES 13 | 14 | #include "webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h" 15 | 16 | #include 17 | 18 | namespace webrtc { 19 | 20 | SinusoidalLinearChirpSource::SinusoidalLinearChirpSource(int sample_rate, 21 | size_t samples, 22 | double max_frequency, 23 | double delay_samples) 24 | : sample_rate_(sample_rate), 25 | total_samples_(samples), 26 | max_frequency_(max_frequency), 27 | current_index_(0), 28 | delay_samples_(delay_samples) { 29 | // Chirp rate. 30 | double duration = static_cast(total_samples_) / sample_rate_; 31 | k_ = (max_frequency_ - kMinFrequency) / duration; 32 | } 33 | 34 | void SinusoidalLinearChirpSource::Run(size_t frames, float* destination) { 35 | for (size_t i = 0; i < frames; ++i, ++current_index_) { 36 | // Filter out frequencies higher than Nyquist. 37 | if (Frequency(current_index_) > 0.5 * sample_rate_) { 38 | destination[i] = 0; 39 | } else { 40 | // Calculate time in seconds. 41 | if (current_index_ < delay_samples_) { 42 | destination[i] = 0; 43 | } else { 44 | // Sinusoidal linear chirp. 45 | double t = (current_index_ - delay_samples_) / sample_rate_; 46 | destination[i] = 47 | sin(2 * M_PI * (kMinFrequency * t + (k_ / 2) * t * t)); 48 | } 49 | } 50 | } 51 | } 52 | 53 | double SinusoidalLinearChirpSource::Frequency(size_t position) { 54 | return kMinFrequency + (position - delay_samples_) * 55 | (max_frequency_ - kMinFrequency) / total_samples_; 56 | } 57 | 58 | } // namespace webrtc 59 | -------------------------------------------------------------------------------- /webrtc/common_audio/sparse_fir_filter.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 "webrtc/common_audio/sparse_fir_filter.h" 12 | 13 | #include "webrtc/base/checks.h" 14 | 15 | namespace webrtc { 16 | 17 | SparseFIRFilter::SparseFIRFilter(const float* nonzero_coeffs, 18 | size_t num_nonzero_coeffs, 19 | size_t sparsity, 20 | size_t offset) 21 | : sparsity_(sparsity), 22 | offset_(offset), 23 | nonzero_coeffs_(nonzero_coeffs, nonzero_coeffs + num_nonzero_coeffs), 24 | state_(sparsity_ * (num_nonzero_coeffs - 1) + offset_, 0.f) { 25 | RTC_CHECK_GE(num_nonzero_coeffs, 1u); 26 | RTC_CHECK_GE(sparsity, 1u); 27 | } 28 | 29 | void SparseFIRFilter::Filter(const float* in, size_t length, float* out) { 30 | // Convolves the input signal |in| with the filter kernel |nonzero_coeffs_| 31 | // taking into account the previous state. 32 | for (size_t i = 0; i < length; ++i) { 33 | out[i] = 0.f; 34 | size_t j; 35 | for (j = 0; i >= j * sparsity_ + offset_ && 36 | j < nonzero_coeffs_.size(); ++j) { 37 | out[i] += in[i - j * sparsity_ - offset_] * nonzero_coeffs_[j]; 38 | } 39 | for (; j < nonzero_coeffs_.size(); ++j) { 40 | out[i] += state_[i + (nonzero_coeffs_.size() - j - 1) * sparsity_] * 41 | nonzero_coeffs_[j]; 42 | } 43 | } 44 | 45 | // Update current state. 46 | if (state_.size() > 0u) { 47 | if (length >= state_.size()) { 48 | std::memcpy(&state_[0], 49 | &in[length - state_.size()], 50 | state_.size() * sizeof(*in)); 51 | } else { 52 | std::memmove(&state_[0], 53 | &state_[length], 54 | (state_.size() - length) * sizeof(state_[0])); 55 | std::memcpy(&state_[state_.size() - length], in, length * sizeof(*in)); 56 | } 57 | } 58 | } 59 | 60 | } // namespace webrtc 61 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/vad/pitch_internal.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 "webrtc/modules/audio_processing/vad/pitch_internal.h" 12 | 13 | #include 14 | 15 | // A 4-to-3 linear interpolation. 16 | // The interpolation constants are derived as following: 17 | // Input pitch parameters are updated every 7.5 ms. Within a 30-ms interval 18 | // we are interested in pitch parameters of 0-5 ms, 10-15ms and 20-25ms. This is 19 | // like interpolating 4-to-6 and keep the odd samples. 20 | // The reason behind this is that LPC coefficients are computed for the first 21 | // half of each 10ms interval. 22 | static void PitchInterpolation(double old_val, const double* in, double* out) { 23 | out[0] = 1. / 6. * old_val + 5. / 6. * in[0]; 24 | out[1] = 5. / 6. * in[1] + 1. / 6. * in[2]; 25 | out[2] = 0.5 * in[2] + 0.5 * in[3]; 26 | } 27 | 28 | void GetSubframesPitchParameters(int sampling_rate_hz, 29 | double* gains, 30 | double* lags, 31 | int num_in_frames, 32 | int num_out_frames, 33 | double* log_old_gain, 34 | double* old_lag, 35 | double* log_pitch_gain, 36 | double* pitch_lag_hz) { 37 | // Gain interpolation is in log-domain, also returned in log-domain. 38 | for (int n = 0; n < num_in_frames; n++) 39 | gains[n] = log(gains[n] + 1e-12); 40 | 41 | // Interpolate lags and gains. 42 | PitchInterpolation(*log_old_gain, gains, log_pitch_gain); 43 | *log_old_gain = gains[num_in_frames - 1]; 44 | PitchInterpolation(*old_lag, lags, pitch_lag_hz); 45 | *old_lag = lags[num_in_frames - 1]; 46 | 47 | // Convert pitch-lags to Hertz. 48 | for (int n = 0; n < num_out_frames; n++) { 49 | pitch_lag_hz[n] = (sampling_rate_hz) / (pitch_lag_hz[n]); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /webrtc/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.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 | // This header file defines the coefficients of the FIR based approximation of 12 | // the Meyer Wavelet 13 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_DAUBECHIES_8_WAVELET_COEFFS_H_ 14 | #define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_DAUBECHIES_8_WAVELET_COEFFS_H_ 15 | 16 | // Decomposition coefficients Daubechies 8. 17 | 18 | namespace webrtc { 19 | 20 | const int kDaubechies8CoefficientsLength = 16; 21 | 22 | const float kDaubechies8HighPassCoefficients[kDaubechies8CoefficientsLength] 23 | = { 24 | -5.44158422430816093862e-02f, 25 | 3.12871590914465924627e-01f, 26 | -6.75630736298012846142e-01f, 27 | 5.85354683654869090148e-01f, 28 | 1.58291052560238926228e-02f, 29 | -2.84015542962428091389e-01f, 30 | -4.72484573997972536787e-04f, 31 | 1.28747426620186011803e-01f, 32 | 1.73693010020221083600e-02f, 33 | -4.40882539310647192377e-02f, 34 | -1.39810279170155156436e-02f, 35 | 8.74609404701565465445e-03f, 36 | 4.87035299301066034600e-03f, 37 | -3.91740372995977108837e-04f, 38 | -6.75449405998556772109e-04f, 39 | -1.17476784002281916305e-04f 40 | }; 41 | 42 | const float kDaubechies8LowPassCoefficients[kDaubechies8CoefficientsLength] = { 43 | -1.17476784002281916305e-04f, 44 | 6.75449405998556772109e-04f, 45 | -3.91740372995977108837e-04f, 46 | -4.87035299301066034600e-03f, 47 | 8.74609404701565465445e-03f, 48 | 1.39810279170155156436e-02f, 49 | -4.40882539310647192377e-02f, 50 | -1.73693010020221083600e-02f, 51 | 1.28747426620186011803e-01f, 52 | 4.72484573997972536787e-04f, 53 | -2.84015542962428091389e-01f, 54 | -1.58291052560238926228e-02f, 55 | 5.85354683654869090148e-01f, 56 | 6.75630736298012846142e-01f, 57 | 3.12871590914465924627e-01f, 58 | 5.44158422430816093862e-02f 59 | }; 60 | 61 | } // namespace webrtc 62 | 63 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_DAUBECHIES_8_WAVELET_COEFFS_H_ 64 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/source/event_timer_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 "webrtc/system_wrappers/source/event_timer_win.h" 12 | 13 | #include "Mmsystem.h" 14 | 15 | namespace webrtc { 16 | 17 | // static 18 | EventTimerWrapper* EventTimerWrapper::Create() { 19 | return new EventTimerWin(); 20 | } 21 | 22 | EventTimerWin::EventTimerWin() 23 | : event_(::CreateEvent(NULL, // security attributes 24 | FALSE, // manual reset 25 | FALSE, // initial state 26 | NULL)), // name of event 27 | timerID_(NULL) { 28 | } 29 | 30 | EventTimerWin::~EventTimerWin() { 31 | StopTimer(); 32 | CloseHandle(event_); 33 | } 34 | 35 | bool EventTimerWin::Set() { 36 | // Note: setting an event that is already set has no effect. 37 | return SetEvent(event_) == 1; 38 | } 39 | 40 | EventTypeWrapper EventTimerWin::Wait(unsigned long max_time) { 41 | unsigned long res = WaitForSingleObject(event_, max_time); 42 | switch (res) { 43 | case WAIT_OBJECT_0: 44 | return kEventSignaled; 45 | case WAIT_TIMEOUT: 46 | return kEventTimeout; 47 | default: 48 | return kEventError; 49 | } 50 | } 51 | 52 | bool EventTimerWin::StartTimer(bool periodic, unsigned long time) { 53 | if (timerID_ != NULL) { 54 | timeKillEvent(timerID_); 55 | timerID_ = NULL; 56 | } 57 | 58 | if (periodic) { 59 | timerID_ = timeSetEvent(time, 0, (LPTIMECALLBACK)HANDLE(event_), 0, 60 | TIME_PERIODIC | TIME_CALLBACK_EVENT_PULSE); 61 | } else { 62 | timerID_ = timeSetEvent(time, 0, (LPTIMECALLBACK)HANDLE(event_), 0, 63 | TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); 64 | } 65 | 66 | return timerID_ != NULL; 67 | } 68 | 69 | bool EventTimerWin::StopTimer() { 70 | if (timerID_ != NULL) { 71 | timeKillEvent(timerID_); 72 | timerID_ = NULL; 73 | } 74 | 75 | return true; 76 | } 77 | 78 | } // namespace webrtc 79 | -------------------------------------------------------------------------------- /webrtc/system_wrappers/include/aligned_malloc.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 WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_MALLOC_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_MALLOC_H_ 13 | 14 | // The functions declared here 15 | // 1) Allocates block of aligned memory. 16 | // 2) Re-calculates a pointer such that it is aligned to a higher or equal 17 | // address. 18 | // Note: alignment must be a power of two. The alignment is in bytes. 19 | 20 | #include 21 | 22 | namespace webrtc { 23 | 24 | // Returns a pointer to the first boundry of |alignment| bytes following the 25 | // address of |ptr|. 26 | // Note that there is no guarantee that the memory in question is available. 27 | // |ptr| has no requirements other than it can't be NULL. 28 | void* GetRightAlign(const void* ptr, size_t alignment); 29 | 30 | // Allocates memory of |size| bytes aligned on an |alignment| boundry. 31 | // The return value is a pointer to the memory. Note that the memory must 32 | // be de-allocated using AlignedFree. 33 | void* AlignedMalloc(size_t size, size_t alignment); 34 | // De-allocates memory created using the AlignedMalloc() API. 35 | void AlignedFree(void* mem_block); 36 | 37 | // Templated versions to facilitate usage of aligned malloc without casting 38 | // to and from void*. 39 | template 40 | T* GetRightAlign(const T* ptr, size_t alignment) { 41 | return reinterpret_cast(GetRightAlign(reinterpret_cast(ptr), 42 | alignment)); 43 | } 44 | template 45 | T* AlignedMalloc(size_t size, size_t alignment) { 46 | return reinterpret_cast(AlignedMalloc(size, alignment)); 47 | } 48 | 49 | // Deleter for use with scoped_ptr. E.g., use as 50 | // scoped_ptr foo; 51 | struct AlignedFreeDeleter { 52 | inline void operator()(void* ptr) const { 53 | AlignedFree(ptr); 54 | } 55 | }; 56 | 57 | } // namespace webrtc 58 | 59 | #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_MALLOC_H_ 60 | -------------------------------------------------------------------------------- /webrtc/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_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 | * lpc_shape_swb12_tables.h 13 | * 14 | * This file declares tables used for entropy coding of LPC shape of 15 | * upper-band signal if the bandwidth is 12 kHz. 16 | * 17 | */ 18 | 19 | #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_ 20 | #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_ 21 | 22 | #include "settings.h" 23 | #include "webrtc/typedefs.h" 24 | 25 | extern const double WebRtcIsac_kMeanLarUb12[UB_LPC_ORDER]; 26 | 27 | extern const double WebRtcIsac_kMeanLpcGain; 28 | 29 | extern const double WebRtcIsac_kIntraVecDecorrMatUb12[UB_LPC_ORDER][UB_LPC_ORDER]; 30 | 31 | extern const double WebRtcIsac_kInterVecDecorrMatUb12 32 | [UB_LPC_VEC_PER_FRAME][UB_LPC_VEC_PER_FRAME]; 33 | 34 | extern const double WebRtcIsac_kLpcShapeQStepSizeUb12; 35 | 36 | extern const double WebRtcIsac_kLpcShapeLeftRecPointUb12 37 | [UB_LPC_ORDER*UB_LPC_VEC_PER_FRAME]; 38 | 39 | 40 | extern const int16_t WebRtcIsac_kLpcShapeNumRecPointUb12 41 | [UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; 42 | 43 | extern const uint16_t WebRtcIsac_kLpcShapeEntropySearchUb12 44 | [UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; 45 | 46 | extern const uint16_t WebRtcIsac_kLpcShapeCdfVec0Ub12[14]; 47 | 48 | extern const uint16_t WebRtcIsac_kLpcShapeCdfVec1Ub12[16]; 49 | 50 | extern const uint16_t WebRtcIsac_kLpcShapeCdfVec2Ub12[20]; 51 | 52 | extern const uint16_t WebRtcIsac_kLpcShapeCdfVec3Ub12[28]; 53 | 54 | extern const uint16_t WebRtcIsac_kLpcShapeCdfVec4Ub12[20]; 55 | 56 | extern const uint16_t WebRtcIsac_kLpcShapeCdfVec5Ub12[25]; 57 | 58 | extern const uint16_t WebRtcIsac_kLpcShapeCdfVec6Ub12[33]; 59 | 60 | extern const uint16_t WebRtcIsac_kLpcShapeCdfVec7Ub12[49]; 61 | 62 | extern const uint16_t* WebRtcIsac_kLpcShapeCdfMatUb12 63 | [UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; 64 | 65 | #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_ 66 | -------------------------------------------------------------------------------- /webrtc/common_audio/resampler/sinc_resampler_sse.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/simd/sinc_resampler_sse.cc 13 | 14 | #include "webrtc/common_audio/resampler/sinc_resampler.h" 15 | 16 | #include 17 | 18 | namespace webrtc { 19 | 20 | float SincResampler::Convolve_SSE(const float* input_ptr, const float* k1, 21 | const float* k2, 22 | double kernel_interpolation_factor) { 23 | __m128 m_input; 24 | __m128 m_sums1 = _mm_setzero_ps(); 25 | __m128 m_sums2 = _mm_setzero_ps(); 26 | 27 | // Based on |input_ptr| alignment, we need to use loadu or load. Unrolling 28 | // these loops hurt performance in local testing. 29 | if (reinterpret_cast(input_ptr) & 0x0F) { 30 | for (size_t i = 0; i < kKernelSize; i += 4) { 31 | m_input = _mm_loadu_ps(input_ptr + i); 32 | m_sums1 = _mm_add_ps(m_sums1, _mm_mul_ps(m_input, _mm_load_ps(k1 + i))); 33 | m_sums2 = _mm_add_ps(m_sums2, _mm_mul_ps(m_input, _mm_load_ps(k2 + i))); 34 | } 35 | } else { 36 | for (size_t i = 0; i < kKernelSize; i += 4) { 37 | m_input = _mm_load_ps(input_ptr + i); 38 | m_sums1 = _mm_add_ps(m_sums1, _mm_mul_ps(m_input, _mm_load_ps(k1 + i))); 39 | m_sums2 = _mm_add_ps(m_sums2, _mm_mul_ps(m_input, _mm_load_ps(k2 + i))); 40 | } 41 | } 42 | 43 | // Linearly interpolate the two "convolutions". 44 | m_sums1 = _mm_mul_ps(m_sums1, _mm_set_ps1( 45 | static_cast(1.0 - kernel_interpolation_factor))); 46 | m_sums2 = _mm_mul_ps(m_sums2, _mm_set_ps1( 47 | static_cast(kernel_interpolation_factor))); 48 | m_sums1 = _mm_add_ps(m_sums1, m_sums2); 49 | 50 | // Sum components together. 51 | float result; 52 | m_sums2 = _mm_add_ps(_mm_movehl_ps(m_sums1, m_sums1), m_sums1); 53 | _mm_store_ss(&result, _mm_add_ss(m_sums2, _mm_shuffle_ps( 54 | m_sums2, m_sums2, 1))); 55 | 56 | return result; 57 | } 58 | 59 | } // namespace webrtc 60 | --------------------------------------------------------------------------------