1 /* 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "modules/audio_processing/aec3/aec3_common.h" 12 13 #include <stdint.h> 14 15 #include "rtc_base/checks.h" 16 #include "rtc_base/system/arch.h" 17 #include "system_wrappers/include/cpu_features_wrapper.h" 18 19 namespace webrtc { 20 DetectOptimization()21Aec3Optimization DetectOptimization() { 22 #if defined(WEBRTC_ARCH_X86_FAMILY) 23 if (WebRtc_GetCPUInfo(kSSE2) != 0) { 24 return Aec3Optimization::kSse2; 25 } 26 #endif 27 28 #if defined(WEBRTC_HAS_NEON) 29 return Aec3Optimization::kNeon; 30 #endif 31 32 return Aec3Optimization::kNone; 33 } 34 FastApproxLog2f(const float in)35float FastApproxLog2f(const float in) { 36 RTC_DCHECK_GT(in, .0f); 37 // Read and interpret float as uint32_t and then cast to float. 38 // This is done to extract the exponent (bits 30 - 23). 39 // "Right shift" of the exponent is then performed by multiplying 40 // with the constant (1/2^23). Finally, we subtract a constant to 41 // remove the bias (https://en.wikipedia.org/wiki/Exponent_bias). 42 union { 43 float dummy; 44 uint32_t a; 45 } x = {in}; 46 float out = x.a; 47 out *= 1.1920929e-7f; // 1/2^23 48 out -= 126.942695f; // Remove bias. 49 return out; 50 } 51 Log2TodB(const float in_log2)52float Log2TodB(const float in_log2) { 53 return 3.0102999566398121 * in_log2; 54 } 55 56 } // namespace webrtc 57