├── CMakeLists.txt ├── WebRtcAudioTest.cpp ├── WebRtcMoudle ├── CMakeLists.txt ├── aec_core.c ├── aec_core.h ├── aec_core_internal.h ├── aec_core_sse2.c ├── aec_rdft.c ├── aec_rdft.h ├── aec_rdft_sse2.c ├── aec_resampler.c ├── aec_resampler.h ├── analog_agc.c ├── analog_agc.h ├── build │ ├── CMakeCache.txt │ ├── Makefile │ ├── cmake_install.cmake │ ├── install_manifest.txt │ └── libwebRTC.so ├── compile_assert_c.h ├── complex_bit_reverse.c ├── complex_fft.c ├── complex_fft_tables.h ├── copy_set_operations.c ├── cpu_features.cpp ├── cpu_features_wrapper.h ├── cpu_info.h ├── cross_correlation.c ├── defines.h ├── delay_estimator.c ├── delay_estimator.h ├── delay_estimator_internal.h ├── delay_estimator_wrapper.c ├── delay_estimator_wrapper.h ├── digital_agc.c ├── digital_agc.h ├── division_operations.c ├── dot_product_with_scale.c ├── downsample_fast.c ├── echo_cancellation.c ├── echo_cancellation.h ├── echo_cancellation_internal.h ├── energy.c ├── fft4g.c ├── fft4g.h ├── gain_control.h ├── get_scaling_square.c ├── min_max_operations.c ├── noise_suppression.c ├── noise_suppression.h ├── noise_suppression_x.c ├── noise_suppression_x.h ├── ns_core.c ├── ns_core.h ├── nsx_core.c ├── nsx_core.h ├── nsx_core_c.c ├── nsx_core_neon_offsets.c ├── nsx_defines.h ├── randomization_functions.c ├── real_fft.c ├── real_fft.h ├── resample.c ├── resample_48khz.c ├── resample_by_2.c ├── resample_by_2_internal.c ├── resample_by_2_internal.h ├── resample_by_2_mips.c ├── resample_fractional.c ├── ring_buffer.c ├── ring_buffer.h ├── signal_processing_library.h ├── spl_init.c ├── spl_inl.h ├── spl_sqrt.c ├── spl_sqrt_floor.c ├── splitting_filter.c ├── typedefs.h ├── vector_scaling_operations.c └── windows_private.h ├── build ├── CMakeCache.txt ├── Makefile ├── cmake_install.cmake └── webRTCtest ├── stdafx.cpp ├── stdafx.h ├── targetver.h └── 文件备份 ├── WebRtcAudioTest(复件).cpp ├── jilu.txt ├── stdafx(复件).cpp ├── stdafx(复件).h └── targetver(复件).h /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | PROJECT(webRTC) 3 | 4 | SET(CMAKE_CXX_FLAGS_DEBUG "") 5 | 6 | AUX_SOURCE_DIRECTORY(${PROJECT_SOURCE_DIR} main_srs) 7 | 8 | include_directories(/usr/include/webRtcModule) 9 | include_directories(${PROJECT_SOURCE_DIR}) 10 | 11 | add_executable(webRTCtest ${main_srs}) 12 | 13 | TARGET_LINK_LIBRARIES(webRTCtest libwebRTC.so) 14 | TARGET_LINK_LIBRARIES(webRTCtest libpthread.so) 15 | -------------------------------------------------------------------------------- /WebRtcAudioTest.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljl86400/webRTCtest/e812bbd08b5ba216c55011615ae4f400b7f7376f/WebRtcAudioTest.cpp -------------------------------------------------------------------------------- /WebRtcMoudle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | PROJECT(webRTCLIB) 3 | 4 | AUX_SOURCE_DIRECTORY(. DIR_SRCS) 5 | SET(DIR_HEADERS analog_agc.h complex_fft_tables.h cpu_features_wrapper.h defines.h digital_agc.h 6 | fft4g.h gain_control.h noise_suppression.h noise_suppression_x.h ns_core.h nsx_core.h nsx_defines.h real_fft.h resample_by_2_internal.h ring_buffer.h signal_processing_library.h spl_inl.h typedefs.h windows_private.h aec_core.h 7 | aec_core_internal.h aec_rdft.h aec_resampler.h echo_cancellation.h echo_cancellation_internal.h delay_estimator.h delay_estimator_internal.h delay_estimator_wrapper.h ring_buffer.h) 8 | # SET(LIBWebRTC_SRC ${DIR_SRCS}) 9 | ADD_LIBRARY(webRTC SHARED ${DIR_SRCS}) 10 | ADD_LIBRARY(webRTC_static STATIC ${DIR_SRCS}) 11 | ADD_DEFINITIONS(-DWEBRTC_POSIX) 12 | SET_TARGET_PROPERTIES(webRTC_static PROPERTIES OUTPUT_NAME "webRTC") 13 | GET_TARGET_PROPERTY(OUTPUT_VALUE webRTC_static OUTPUT_NAME) 14 | MESSAGE(STATUS "this is the webRTC_static OUTPUT_NAME:"${OUTPUT_VALUE}) 15 | 16 | SET_TARGET_PROPERTIES(webRTC PROPERTIES CLEAN_DIRECT_OUTPUT 1) 17 | SET_TARGET_PROPERTIES(webRTC_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) 18 | 19 | 20 | INSTALL(TARGETS webRTC webRTC_static 21 | LIBRARY DESTINATION lib 22 | ARCHIVE DESTINATION lib 23 | RUNTIME DESTINATION lib 24 | COMPONENT library) 25 | 26 | INSTALL(FILES ${DIR_HEADERS} DESTINATION include/webRtcModule) 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /WebRtcMoudle/aec_core.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 | * Specifies the interface for the AEC core. 13 | */ 14 | 15 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_CORE_H_ 16 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_CORE_H_ 17 | 18 | #include "typedefs.h" 19 | 20 | #define FRAME_LEN 80 21 | #define PART_LEN 64 // Length of partition 22 | #define PART_LEN1 (PART_LEN + 1) // Unique fft coefficients 23 | #define PART_LEN2 (PART_LEN * 2) // Length of partition * 2 24 | 25 | // Delay estimator constants, used for logging. 26 | enum { 27 | kMaxDelayBlocks = 60 28 | }; 29 | enum { 30 | kLookaheadBlocks = 15 31 | }; 32 | enum { 33 | kHistorySizeBlocks = kMaxDelayBlocks + kLookaheadBlocks 34 | }; 35 | 36 | typedef float complex_t[2]; 37 | // For performance reasons, some arrays of complex numbers are replaced by twice 38 | // as long arrays of float, all the real parts followed by all the imaginary 39 | // ones (complex_t[SIZE] -> float[2][SIZE]). This allows SIMD optimizations and 40 | // is better than two arrays (one for the real parts and one for the imaginary 41 | // parts) as this other way would require two pointers instead of one and cause 42 | // extra register spilling. This also allows the offsets to be calculated at 43 | // compile time. 44 | 45 | // Metrics 46 | enum { 47 | kOffsetLevel = -100 48 | }; 49 | 50 | typedef struct Stats { 51 | float instant; 52 | float average; 53 | float min; 54 | float max; 55 | float sum; 56 | float hisum; 57 | float himean; 58 | int counter; 59 | int hicounter; 60 | } Stats; 61 | 62 | typedef struct AecCore AecCore; 63 | 64 | int WebRtcAec_CreateAec(AecCore** aec); 65 | int WebRtcAec_FreeAec(AecCore* aec); 66 | int WebRtcAec_InitAec(AecCore* aec, int sampFreq); 67 | void WebRtcAec_InitAec_SSE2(void); 68 | 69 | void WebRtcAec_BufferFarendPartition(AecCore* aec, const float* farend); 70 | void WebRtcAec_ProcessFrame(AecCore* aec, 71 | const short* nearend, 72 | const short* nearendH, 73 | int knownDelay, 74 | int16_t* out, 75 | int16_t* outH); 76 | 77 | // A helper function to call WebRtc_MoveReadPtr() for all far-end buffers. 78 | // Returns the number of elements moved, and adjusts |system_delay| by the 79 | // corresponding amount in ms. 80 | int WebRtcAec_MoveFarReadPtr(AecCore* aec, int elements); 81 | 82 | // Calculates the median and standard deviation among the delay estimates 83 | // collected since the last call to this function. 84 | int WebRtcAec_GetDelayMetricsCore(AecCore* self, int* median, int* std); 85 | 86 | // Returns the echo state (1: echo, 0: no echo). 87 | int WebRtcAec_echo_state(AecCore* self); 88 | 89 | // Gets statistics of the echo metrics ERL, ERLE, A_NLP. 90 | void WebRtcAec_GetEchoStats(AecCore* self, 91 | Stats* erl, 92 | Stats* erle, 93 | Stats* a_nlp); 94 | #ifdef WEBRTC_AEC_DEBUG_DUMP 95 | void* WebRtcAec_far_time_buf(AecCore* self); 96 | #endif 97 | 98 | // Sets local configuration modes. 99 | void WebRtcAec_SetConfigCore(AecCore* self, 100 | int nlp_mode, 101 | int metrics_mode, 102 | int delay_logging); 103 | 104 | // We now interpret delay correction to mean an extended filter length feature. 105 | // We reuse the delay correction infrastructure to avoid changes through to 106 | // libjingle. See details along with |DelayCorrection| in 107 | // echo_cancellation_impl.h. Non-zero enables, zero disables. 108 | void WebRtcAec_enable_delay_correction(AecCore* self, int enable); 109 | 110 | // Returns non-zero if delay correction is enabled and zero if disabled. 111 | int WebRtcAec_delay_correction_enabled(AecCore* self); 112 | 113 | // Returns the current |system_delay|, i.e., the buffered difference between 114 | // far-end and near-end. 115 | int WebRtcAec_system_delay(AecCore* self); 116 | 117 | // Sets the |system_delay| to |value|. Note that if the value is changed 118 | // improperly, there can be a performance regression. So it should be used with 119 | // care. 120 | void WebRtcAec_SetSystemDelay(AecCore* self, int delay); 121 | 122 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_CORE_H_ 123 | -------------------------------------------------------------------------------- /WebRtcMoudle/aec_core_internal.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_AEC_AEC_CORE_INTERNAL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_CORE_INTERNAL_H_ 13 | 14 | #ifdef WEBRTC_AEC_DEBUG_DUMP 15 | #include 16 | #endif 17 | 18 | #include "aec_core.h" 19 | #include "ring_buffer.h" 20 | #include "typedefs.h" 21 | 22 | // Number of partitions for the extended filter mode. The first one is an enum 23 | // to be used in array declarations, as it represents the maximum filter length. 24 | enum { 25 | kExtendedNumPartitions = 32 26 | }; 27 | static const int kNormalNumPartitions = 12; 28 | 29 | // Extended filter adaptation parameters. 30 | // TODO(ajm): No narrowband tuning yet. 31 | static const float kExtendedMu = 0.4f; 32 | static const float kExtendedErrorThreshold = 1.0e-6f; 33 | 34 | typedef struct PowerLevel { 35 | float sfrsum; 36 | int sfrcounter; 37 | float framelevel; 38 | float frsum; 39 | int frcounter; 40 | float minlevel; 41 | float averagelevel; 42 | } PowerLevel; 43 | 44 | struct AecCore { 45 | int farBufWritePos, farBufReadPos; 46 | 47 | int knownDelay; 48 | int inSamples, outSamples; 49 | int delayEstCtr; 50 | 51 | RingBuffer* nearFrBuf; 52 | RingBuffer* outFrBuf; 53 | 54 | RingBuffer* nearFrBufH; 55 | RingBuffer* outFrBufH; 56 | 57 | float dBuf[PART_LEN2]; // nearend 58 | float eBuf[PART_LEN2]; // error 59 | 60 | float dBufH[PART_LEN2]; // nearend 61 | 62 | float xPow[PART_LEN1]; 63 | float dPow[PART_LEN1]; 64 | float dMinPow[PART_LEN1]; 65 | float dInitMinPow[PART_LEN1]; 66 | float* noisePow; 67 | 68 | float xfBuf[2][kExtendedNumPartitions * PART_LEN1]; // farend fft buffer 69 | float wfBuf[2][kExtendedNumPartitions * PART_LEN1]; // filter fft 70 | complex_t sde[PART_LEN1]; // cross-psd of nearend and error 71 | complex_t sxd[PART_LEN1]; // cross-psd of farend and nearend 72 | // Farend windowed fft buffer. 73 | complex_t xfwBuf[kExtendedNumPartitions * PART_LEN1]; 74 | 75 | float sx[PART_LEN1], sd[PART_LEN1], se[PART_LEN1]; // far, near, error psd 76 | float hNs[PART_LEN1]; 77 | float hNlFbMin, hNlFbLocalMin; 78 | float hNlXdAvgMin; 79 | int hNlNewMin, hNlMinCtr; 80 | float overDrive, overDriveSm; 81 | int nlp_mode; 82 | float outBuf[PART_LEN]; 83 | int delayIdx; 84 | 85 | short stNearState, echoState; 86 | short divergeState; 87 | 88 | int xfBufBlockPos; 89 | 90 | RingBuffer* far_buf; 91 | RingBuffer* far_buf_windowed; 92 | int system_delay; // Current system delay buffered in AEC. 93 | 94 | int mult; // sampling frequency multiple 95 | int sampFreq; 96 | uint32_t seed; 97 | 98 | float normal_mu; // stepsize 99 | float normal_error_threshold; // error threshold 100 | 101 | int noiseEstCtr; 102 | 103 | PowerLevel farlevel; 104 | PowerLevel nearlevel; 105 | PowerLevel linoutlevel; 106 | PowerLevel nlpoutlevel; 107 | 108 | int metricsMode; 109 | int stateCounter; 110 | Stats erl; 111 | Stats erle; 112 | Stats aNlp; 113 | Stats rerl; 114 | 115 | // Quantities to control H band scaling for SWB input 116 | int freq_avg_ic; // initial bin for averaging nlp gain 117 | int flag_Hband_cn; // for comfort noise 118 | float cn_scale_Hband; // scale for comfort noise in H band 119 | 120 | int delay_histogram[kHistorySizeBlocks]; 121 | int delay_logging_enabled; 122 | void* delay_estimator_farend; 123 | void* delay_estimator; 124 | 125 | // 1 = extended filter mode enabled, 0 = disabled. 126 | int extended_filter_enabled; 127 | // Runtime selection of number of filter partitions. 128 | int num_partitions; 129 | 130 | #ifdef WEBRTC_AEC_DEBUG_DUMP 131 | RingBuffer* far_time_buf; 132 | FILE* farFile; 133 | FILE* nearFile; 134 | FILE* outFile; 135 | FILE* outLinearFile; 136 | #endif 137 | }; 138 | 139 | typedef void (*WebRtcAec_FilterFar_t)(AecCore* aec, float yf[2][PART_LEN1]); 140 | extern WebRtcAec_FilterFar_t WebRtcAec_FilterFar; 141 | typedef void (*WebRtcAec_ScaleErrorSignal_t)(AecCore* aec, 142 | float ef[2][PART_LEN1]); 143 | extern WebRtcAec_ScaleErrorSignal_t WebRtcAec_ScaleErrorSignal; 144 | typedef void (*WebRtcAec_FilterAdaptation_t)(AecCore* aec, 145 | float* fft, 146 | float ef[2][PART_LEN1]); 147 | extern WebRtcAec_FilterAdaptation_t WebRtcAec_FilterAdaptation; 148 | typedef void (*WebRtcAec_OverdriveAndSuppress_t)(AecCore* aec, 149 | float hNl[PART_LEN1], 150 | const float hNlFb, 151 | float efw[2][PART_LEN1]); 152 | extern WebRtcAec_OverdriveAndSuppress_t WebRtcAec_OverdriveAndSuppress; 153 | 154 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_CORE_INTERNAL_H_ 155 | -------------------------------------------------------------------------------- /WebRtcMoudle/aec_rdft.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_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_AEC_RDFT_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_AEC_RDFT_H_ 13 | 14 | // These intrinsics were unavailable before VS 2008. 15 | // TODO(andrew): move to a common file. 16 | #if defined(_MSC_VER) && _MSC_VER < 1500 17 | #include 18 | static __inline __m128 _mm_castsi128_ps(__m128i a) { return *(__m128*)&a; } 19 | static __inline __m128i _mm_castps_si128(__m128 a) { return *(__m128i*)&a; } 20 | #endif 21 | 22 | #ifdef _MSC_VER /* visual c++ */ 23 | #define ALIGN16_BEG __declspec(align(16)) 24 | #define ALIGN16_END 25 | #else /* gcc or icc */ 26 | #define ALIGN16_BEG 27 | #define ALIGN16_END __attribute__((aligned(16))) 28 | #endif 29 | 30 | // constants shared by all paths (C, SSE2). 31 | extern float rdft_w[64]; 32 | // constants used by the C path. 33 | extern float rdft_wk3ri_first[32]; 34 | extern float rdft_wk3ri_second[32]; 35 | // constants used by SSE2 but initialized in C path. 36 | extern float rdft_wk1r[32]; 37 | extern float rdft_wk2r[32]; 38 | extern float rdft_wk3r[32]; 39 | extern float rdft_wk1i[32]; 40 | extern float rdft_wk2i[32]; 41 | extern float rdft_wk3i[32]; 42 | extern float cftmdl_wk1r[4]; 43 | 44 | // code path selection function pointers 45 | typedef void (*rft_sub_128_t)(float* a); 46 | extern rft_sub_128_t rftfsub_128; 47 | extern rft_sub_128_t rftbsub_128; 48 | extern rft_sub_128_t cft1st_128; 49 | extern rft_sub_128_t cftmdl_128; 50 | 51 | // entry points 52 | void aec_rdft_init(void); 53 | void aec_rdft_init_sse2(void); 54 | void aec_rdft_forward_128(float* a); 55 | void aec_rdft_inverse_128(float* a); 56 | 57 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_AEC_RDFT_H_ 58 | -------------------------------------------------------------------------------- /WebRtcMoudle/aec_resampler.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 | /* Resamples a signal to an arbitrary rate. Used by the AEC to compensate for 12 | * clock skew by resampling the farend signal. 13 | */ 14 | 15 | #include "aec_resampler.h" 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "aec_core.h" 23 | 24 | enum { 25 | kEstimateLengthFrames = 400 26 | }; 27 | 28 | typedef struct { 29 | short buffer[kResamplerBufferSize]; 30 | float position; 31 | 32 | int deviceSampleRateHz; 33 | int skewData[kEstimateLengthFrames]; 34 | int skewDataIndex; 35 | float skewEstimate; 36 | } resampler_t; 37 | 38 | static int EstimateSkew(const int* rawSkew, 39 | int size, 40 | int absLimit, 41 | float* skewEst); 42 | 43 | int WebRtcAec_CreateResampler(void** resampInst) { 44 | resampler_t* obj = malloc(sizeof(resampler_t)); 45 | *resampInst = obj; 46 | if (obj == NULL) { 47 | return -1; 48 | } 49 | 50 | return 0; 51 | } 52 | 53 | int WebRtcAec_InitResampler(void* resampInst, int deviceSampleRateHz) { 54 | resampler_t* obj = (resampler_t*)resampInst; 55 | memset(obj->buffer, 0, sizeof(obj->buffer)); 56 | obj->position = 0.0; 57 | 58 | obj->deviceSampleRateHz = deviceSampleRateHz; 59 | memset(obj->skewData, 0, sizeof(obj->skewData)); 60 | obj->skewDataIndex = 0; 61 | obj->skewEstimate = 0.0; 62 | 63 | return 0; 64 | } 65 | 66 | int WebRtcAec_FreeResampler(void* resampInst) { 67 | resampler_t* obj = (resampler_t*)resampInst; 68 | free(obj); 69 | 70 | return 0; 71 | } 72 | 73 | void WebRtcAec_ResampleLinear(void* resampInst, 74 | const short* inspeech, 75 | int size, 76 | float skew, 77 | short* outspeech, 78 | int* size_out) { 79 | resampler_t* obj = (resampler_t*)resampInst; 80 | 81 | short* y; 82 | float be, tnew, interp; 83 | int tn, mm; 84 | 85 | assert(!(size < 0 || size > 2 * FRAME_LEN)); 86 | assert(resampInst != NULL); 87 | assert(inspeech != NULL); 88 | assert(outspeech != NULL); 89 | assert(size_out != NULL); 90 | 91 | // Add new frame data in lookahead 92 | memcpy(&obj->buffer[FRAME_LEN + kResamplingDelay], 93 | inspeech, 94 | size * sizeof(short)); 95 | 96 | // Sample rate ratio 97 | be = 1 + skew; 98 | 99 | // Loop over input frame 100 | mm = 0; 101 | y = &obj->buffer[FRAME_LEN]; // Point at current frame 102 | 103 | tnew = be * mm + obj->position; 104 | tn = (int)tnew; 105 | 106 | while (tn < size) { 107 | 108 | // Interpolation 109 | interp = y[tn] + (tnew - tn) * (y[tn + 1] - y[tn]); 110 | 111 | if (interp > 32767) { 112 | interp = 32767; 113 | } else if (interp < -32768) { 114 | interp = -32768; 115 | } 116 | 117 | outspeech[mm] = (short)interp; 118 | mm++; 119 | 120 | tnew = be * mm + obj->position; 121 | tn = (int)tnew; 122 | } 123 | 124 | *size_out = mm; 125 | obj->position += (*size_out) * be - size; 126 | 127 | // Shift buffer 128 | memmove(obj->buffer, 129 | &obj->buffer[size], 130 | (kResamplerBufferSize - size) * sizeof(short)); 131 | } 132 | 133 | int WebRtcAec_GetSkew(void* resampInst, int rawSkew, float* skewEst) { 134 | resampler_t* obj = (resampler_t*)resampInst; 135 | int err = 0; 136 | 137 | if (obj->skewDataIndex < kEstimateLengthFrames) { 138 | obj->skewData[obj->skewDataIndex] = rawSkew; 139 | obj->skewDataIndex++; 140 | } else if (obj->skewDataIndex == kEstimateLengthFrames) { 141 | err = EstimateSkew( 142 | obj->skewData, kEstimateLengthFrames, obj->deviceSampleRateHz, skewEst); 143 | obj->skewEstimate = *skewEst; 144 | obj->skewDataIndex++; 145 | } else { 146 | *skewEst = obj->skewEstimate; 147 | } 148 | 149 | return err; 150 | } 151 | 152 | int EstimateSkew(const int* rawSkew, 153 | int size, 154 | int deviceSampleRateHz, 155 | float* skewEst) { 156 | const int absLimitOuter = (int)(0.04f * deviceSampleRateHz); 157 | const int absLimitInner = (int)(0.0025f * deviceSampleRateHz); 158 | int i = 0; 159 | int n = 0; 160 | float rawAvg = 0; 161 | float err = 0; 162 | float rawAbsDev = 0; 163 | int upperLimit = 0; 164 | int lowerLimit = 0; 165 | float cumSum = 0; 166 | float x = 0; 167 | float x2 = 0; 168 | float y = 0; 169 | float xy = 0; 170 | float xAvg = 0; 171 | float denom = 0; 172 | float skew = 0; 173 | 174 | *skewEst = 0; // Set in case of error below. 175 | for (i = 0; i < size; i++) { 176 | if ((rawSkew[i] < absLimitOuter && rawSkew[i] > -absLimitOuter)) { 177 | n++; 178 | rawAvg += rawSkew[i]; 179 | } 180 | } 181 | 182 | if (n == 0) { 183 | return -1; 184 | } 185 | assert(n > 0); 186 | rawAvg /= n; 187 | 188 | for (i = 0; i < size; i++) { 189 | if ((rawSkew[i] < absLimitOuter && rawSkew[i] > -absLimitOuter)) { 190 | err = rawSkew[i] - rawAvg; 191 | rawAbsDev += err >= 0 ? err : -err; 192 | } 193 | } 194 | assert(n > 0); 195 | rawAbsDev /= n; 196 | upperLimit = (int)(rawAvg + 5 * rawAbsDev + 1); // +1 for ceiling. 197 | lowerLimit = (int)(rawAvg - 5 * rawAbsDev - 1); // -1 for floor. 198 | 199 | n = 0; 200 | for (i = 0; i < size; i++) { 201 | if ((rawSkew[i] < absLimitInner && rawSkew[i] > -absLimitInner) || 202 | (rawSkew[i] < upperLimit && rawSkew[i] > lowerLimit)) { 203 | n++; 204 | cumSum += rawSkew[i]; 205 | x += n; 206 | x2 += n * n; 207 | y += cumSum; 208 | xy += n * cumSum; 209 | } 210 | } 211 | 212 | if (n == 0) { 213 | return -1; 214 | } 215 | assert(n > 0); 216 | xAvg = x / n; 217 | denom = x2 - xAvg * x; 218 | 219 | if (denom != 0) { 220 | skew = (xy - xAvg * y) / denom; 221 | } 222 | 223 | *skewEst = skew; 224 | return 0; 225 | } 226 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "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 | int WebRtcAec_CreateResampler(void** resampInst); 25 | int WebRtcAec_InitResampler(void* resampInst, int deviceSampleRateHz); 26 | int 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 short* inspeech, 34 | int size, 35 | float skew, 36 | short* outspeech, 37 | int* size_out); 38 | 39 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_RESAMPLER_H_ 40 | -------------------------------------------------------------------------------- /WebRtcMoudle/analog_agc.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_MODULES_AUDIO_PROCESSING_AGC_MAIN_SOURCE_ANALOG_AGC_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_MAIN_SOURCE_ANALOG_AGC_H_ 13 | 14 | #include "digital_agc.h" 15 | #include "gain_control.h" 16 | #include "typedefs.h" 17 | 18 | //#define AGC_DEBUG 19 | //#define MIC_LEVEL_FEEDBACK 20 | #ifdef AGC_DEBUG 21 | #include 22 | #endif 23 | 24 | /* Analog Automatic Gain Control variables: 25 | * Constant declarations (inner limits inside which no changes are done) 26 | * In the beginning the range is narrower to widen as soon as the measure 27 | * 'Rxx160_LP' is inside it. Currently the starting limits are -22.2+/-1dBm0 28 | * and the final limits -22.2+/-2.5dBm0. These levels makes the speech signal 29 | * go towards -25.4dBm0 (-31.4dBov). Tuned with wbfile-31.4dBov.pcm 30 | * The limits are created by running the AGC with a file having the desired 31 | * signal level and thereafter plotting Rxx160_LP in the dBm0-domain defined 32 | * by out=10*log10(in/260537279.7); Set the target level to the average level 33 | * of our measure Rxx160_LP. Remember that the levels are in blocks of 16 in 34 | * Q(-7). (Example matlab code: round(db2pow(-21.2)*16/2^7) ) 35 | */ 36 | #define RXX_BUFFER_LEN 10 37 | 38 | static const int16_t kMsecSpeechInner = 520; 39 | static const int16_t kMsecSpeechOuter = 340; 40 | 41 | static const int16_t kNormalVadThreshold = 400; 42 | 43 | static const int16_t kAlphaShortTerm = 6; // 1 >> 6 = 0.0156 44 | static const int16_t kAlphaLongTerm = 10; // 1 >> 10 = 0.000977 45 | 46 | typedef struct 47 | { 48 | // Configurable parameters/variables 49 | uint32_t fs; // Sampling frequency 50 | int16_t compressionGaindB; // Fixed gain level in dB 51 | int16_t targetLevelDbfs; // Target level in -dBfs of envelope (default -3) 52 | int16_t agcMode; // Hard coded mode (adaptAna/adaptDig/fixedDig) 53 | uint8_t limiterEnable; // Enabling limiter (on/off (default off)) 54 | WebRtcAgc_config_t defaultConfig; 55 | WebRtcAgc_config_t usedConfig; 56 | 57 | // General variables 58 | int16_t initFlag; 59 | int16_t lastError; 60 | 61 | // Target level parameters 62 | // Based on the above: analogTargetLevel = round((32767*10^(-22/20))^2*16/2^7) 63 | int32_t analogTargetLevel; // = RXX_BUFFER_LEN * 846805; -22 dBfs 64 | int32_t startUpperLimit; // = RXX_BUFFER_LEN * 1066064; -21 dBfs 65 | int32_t startLowerLimit; // = RXX_BUFFER_LEN * 672641; -23 dBfs 66 | int32_t upperPrimaryLimit; // = RXX_BUFFER_LEN * 1342095; -20 dBfs 67 | int32_t lowerPrimaryLimit; // = RXX_BUFFER_LEN * 534298; -24 dBfs 68 | int32_t upperSecondaryLimit;// = RXX_BUFFER_LEN * 2677832; -17 dBfs 69 | int32_t lowerSecondaryLimit;// = RXX_BUFFER_LEN * 267783; -27 dBfs 70 | uint16_t targetIdx; // Table index for corresponding target level 71 | #ifdef MIC_LEVEL_FEEDBACK 72 | uint16_t targetIdxOffset; // Table index offset for level compensation 73 | #endif 74 | int16_t analogTarget; // Digital reference level in ENV scale 75 | 76 | // Analog AGC specific variables 77 | int32_t filterState[8]; // For downsampling wb to nb 78 | int32_t upperLimit; // Upper limit for mic energy 79 | int32_t lowerLimit; // Lower limit for mic energy 80 | int32_t Rxx160w32; // Average energy for one frame 81 | int32_t Rxx16_LPw32; // Low pass filtered subframe energies 82 | int32_t Rxx160_LPw32; // Low pass filtered frame energies 83 | int32_t Rxx16_LPw32Max; // Keeps track of largest energy subframe 84 | int32_t Rxx16_vectorw32[RXX_BUFFER_LEN];// Array with subframe energies 85 | int32_t Rxx16w32_array[2][5];// Energy values of microphone signal 86 | int32_t env[2][10]; // Envelope values of subframes 87 | 88 | int16_t Rxx16pos; // Current position in the Rxx16_vectorw32 89 | int16_t envSum; // Filtered scaled envelope in subframes 90 | int16_t vadThreshold; // Threshold for VAD decision 91 | int16_t inActive; // Inactive time in milliseconds 92 | int16_t msTooLow; // Milliseconds of speech at a too low level 93 | int16_t msTooHigh; // Milliseconds of speech at a too high level 94 | int16_t changeToSlowMode; // Change to slow mode after some time at target 95 | int16_t firstCall; // First call to the process-function 96 | int16_t msZero; // Milliseconds of zero input 97 | int16_t msecSpeechOuterChange;// Min ms of speech between volume changes 98 | int16_t msecSpeechInnerChange;// Min ms of speech between volume changes 99 | int16_t activeSpeech; // Milliseconds of active speech 100 | int16_t muteGuardMs; // Counter to prevent mute action 101 | int16_t inQueue; // 10 ms batch indicator 102 | 103 | // Microphone level variables 104 | int32_t micRef; // Remember ref. mic level for virtual mic 105 | uint16_t gainTableIdx; // Current position in virtual gain table 106 | int32_t micGainIdx; // Gain index of mic level to increase slowly 107 | int32_t micVol; // Remember volume between frames 108 | int32_t maxLevel; // Max possible vol level, incl dig gain 109 | int32_t maxAnalog; // Maximum possible analog volume level 110 | int32_t maxInit; // Initial value of "max" 111 | int32_t minLevel; // Minimum possible volume level 112 | int32_t minOutput; // Minimum output volume level 113 | int32_t zeroCtrlMax; // Remember max gain => don't amp low input 114 | 115 | int16_t scale; // Scale factor for internal volume levels 116 | #ifdef MIC_LEVEL_FEEDBACK 117 | int16_t numBlocksMicLvlSat; 118 | uint8_t micLvlSat; 119 | #endif 120 | // Structs for VAD and digital_agc 121 | AgcVad_t vadMic; 122 | DigitalAgc_t digitalAgc; 123 | 124 | #ifdef AGC_DEBUG 125 | FILE* fpt; 126 | FILE* agcLog; 127 | int32_t fcount; 128 | #endif 129 | 130 | int16_t lowLevelSignal; 131 | } Agc_t; 132 | 133 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_MAIN_SOURCE_ANALOG_AGC_H_ 134 | -------------------------------------------------------------------------------- /WebRtcMoudle/build/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Install shared libraries without execute permission? 31 | if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) 32 | set(CMAKE_INSTALL_SO_NO_EXE "1") 33 | endif() 34 | 35 | # Is this installation the result of a crosscompile? 36 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 37 | set(CMAKE_CROSSCOMPILING "FALSE") 38 | endif() 39 | 40 | if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT) 41 | if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libwebRTC.so" AND 42 | NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libwebRTC.so") 43 | file(RPATH_CHECK 44 | FILE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libwebRTC.so" 45 | RPATH "") 46 | endif() 47 | file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE SHARED_LIBRARY FILES "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/build/libwebRTC.so") 48 | if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libwebRTC.so" AND 49 | NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libwebRTC.so") 50 | if(CMAKE_INSTALL_DO_STRIP) 51 | execute_process(COMMAND "/usr/bin/strip" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libwebRTC.so") 52 | endif() 53 | endif() 54 | endif() 55 | 56 | if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT) 57 | file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/build/libwebRTC.a") 58 | endif() 59 | 60 | if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT) 61 | file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/include/webRtcModule" TYPE FILE FILES 62 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/analog_agc.h" 63 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/complex_fft_tables.h" 64 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/cpu_features_wrapper.h" 65 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/defines.h" 66 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/digital_agc.h" 67 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/fft4g.h" 68 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/gain_control.h" 69 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/noise_suppression.h" 70 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/noise_suppression_x.h" 71 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/ns_core.h" 72 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/nsx_core.h" 73 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/nsx_defines.h" 74 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/real_fft.h" 75 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/resample_by_2_internal.h" 76 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/ring_buffer.h" 77 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/signal_processing_library.h" 78 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/spl_inl.h" 79 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/typedefs.h" 80 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/windows_private.h" 81 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/aec_core.h" 82 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/aec_core_internal.h" 83 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/aec_rdft.h" 84 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/aec_resampler.h" 85 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/echo_cancellation.h" 86 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/echo_cancellation_internal.h" 87 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/delay_estimator.h" 88 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/delay_estimator_internal.h" 89 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/delay_estimator_wrapper.h" 90 | "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/ring_buffer.h" 91 | ) 92 | endif() 93 | 94 | if(CMAKE_INSTALL_COMPONENT) 95 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 96 | else() 97 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 98 | endif() 99 | 100 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 101 | "${CMAKE_INSTALL_MANIFEST_FILES}") 102 | file(WRITE "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/WebRtcMoudle/build/${CMAKE_INSTALL_MANIFEST}" 103 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 104 | -------------------------------------------------------------------------------- /WebRtcMoudle/build/install_manifest.txt: -------------------------------------------------------------------------------- 1 | /usr/lib/libwebRTC.so 2 | /usr/lib/libwebRTC.a 3 | /usr/include/webRtcModule/analog_agc.h 4 | /usr/include/webRtcModule/complex_fft_tables.h 5 | /usr/include/webRtcModule/cpu_features_wrapper.h 6 | /usr/include/webRtcModule/defines.h 7 | /usr/include/webRtcModule/digital_agc.h 8 | /usr/include/webRtcModule/fft4g.h 9 | /usr/include/webRtcModule/gain_control.h 10 | /usr/include/webRtcModule/noise_suppression.h 11 | /usr/include/webRtcModule/noise_suppression_x.h 12 | /usr/include/webRtcModule/ns_core.h 13 | /usr/include/webRtcModule/nsx_core.h 14 | /usr/include/webRtcModule/nsx_defines.h 15 | /usr/include/webRtcModule/real_fft.h 16 | /usr/include/webRtcModule/resample_by_2_internal.h 17 | /usr/include/webRtcModule/ring_buffer.h 18 | /usr/include/webRtcModule/signal_processing_library.h 19 | /usr/include/webRtcModule/spl_inl.h 20 | /usr/include/webRtcModule/typedefs.h 21 | /usr/include/webRtcModule/windows_private.h 22 | /usr/include/webRtcModule/aec_core.h 23 | /usr/include/webRtcModule/aec_core_internal.h 24 | /usr/include/webRtcModule/aec_rdft.h 25 | /usr/include/webRtcModule/aec_resampler.h 26 | /usr/include/webRtcModule/echo_cancellation.h 27 | /usr/include/webRtcModule/echo_cancellation_internal.h 28 | /usr/include/webRtcModule/delay_estimator.h 29 | /usr/include/webRtcModule/delay_estimator_internal.h 30 | /usr/include/webRtcModule/delay_estimator_wrapper.h 31 | /usr/include/webRtcModule/ring_buffer.h -------------------------------------------------------------------------------- /WebRtcMoudle/build/libwebRTC.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljl86400/webRTCtest/e812bbd08b5ba216c55011615ae4f400b7f7376f/WebRtcMoudle/build/libwebRTC.so -------------------------------------------------------------------------------- /WebRtcMoudle/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_INTERFACE_COMPILE_ASSERT_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_ 13 | 14 | // Only use this for C files. For C++, use compile_assert.h. 15 | // 16 | // Use this macro to verify at compile time that certain restrictions are met. 17 | // The argument is the boolean expression to evaluate. 18 | // Example: 19 | // COMPILE_ASSERT(sizeof(foo) < 128); 20 | #define COMPILE_ASSERT(expression) switch (0) {case 0: case expression:;} 21 | 22 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_ 23 | -------------------------------------------------------------------------------- /WebRtcMoudle/complex_bit_reverse.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 "signal_processing_library.h" 12 | 13 | /* Tables for data buffer indexes that are bit reversed and thus need to be 14 | * swapped. Note that, index_7[{0, 2, 4, ...}] are for the left side of the swap 15 | * operations, while index_7[{1, 3, 5, ...}] are for the right side of the 16 | * operation. Same for index_8. 17 | */ 18 | 19 | /* Indexes for the case of stages == 7. */ 20 | static const int16_t index_7[112] = { 21 | 1, 64, 2, 32, 3, 96, 4, 16, 5, 80, 6, 48, 7, 112, 9, 72, 10, 40, 11, 104, 22 | 12, 24, 13, 88, 14, 56, 15, 120, 17, 68, 18, 36, 19, 100, 21, 84, 22, 52, 23 | 23, 116, 25, 76, 26, 44, 27, 108, 29, 92, 30, 60, 31, 124, 33, 66, 35, 98, 24 | 37, 82, 38, 50, 39, 114, 41, 74, 43, 106, 45, 90, 46, 58, 47, 122, 49, 70, 25 | 51, 102, 53, 86, 55, 118, 57, 78, 59, 110, 61, 94, 63, 126, 67, 97, 69, 26 | 81, 71, 113, 75, 105, 77, 89, 79, 121, 83, 101, 87, 117, 91, 109, 95, 125, 27 | 103, 115, 111, 123 28 | }; 29 | 30 | /* Indexes for the case of stages == 8. */ 31 | static const int16_t index_8[240] = { 32 | 1, 128, 2, 64, 3, 192, 4, 32, 5, 160, 6, 96, 7, 224, 8, 16, 9, 144, 10, 80, 33 | 11, 208, 12, 48, 13, 176, 14, 112, 15, 240, 17, 136, 18, 72, 19, 200, 20, 34 | 40, 21, 168, 22, 104, 23, 232, 25, 152, 26, 88, 27, 216, 28, 56, 29, 184, 35 | 30, 120, 31, 248, 33, 132, 34, 68, 35, 196, 37, 164, 38, 100, 39, 228, 41, 36 | 148, 42, 84, 43, 212, 44, 52, 45, 180, 46, 116, 47, 244, 49, 140, 50, 76, 37 | 51, 204, 53, 172, 54, 108, 55, 236, 57, 156, 58, 92, 59, 220, 61, 188, 62, 38 | 124, 63, 252, 65, 130, 67, 194, 69, 162, 70, 98, 71, 226, 73, 146, 74, 82, 39 | 75, 210, 77, 178, 78, 114, 79, 242, 81, 138, 83, 202, 85, 170, 86, 106, 87, 40 | 234, 89, 154, 91, 218, 93, 186, 94, 122, 95, 250, 97, 134, 99, 198, 101, 41 | 166, 103, 230, 105, 150, 107, 214, 109, 182, 110, 118, 111, 246, 113, 142, 42 | 115, 206, 117, 174, 119, 238, 121, 158, 123, 222, 125, 190, 127, 254, 131, 43 | 193, 133, 161, 135, 225, 137, 145, 139, 209, 141, 177, 143, 241, 147, 201, 44 | 149, 169, 151, 233, 155, 217, 157, 185, 159, 249, 163, 197, 167, 229, 171, 45 | 213, 173, 181, 175, 245, 179, 205, 183, 237, 187, 221, 191, 253, 199, 227, 46 | 203, 211, 207, 243, 215, 235, 223, 251, 239, 247 47 | }; 48 | 49 | void WebRtcSpl_ComplexBitReverse(int16_t* __restrict complex_data, int stages) { 50 | /* For any specific value of stages, we know exactly the indexes that are 51 | * bit reversed. Currently (Feb. 2012) in WebRTC the only possible values of 52 | * stages are 7 and 8, so we use tables to save unnecessary iterations and 53 | * calculations for these two cases. 54 | */ 55 | if (stages == 7 || stages == 8) { 56 | int m = 0; 57 | int length = 112; 58 | const int16_t* index = index_7; 59 | 60 | if (stages == 8) { 61 | length = 240; 62 | index = index_8; 63 | } 64 | 65 | /* Decimation in time. Swap the elements with bit-reversed indexes. */ 66 | for (m = 0; m < length; m += 2) { 67 | /* We declare a int32_t* type pointer, to load both the 16-bit real 68 | * and imaginary elements from complex_data in one instruction, reducing 69 | * complexity. 70 | */ 71 | int32_t* complex_data_ptr = (int32_t*)complex_data; 72 | int32_t temp = 0; 73 | 74 | temp = complex_data_ptr[index[m]]; /* Real and imaginary */ 75 | complex_data_ptr[index[m]] = complex_data_ptr[index[m + 1]]; 76 | complex_data_ptr[index[m + 1]] = temp; 77 | } 78 | } 79 | else { 80 | int m = 0, mr = 0, l = 0; 81 | int n = 1 << stages; 82 | int nn = n - 1; 83 | 84 | /* Decimation in time - re-order data */ 85 | for (m = 1; m <= nn; ++m) { 86 | int32_t* complex_data_ptr = (int32_t*)complex_data; 87 | int32_t temp = 0; 88 | 89 | /* Find out indexes that are bit-reversed. */ 90 | l = n; 91 | do { 92 | l >>= 1; 93 | } while (l > nn - mr); 94 | mr = (mr & (l - 1)) + l; 95 | 96 | if (mr <= m) { 97 | continue; 98 | } 99 | 100 | /* Swap the elements with bit-reversed indexes. 101 | * This is similar to the loop in the stages == 7 or 8 cases. 102 | */ 103 | temp = complex_data_ptr[m]; /* Real and imaginary */ 104 | complex_data_ptr[m] = complex_data_ptr[mr]; 105 | complex_data_ptr[mr] = temp; 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /WebRtcMoudle/complex_fft_tables.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 | 12 | #ifndef WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_COMPLEX_FFT_TABLES_H_ 13 | #define WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_COMPLEX_FFT_TABLES_H_ 14 | 15 | #include "typedefs.h" 16 | 17 | static const int16_t kSinTable1024[] = { 18 | 0, 201, 402, 603, 804, 1005, 1206, 1406, 19 | 1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011, 20 | 3211, 3411, 3611, 3811, 4011, 4210, 4409, 4608, 21 | 4807, 5006, 5205, 5403, 5601, 5799, 5997, 6195, 22 | 6392, 6589, 6786, 6982, 7179, 7375, 7571, 7766, 23 | 7961, 8156, 8351, 8545, 8739, 8932, 9126, 9319, 24 | 9511, 9703, 9895, 10087, 10278, 10469, 10659, 10849, 25 | 11038, 11227, 11416, 11604, 11792, 11980, 12166, 12353, 26 | 12539, 12724, 12909, 13094, 13278, 13462, 13645, 13827, 27 | 14009, 14191, 14372, 14552, 14732, 14911, 15090, 15268, 28 | 15446, 15623, 15799, 15975, 16150, 16325, 16499, 16672, 29 | 16845, 17017, 17189, 17360, 17530, 17699, 17868, 18036, 30 | 18204, 18371, 18537, 18702, 18867, 19031, 19194, 19357, 31 | 19519, 19680, 19840, 20000, 20159, 20317, 20474, 20631, 32 | 20787, 20942, 21096, 21249, 21402, 21554, 21705, 21855, 33 | 22004, 22153, 22301, 22448, 22594, 22739, 22883, 23027, 34 | 23169, 23311, 23452, 23592, 23731, 23869, 24006, 24143, 35 | 24278, 24413, 24546, 24679, 24811, 24942, 25072, 25201, 36 | 25329, 25456, 25582, 25707, 25831, 25954, 26077, 26198, 37 | 26318, 26437, 26556, 26673, 26789, 26905, 27019, 27132, 38 | 27244, 27355, 27466, 27575, 27683, 27790, 27896, 28001, 39 | 28105, 28208, 28309, 28410, 28510, 28608, 28706, 28802, 40 | 28897, 28992, 29085, 29177, 29268, 29358, 29446, 29534, 41 | 29621, 29706, 29790, 29873, 29955, 30036, 30116, 30195, 42 | 30272, 30349, 30424, 30498, 30571, 30643, 30713, 30783, 43 | 30851, 30918, 30984, 31049, 31113, 31175, 31236, 31297, 44 | 31356, 31413, 31470, 31525, 31580, 31633, 31684, 31735, 45 | 31785, 31833, 31880, 31926, 31970, 32014, 32056, 32097, 46 | 32137, 32176, 32213, 32249, 32284, 32318, 32350, 32382, 47 | 32412, 32441, 32468, 32495, 32520, 32544, 32567, 32588, 48 | 32609, 32628, 32646, 32662, 32678, 32692, 32705, 32717, 49 | 32727, 32736, 32744, 32751, 32757, 32761, 32764, 32766, 50 | 32767, 32766, 32764, 32761, 32757, 32751, 32744, 32736, 51 | 32727, 32717, 32705, 32692, 32678, 32662, 32646, 32628, 52 | 32609, 32588, 32567, 32544, 32520, 32495, 32468, 32441, 53 | 32412, 32382, 32350, 32318, 32284, 32249, 32213, 32176, 54 | 32137, 32097, 32056, 32014, 31970, 31926, 31880, 31833, 55 | 31785, 31735, 31684, 31633, 31580, 31525, 31470, 31413, 56 | 31356, 31297, 31236, 31175, 31113, 31049, 30984, 30918, 57 | 30851, 30783, 30713, 30643, 30571, 30498, 30424, 30349, 58 | 30272, 30195, 30116, 30036, 29955, 29873, 29790, 29706, 59 | 29621, 29534, 29446, 29358, 29268, 29177, 29085, 28992, 60 | 28897, 28802, 28706, 28608, 28510, 28410, 28309, 28208, 61 | 28105, 28001, 27896, 27790, 27683, 27575, 27466, 27355, 62 | 27244, 27132, 27019, 26905, 26789, 26673, 26556, 26437, 63 | 26318, 26198, 26077, 25954, 25831, 25707, 25582, 25456, 64 | 25329, 25201, 25072, 24942, 24811, 24679, 24546, 24413, 65 | 24278, 24143, 24006, 23869, 23731, 23592, 23452, 23311, 66 | 23169, 23027, 22883, 22739, 22594, 22448, 22301, 22153, 67 | 22004, 21855, 21705, 21554, 21402, 21249, 21096, 20942, 68 | 20787, 20631, 20474, 20317, 20159, 20000, 19840, 19680, 69 | 19519, 19357, 19194, 19031, 18867, 18702, 18537, 18371, 70 | 18204, 18036, 17868, 17699, 17530, 17360, 17189, 17017, 71 | 16845, 16672, 16499, 16325, 16150, 15975, 15799, 15623, 72 | 15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191, 73 | 14009, 13827, 13645, 13462, 13278, 13094, 12909, 12724, 74 | 12539, 12353, 12166, 11980, 11792, 11604, 11416, 11227, 75 | 11038, 10849, 10659, 10469, 10278, 10087, 9895, 9703, 76 | 9511, 9319, 9126, 8932, 8739, 8545, 8351, 8156, 77 | 7961, 7766, 7571, 7375, 7179, 6982, 6786, 6589, 78 | 6392, 6195, 5997, 5799, 5601, 5403, 5205, 5006, 79 | 4807, 4608, 4409, 4210, 4011, 3811, 3611, 3411, 80 | 3211, 3011, 2811, 2610, 2410, 2209, 2009, 1808, 81 | 1607, 1406, 1206, 1005, 804, 603, 402, 201, 82 | 0, -201, -402, -603, -804, -1005, -1206, -1406, 83 | -1607, -1808, -2009, -2209, -2410, -2610, -2811, -3011, 84 | -3211, -3411, -3611, -3811, -4011, -4210, -4409, -4608, 85 | -4807, -5006, -5205, -5403, -5601, -5799, -5997, -6195, 86 | -6392, -6589, -6786, -6982, -7179, -7375, -7571, -7766, 87 | -7961, -8156, -8351, -8545, -8739, -8932, -9126, -9319, 88 | -9511, -9703, -9895, -10087, -10278, -10469, -10659, -10849, 89 | -11038, -11227, -11416, -11604, -11792, -11980, -12166, -12353, 90 | -12539, -12724, -12909, -13094, -13278, -13462, -13645, -13827, 91 | -14009, -14191, -14372, -14552, -14732, -14911, -15090, -15268, 92 | -15446, -15623, -15799, -15975, -16150, -16325, -16499, -16672, 93 | -16845, -17017, -17189, -17360, -17530, -17699, -17868, -18036, 94 | -18204, -18371, -18537, -18702, -18867, -19031, -19194, -19357, 95 | -19519, -19680, -19840, -20000, -20159, -20317, -20474, -20631, 96 | -20787, -20942, -21096, -21249, -21402, -21554, -21705, -21855, 97 | -22004, -22153, -22301, -22448, -22594, -22739, -22883, -23027, 98 | -23169, -23311, -23452, -23592, -23731, -23869, -24006, -24143, 99 | -24278, -24413, -24546, -24679, -24811, -24942, -25072, -25201, 100 | -25329, -25456, -25582, -25707, -25831, -25954, -26077, -26198, 101 | -26318, -26437, -26556, -26673, -26789, -26905, -27019, -27132, 102 | -27244, -27355, -27466, -27575, -27683, -27790, -27896, -28001, 103 | -28105, -28208, -28309, -28410, -28510, -28608, -28706, -28802, 104 | -28897, -28992, -29085, -29177, -29268, -29358, -29446, -29534, 105 | -29621, -29706, -29790, -29873, -29955, -30036, -30116, -30195, 106 | -30272, -30349, -30424, -30498, -30571, -30643, -30713, -30783, 107 | -30851, -30918, -30984, -31049, -31113, -31175, -31236, -31297, 108 | -31356, -31413, -31470, -31525, -31580, -31633, -31684, -31735, 109 | -31785, -31833, -31880, -31926, -31970, -32014, -32056, -32097, 110 | -32137, -32176, -32213, -32249, -32284, -32318, -32350, -32382, 111 | -32412, -32441, -32468, -32495, -32520, -32544, -32567, -32588, 112 | -32609, -32628, -32646, -32662, -32678, -32692, -32705, -32717, 113 | -32727, -32736, -32744, -32751, -32757, -32761, -32764, -32766, 114 | -32767, -32766, -32764, -32761, -32757, -32751, -32744, -32736, 115 | -32727, -32717, -32705, -32692, -32678, -32662, -32646, -32628, 116 | -32609, -32588, -32567, -32544, -32520, -32495, -32468, -32441, 117 | -32412, -32382, -32350, -32318, -32284, -32249, -32213, -32176, 118 | -32137, -32097, -32056, -32014, -31970, -31926, -31880, -31833, 119 | -31785, -31735, -31684, -31633, -31580, -31525, -31470, -31413, 120 | -31356, -31297, -31236, -31175, -31113, -31049, -30984, -30918, 121 | -30851, -30783, -30713, -30643, -30571, -30498, -30424, -30349, 122 | -30272, -30195, -30116, -30036, -29955, -29873, -29790, -29706, 123 | -29621, -29534, -29446, -29358, -29268, -29177, -29085, -28992, 124 | -28897, -28802, -28706, -28608, -28510, -28410, -28309, -28208, 125 | -28105, -28001, -27896, -27790, -27683, -27575, -27466, -27355, 126 | -27244, -27132, -27019, -26905, -26789, -26673, -26556, -26437, 127 | -26318, -26198, -26077, -25954, -25831, -25707, -25582, -25456, 128 | -25329, -25201, -25072, -24942, -24811, -24679, -24546, -24413, 129 | -24278, -24143, -24006, -23869, -23731, -23592, -23452, -23311, 130 | -23169, -23027, -22883, -22739, -22594, -22448, -22301, -22153, 131 | -22004, -21855, -21705, -21554, -21402, -21249, -21096, -20942, 132 | -20787, -20631, -20474, -20317, -20159, -20000, -19840, -19680, 133 | -19519, -19357, -19194, -19031, -18867, -18702, -18537, -18371, 134 | -18204, -18036, -17868, -17699, -17530, -17360, -17189, -17017, 135 | -16845, -16672, -16499, -16325, -16150, -15975, -15799, -15623, 136 | -15446, -15268, -15090, -14911, -14732, -14552, -14372, -14191, 137 | -14009, -13827, -13645, -13462, -13278, -13094, -12909, -12724, 138 | -12539, -12353, -12166, -11980, -11792, -11604, -11416, -11227, 139 | -11038, -10849, -10659, -10469, -10278, -10087, -9895, -9703, 140 | -9511, -9319, -9126, -8932, -8739, -8545, -8351, -8156, 141 | -7961, -7766, -7571, -7375, -7179, -6982, -6786, -6589, 142 | -6392, -6195, -5997, -5799, -5601, -5403, -5205, -5006, 143 | -4807, -4608, -4409, -4210, -4011, -3811, -3611, -3411, 144 | -3211, -3011, -2811, -2610, -2410, -2209, -2009, -1808, 145 | -1607, -1406, -1206, -1005, -804, -603, -402, -201 146 | }; 147 | 148 | #endif // WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_COMPLEX_FFT_TABLES_H_ 149 | -------------------------------------------------------------------------------- /WebRtcMoudle/copy_set_operations.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 implementation of functions 14 | * WebRtcSpl_MemSetW16() 15 | * WebRtcSpl_MemSetW32() 16 | * WebRtcSpl_MemCpyReversedOrder() 17 | * WebRtcSpl_CopyFromEndW16() 18 | * WebRtcSpl_ZerosArrayW16() 19 | * WebRtcSpl_ZerosArrayW32() 20 | * WebRtcSpl_OnesArrayW16() 21 | * WebRtcSpl_OnesArrayW32() 22 | * 23 | * The description header can be found in signal_processing_library.h 24 | * 25 | */ 26 | 27 | #include 28 | #include "signal_processing_library.h" 29 | 30 | 31 | void WebRtcSpl_MemSetW16(int16_t *ptr, int16_t set_value, int length) 32 | { 33 | int j; 34 | int16_t *arrptr = ptr; 35 | 36 | for (j = length; j > 0; j--) 37 | { 38 | *arrptr++ = set_value; 39 | } 40 | } 41 | 42 | void WebRtcSpl_MemSetW32(int32_t *ptr, int32_t set_value, int length) 43 | { 44 | int j; 45 | int32_t *arrptr = ptr; 46 | 47 | for (j = length; j > 0; j--) 48 | { 49 | *arrptr++ = set_value; 50 | } 51 | } 52 | 53 | void WebRtcSpl_MemCpyReversedOrder(int16_t* dest, int16_t* source, int length) 54 | { 55 | int j; 56 | int16_t* destPtr = dest; 57 | int16_t* sourcePtr = source; 58 | 59 | for (j = 0; j < length; j++) 60 | { 61 | *destPtr-- = *sourcePtr++; 62 | } 63 | } 64 | 65 | int16_t WebRtcSpl_CopyFromEndW16(const int16_t *vector_in, 66 | int16_t length, 67 | int16_t samples, 68 | int16_t *vector_out) 69 | { 70 | // Copy the last of the input vector to vector_out 71 | WEBRTC_SPL_MEMCPY_W16(vector_out, &vector_in[length - samples], samples); 72 | 73 | return samples; 74 | } 75 | 76 | int16_t WebRtcSpl_ZerosArrayW16(int16_t *vector, int16_t length) 77 | { 78 | WebRtcSpl_MemSetW16(vector, 0, length); 79 | return length; 80 | } 81 | 82 | int16_t WebRtcSpl_ZerosArrayW32(int32_t *vector, int16_t length) 83 | { 84 | WebRtcSpl_MemSetW32(vector, 0, length); 85 | return length; 86 | } 87 | 88 | int16_t WebRtcSpl_OnesArrayW16(int16_t *vector, int16_t length) 89 | { 90 | int16_t i; 91 | int16_t *tmpvec = vector; 92 | for (i = 0; i < length; i++) 93 | { 94 | *tmpvec++ = 1; 95 | } 96 | return length; 97 | } 98 | 99 | int16_t WebRtcSpl_OnesArrayW32(int32_t *vector, int16_t length) 100 | { 101 | int16_t i; 102 | int32_t *tmpvec = vector; 103 | for (i = 0; i < length; i++) 104 | { 105 | *tmpvec++ = 1; 106 | } 107 | return length; 108 | } 109 | -------------------------------------------------------------------------------- /WebRtcMoudle/cpu_features.cpp: -------------------------------------------------------------------------------- 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 "cpu_features_wrapper.h" 14 | 15 | #if defined(WEBRTC_ARCH_X86_FAMILY) && defined(_MSC_VER) 16 | #include 17 | #endif 18 | 19 | #include "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 | -------------------------------------------------------------------------------- /WebRtcMoudle/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_INTERFACE_CPU_FEATURES_WRAPPER_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_ 13 | 14 | #if defined(__cplusplus) || defined(c_plusplus) 15 | extern "C" { 16 | #endif 17 | 18 | #include "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_INTERFACE_CPU_FEATURES_WRAPPER_H_ 52 | -------------------------------------------------------------------------------- /WebRtcMoudle/cpu_info.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_INTERFACE_CPU_INFO_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_ 13 | 14 | #include "typedefs.h" 15 | 16 | namespace webrtc { 17 | 18 | class CpuInfo { 19 | public: 20 | static uint32_t DetectNumberOfCores(); 21 | 22 | private: 23 | CpuInfo() {} 24 | static uint32_t number_of_cores_; 25 | }; 26 | 27 | } // namespace webrtc 28 | 29 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_ 30 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "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 | int16_t dim_seq, 18 | int16_t dim_cross_correlation, 19 | int16_t right_shifts, 20 | int16_t step_seq2) { 21 | int i = 0, j = 0; 22 | 23 | for (i = 0; i < dim_cross_correlation; i++) { 24 | *cross_correlation = 0; 25 | /* Unrolling doesn't seem to improve performance. */ 26 | for (j = 0; j < dim_seq; j++) { 27 | *cross_correlation += (seq1[j] * seq2[step_seq2 * i + j]) >> right_shifts; 28 | } 29 | cross_correlation++; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /WebRtcMoudle/defines.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_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_ 13 | 14 | //#define PROCESS_FLOW_0 // Use the traditional method. 15 | //#define PROCESS_FLOW_1 // Use traditional with DD estimate of prior SNR. 16 | #define PROCESS_FLOW_2 // Use the new method of speech/noise classification. 17 | 18 | #define BLOCKL_MAX 160 // max processing block length: 160 19 | #define ANAL_BLOCKL_MAX 256 // max analysis block length: 256 20 | #define HALF_ANAL_BLOCKL 129 // half max analysis block length + 1 21 | 22 | #define QUANTILE (float)0.25 23 | 24 | #define SIMULT 3 25 | #define END_STARTUP_LONG 200 26 | #define END_STARTUP_SHORT 50 27 | #define FACTOR (float)40.0 28 | #define WIDTH (float)0.01 29 | 30 | #define SMOOTH (float)0.75 // filter smoothing 31 | // Length of fft work arrays. 32 | #define IP_LENGTH (ANAL_BLOCKL_MAX >> 1) // must be at least ceil(2 + sqrt(ANAL_BLOCKL_MAX/2)) 33 | #define W_LENGTH (ANAL_BLOCKL_MAX >> 1) 34 | 35 | //PARAMETERS FOR NEW METHOD 36 | #define DD_PR_SNR (float)0.98 // DD update of prior SNR 37 | #define LRT_TAVG (float)0.50 // tavg parameter for LRT (previously 0.90) 38 | #define SPECT_FL_TAVG (float)0.30 // tavg parameter for spectral flatness measure 39 | #define SPECT_DIFF_TAVG (float)0.30 // tavg parameter for spectral difference measure 40 | #define PRIOR_UPDATE (float)0.10 // update parameter of prior model 41 | #define NOISE_UPDATE (float)0.90 // update parameter for noise 42 | #define SPEECH_UPDATE (float)0.99 // update parameter when likely speech 43 | #define WIDTH_PR_MAP (float)4.0 // width parameter in sigmoid map for prior model 44 | #define LRT_FEATURE_THR (float)0.5 // default threshold for LRT feature 45 | #define SF_FEATURE_THR (float)0.5 // default threshold for Spectral Flatness feature 46 | #define SD_FEATURE_THR (float)0.5 // default threshold for Spectral Difference feature 47 | #define PROB_RANGE (float)0.20 // probability threshold for noise state in 48 | // speech/noise likelihood 49 | #define HIST_PAR_EST 1000 // histogram size for estimation of parameters 50 | #define GAMMA_PAUSE (float)0.05 // update for conservative noise estimate 51 | // 52 | #define B_LIM (float)0.5 // threshold in final energy gain factor calculation 53 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_ 54 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "delay_estimator.h" 17 | #include "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 | -------------------------------------------------------------------------------- /WebRtcMoudle/delay_estimator_wrapper.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 | // Performs delay estimation on block by block basis. 12 | // The return value is 0 - OK and -1 - Error, unless otherwise stated. 13 | 14 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_WRAPPER_H_ 15 | #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_WRAPPER_H_ 16 | 17 | #include "typedefs.h" 18 | 19 | // Releases the memory allocated by WebRtc_CreateDelayEstimatorFarend(...) 20 | // Input: 21 | // - handle : Pointer to the delay estimation far-end instance. 22 | // 23 | void WebRtc_FreeDelayEstimatorFarend(void* handle); 24 | 25 | // Allocates the memory needed by the far-end part of the delay estimation. The 26 | // memory needs to be initialized separately through 27 | // WebRtc_InitDelayEstimatorFarend(...). 28 | // 29 | // Inputs: 30 | // - spectrum_size : Size of the spectrum used both in far-end and 31 | // near-end. Used to allocate memory for spectrum 32 | // specific buffers. 33 | // - history_size : The far-end history buffer size. Note that the maximum 34 | // delay which can be estimated is controlled together 35 | // with |lookahead| through 36 | // WebRtc_CreateDelayEstimator(). 37 | // 38 | // Return value: 39 | // - void* : Created |handle|. If the memory can't be allocated or 40 | // if any of the input parameters are invalid NULL is 41 | // returned. 42 | // 43 | void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size); 44 | 45 | // Initializes the far-end part of the delay estimation instance returned by 46 | // WebRtc_CreateDelayEstimatorFarend(...) 47 | // Input: 48 | // - handle : Pointer to the delay estimation far-end instance. 49 | // 50 | // Output: 51 | // - handle : Initialized instance. 52 | // 53 | int WebRtc_InitDelayEstimatorFarend(void* handle); 54 | 55 | // Adds the far-end spectrum to the far-end history buffer. This spectrum is 56 | // used as reference when calculating the delay using 57 | // WebRtc_ProcessSpectrum(). 58 | // 59 | // Inputs: 60 | // - handle : Pointer to the delay estimation far-end instance. 61 | // - far_spectrum : Far-end spectrum. 62 | // - spectrum_size : The size of the data arrays (same for both far- and 63 | // near-end). 64 | // - far_q : The Q-domain of the far-end data. 65 | // 66 | // Output: 67 | // - handle : Updated far-end instance. 68 | // 69 | int WebRtc_AddFarSpectrumFix(void* handle, uint16_t* far_spectrum, 70 | int spectrum_size, int far_q); 71 | 72 | // See WebRtc_AddFarSpectrumFix() for description. 73 | int WebRtc_AddFarSpectrumFloat(void* handle, float* far_spectrum, 74 | int spectrum_size); 75 | 76 | // Releases the memory allocated by WebRtc_CreateDelayEstimator(...) 77 | // Input: 78 | // - handle : Pointer to the delay estimation instance. 79 | // 80 | void WebRtc_FreeDelayEstimator(void* handle); 81 | 82 | // Allocates the memory needed by the delay estimation. The memory needs to be 83 | // initialized separately through WebRtc_InitDelayEstimator(...). 84 | // 85 | // Inputs: 86 | // - farend_handle : Pointer to the far-end part of the delay estimation 87 | // instance created prior to this call using 88 | // WebRtc_CreateDelayEstimatorFarend(). 89 | // 90 | // Note that WebRtc_CreateDelayEstimator does not take 91 | // ownership of |farend_handle|, which has to be torn 92 | // down properly after this instance. 93 | // 94 | // - lookahead : Amount of non-causal lookahead to use. This can 95 | // detect cases in which a near-end signal occurs before 96 | // the corresponding far-end signal. It will delay the 97 | // estimate for the current block by an equal amount, 98 | // and the returned values will be offset by it. 99 | // 100 | // A value of zero is the typical no-lookahead case. 101 | // This also represents the minimum delay which can be 102 | // estimated. 103 | // 104 | // Note that the effective range of delay estimates is 105 | // [-|lookahead|,... ,|history_size|-|lookahead|) 106 | // where |history_size| was set upon creating the far-end 107 | // history buffer size. 108 | // 109 | // Return value: 110 | // - void* : Created |handle|. If the memory can't be allocated or 111 | // if any of the input parameters are invalid NULL is 112 | // returned. 113 | // 114 | void* WebRtc_CreateDelayEstimator(void* farend_handle, int lookahead); 115 | 116 | // Initializes the delay estimation instance returned by 117 | // WebRtc_CreateDelayEstimator(...) 118 | // Input: 119 | // - handle : Pointer to the delay estimation instance. 120 | // 121 | // Output: 122 | // - handle : Initialized instance. 123 | // 124 | int WebRtc_InitDelayEstimator(void* handle); 125 | 126 | // TODO(bjornv): Implement this functionality. Currently, enabling it has no 127 | // impact, hence this is an empty API. 128 | // Enables/Disables a robust validation functionality in the delay estimation. 129 | // This is by default disabled upon initialization. 130 | // Inputs: 131 | // - handle : Pointer to the delay estimation instance. 132 | // - enable : Enable (1) or disable (0) this feature. 133 | int WebRtc_enable_robust_validation(void* handle, int enable); 134 | 135 | // Returns 1 if robust validation is enabled and 0 if disabled. 136 | int WebRtc_is_robust_validation_enabled(void* handle); 137 | 138 | // Estimates and returns the delay between the far-end and near-end blocks. The 139 | // value will be offset by the lookahead (i.e. the lookahead should be 140 | // subtracted from the returned value). 141 | // Inputs: 142 | // - handle : Pointer to the delay estimation instance. 143 | // - near_spectrum : Pointer to the near-end spectrum data of the current 144 | // block. 145 | // - spectrum_size : The size of the data arrays (same for both far- and 146 | // near-end). 147 | // - near_q : The Q-domain of the near-end data. 148 | // 149 | // Output: 150 | // - handle : Updated instance. 151 | // 152 | // Return value: 153 | // - delay : >= 0 - Calculated delay value. 154 | // -1 - Error. 155 | // -2 - Insufficient data for estimation. 156 | // 157 | int WebRtc_DelayEstimatorProcessFix(void* handle, 158 | uint16_t* near_spectrum, 159 | int spectrum_size, 160 | int near_q); 161 | 162 | // See WebRtc_DelayEstimatorProcessFix() for description. 163 | int WebRtc_DelayEstimatorProcessFloat(void* handle, 164 | float* near_spectrum, 165 | int spectrum_size); 166 | 167 | // Returns the last calculated delay updated by the function 168 | // WebRtc_DelayEstimatorProcess(...). 169 | // 170 | // Input: 171 | // - handle : Pointer to the delay estimation instance. 172 | // 173 | // Return value: 174 | // - delay : >= 0 - Last calculated delay value. 175 | // -1 - Error. 176 | // -2 - Insufficient data for estimation. 177 | // 178 | int WebRtc_last_delay(void* handle); 179 | 180 | // Returns the estimation quality/probability of the last calculated delay 181 | // updated by the function WebRtc_DelayEstimatorProcess(...). The estimation 182 | // quality is a value in the interval [0, 1] in Q9. The higher the value, the 183 | // better quality. 184 | // 185 | // Input: 186 | // - handle : Pointer to the delay estimation instance. 187 | // 188 | // Return value: 189 | // - delay_quality : >= 0 - Estimation quality (in Q9) of last calculated 190 | // delay value. 191 | // -1 - Error. 192 | // -2 - Insufficient data for estimation. 193 | // 194 | int WebRtc_last_delay_quality(void* handle); 195 | 196 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_WRAPPER_H_ 197 | -------------------------------------------------------------------------------- /WebRtcMoudle/digital_agc.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_MODULES_AUDIO_PROCESSING_AGC_MAIN_SOURCE_DIGITAL_AGC_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_MAIN_SOURCE_DIGITAL_AGC_H_ 13 | 14 | #ifdef AGC_DEBUG 15 | #include 16 | #endif 17 | #include "signal_processing_library.h" 18 | #include "typedefs.h" 19 | 20 | // the 32 most significant bits of A(19) * B(26) >> 13 21 | #define AGC_MUL32(A, B) (((B)>>13)*(A) + ( ((0x00001FFF & (B))*(A)) >> 13 )) 22 | // C + the 32 most significant bits of A * B 23 | #define AGC_SCALEDIFF32(A, B, C) ((C) + ((B)>>16)*(A) + ( ((0x0000FFFF & (B))*(A)) >> 16 )) 24 | 25 | typedef struct 26 | { 27 | int32_t downState[8]; 28 | int16_t HPstate; 29 | int16_t counter; 30 | int16_t logRatio; // log( P(active) / P(inactive) ) (Q10) 31 | int16_t meanLongTerm; // Q10 32 | int32_t varianceLongTerm; // Q8 33 | int16_t stdLongTerm; // Q10 34 | int16_t meanShortTerm; // Q10 35 | int32_t varianceShortTerm; // Q8 36 | int16_t stdShortTerm; // Q10 37 | } AgcVad_t; // total = 54 bytes 38 | 39 | typedef struct 40 | { 41 | int32_t capacitorSlow; 42 | int32_t capacitorFast; 43 | int32_t gain; 44 | int32_t gainTable[32]; 45 | int16_t gatePrevious; 46 | int16_t agcMode; 47 | AgcVad_t vadNearend; 48 | AgcVad_t vadFarend; 49 | #ifdef AGC_DEBUG 50 | FILE* logFile; 51 | int frameCounter; 52 | #endif 53 | } DigitalAgc_t; 54 | 55 | int32_t WebRtcAgc_InitDigital(DigitalAgc_t *digitalAgcInst, int16_t agcMode); 56 | 57 | int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *digitalAgcInst, 58 | const int16_t *inNear, const int16_t *inNear_H, 59 | int16_t *out, int16_t *out_H, uint32_t FS, 60 | int16_t lowLevelSignal); 61 | 62 | int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc_t *digitalAgcInst, 63 | const int16_t *inFar, 64 | int16_t nrSamples); 65 | 66 | void WebRtcAgc_InitVad(AgcVad_t *vadInst); 67 | 68 | int16_t WebRtcAgc_ProcessVad(AgcVad_t *vadInst, // (i) VAD state 69 | const int16_t *in, // (i) Speech signal 70 | int16_t nrSamples); // (i) number of samples 71 | 72 | int32_t WebRtcAgc_CalculateGainTable(int32_t *gainTable, // Q16 73 | int16_t compressionGaindB, // Q0 (in dB) 74 | int16_t targetLevelDbfs,// Q0 (in dB) 75 | uint8_t limiterEnable, 76 | int16_t analogTarget); 77 | 78 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_MAIN_SOURCE_ANALOG_AGC_H_ 79 | -------------------------------------------------------------------------------- /WebRtcMoudle/division_operations.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 implementations of the divisions 14 | * WebRtcSpl_DivU32U16() 15 | * WebRtcSpl_DivW32W16() 16 | * WebRtcSpl_DivW32W16ResW16() 17 | * WebRtcSpl_DivResultInQ31() 18 | * WebRtcSpl_DivW32HiLow() 19 | * 20 | * The description header can be found in signal_processing_library.h 21 | * 22 | */ 23 | 24 | #include "signal_processing_library.h" 25 | 26 | uint32_t WebRtcSpl_DivU32U16(uint32_t num, uint16_t den) 27 | { 28 | // Guard against division with 0 29 | if (den != 0) 30 | { 31 | return (uint32_t)(num / den); 32 | } else 33 | { 34 | return (uint32_t)0xFFFFFFFF; 35 | } 36 | } 37 | 38 | int32_t WebRtcSpl_DivW32W16(int32_t num, int16_t den) 39 | { 40 | // Guard against division with 0 41 | if (den != 0) 42 | { 43 | return (int32_t)(num / den); 44 | } else 45 | { 46 | return (int32_t)0x7FFFFFFF; 47 | } 48 | } 49 | 50 | int16_t WebRtcSpl_DivW32W16ResW16(int32_t num, int16_t den) 51 | { 52 | // Guard against division with 0 53 | if (den != 0) 54 | { 55 | return (int16_t)(num / den); 56 | } else 57 | { 58 | return (int16_t)0x7FFF; 59 | } 60 | } 61 | 62 | int32_t WebRtcSpl_DivResultInQ31(int32_t num, int32_t den) 63 | { 64 | int32_t L_num = num; 65 | int32_t L_den = den; 66 | int32_t div = 0; 67 | int k = 31; 68 | int change_sign = 0; 69 | 70 | if (num == 0) 71 | return 0; 72 | 73 | if (num < 0) 74 | { 75 | change_sign++; 76 | L_num = -num; 77 | } 78 | if (den < 0) 79 | { 80 | change_sign++; 81 | L_den = -den; 82 | } 83 | while (k--) 84 | { 85 | div <<= 1; 86 | L_num <<= 1; 87 | if (L_num >= L_den) 88 | { 89 | L_num -= L_den; 90 | div++; 91 | } 92 | } 93 | if (change_sign == 1) 94 | { 95 | div = -div; 96 | } 97 | return div; 98 | } 99 | 100 | int32_t WebRtcSpl_DivW32HiLow(int32_t num, int16_t den_hi, int16_t den_low) 101 | { 102 | int16_t approx, tmp_hi, tmp_low, num_hi, num_low; 103 | int32_t tmpW32; 104 | 105 | approx = (int16_t)WebRtcSpl_DivW32W16((int32_t)0x1FFFFFFF, den_hi); 106 | // result in Q14 (Note: 3FFFFFFF = 0.5 in Q30) 107 | 108 | // tmpW32 = 1/den = approx * (2.0 - den * approx) (in Q30) 109 | tmpW32 = (WEBRTC_SPL_MUL_16_16(den_hi, approx) << 1) 110 | + ((WEBRTC_SPL_MUL_16_16(den_low, approx) >> 15) << 1); 111 | // tmpW32 = den * approx 112 | 113 | tmpW32 = (int32_t)0x7fffffffL - tmpW32; // result in Q30 (tmpW32 = 2.0-(den*approx)) 114 | 115 | // Store tmpW32 in hi and low format 116 | tmp_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmpW32, 16); 117 | tmp_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((tmpW32 118 | - WEBRTC_SPL_LSHIFT_W32((int32_t)tmp_hi, 16)), 1); 119 | 120 | // tmpW32 = 1/den in Q29 121 | tmpW32 = ((WEBRTC_SPL_MUL_16_16(tmp_hi, approx) + (WEBRTC_SPL_MUL_16_16(tmp_low, approx) 122 | >> 15)) << 1); 123 | 124 | // 1/den in hi and low format 125 | tmp_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmpW32, 16); 126 | tmp_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((tmpW32 127 | - WEBRTC_SPL_LSHIFT_W32((int32_t)tmp_hi, 16)), 1); 128 | 129 | // Store num in hi and low format 130 | num_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(num, 16); 131 | num_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((num 132 | - WEBRTC_SPL_LSHIFT_W32((int32_t)num_hi, 16)), 1); 133 | 134 | // num * (1/den) by 32 bit multiplication (result in Q28) 135 | 136 | tmpW32 = (WEBRTC_SPL_MUL_16_16(num_hi, tmp_hi) + (WEBRTC_SPL_MUL_16_16(num_hi, tmp_low) 137 | >> 15) + (WEBRTC_SPL_MUL_16_16(num_low, tmp_hi) >> 15)); 138 | 139 | // Put result in Q31 (convert from Q28) 140 | tmpW32 = WEBRTC_SPL_LSHIFT_W32(tmpW32, 3); 141 | 142 | return tmpW32; 143 | } 144 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "signal_processing_library.h" 12 | 13 | int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, 14 | const int16_t* vector2, 15 | int length, 16 | int scaling) { 17 | int32_t sum = 0; 18 | int i = 0; 19 | 20 | /* Unroll the loop to improve performance. */ 21 | for (i = 0; i < length - 3; 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 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "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 | int data_in_length, 17 | int16_t* data_out, 18 | int data_out_length, 19 | const int16_t* __restrict coefficients, 20 | int coefficients_length, 21 | int factor, 22 | int delay) { 23 | int i = 0; 24 | int j = 0; 25 | int32_t out_s32 = 0; 26 | int 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 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "aec_core.h" 15 | #include "ring_buffer.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 | RingBuffer* far_pre_buf_s16; // Time domain far-end pre-buffer in int16_t. 46 | FILE* bufFile; 47 | FILE* delayFile; 48 | FILE* skewFile; 49 | #endif 50 | 51 | // Structures 52 | void* resampler; 53 | 54 | int skewFrCtr; 55 | int resample; // if the skew is small enough we don't resample 56 | int highSkewCtr; 57 | float skew; 58 | 59 | RingBuffer* far_pre_buf; // Time domain far-end pre-buffer. 60 | 61 | int lastError; 62 | 63 | int farend_started; 64 | 65 | AecCore* aec; 66 | } aecpc_t; 67 | 68 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_ECHO_CANCELLATION_INTERNAL_H_ 69 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "signal_processing_library.h" 19 | 20 | int32_t WebRtcSpl_Energy(int16_t* vector, int vector_length, int* scale_factor) 21 | { 22 | int32_t en = 0; 23 | int i; 24 | int scaling = WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length); 25 | int looptimes = vector_length; 26 | int16_t *vectorptr = vector; 27 | 28 | for (i = 0; i < looptimes; i++) 29 | { 30 | en += WEBRTC_SPL_MUL_16_16_RSFT(*vectorptr, *vectorptr, scaling); 31 | vectorptr++; 32 | } 33 | *scale_factor = scaling; 34 | 35 | return en; 36 | } 37 | -------------------------------------------------------------------------------- /WebRtcMoudle/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_MODULES_AUDIO_PROCESSING_UTILITY_FFT4G_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_FFT4G_H_ 13 | 14 | void WebRtc_rdft(int, int, float *, int *, float *); 15 | void WebRtc_cdft(int, int, float *, int *, float *); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "signal_processing_library.h" 19 | 20 | int WebRtcSpl_GetScalingSquare(int16_t *in_vector, int in_vector_length, int times) 21 | { 22 | int nbits = WebRtcSpl_GetSizeInBits(times); 23 | int i; 24 | int16_t smax = -1; 25 | int16_t sabs; 26 | int16_t *sptr = in_vector; 27 | int t; 28 | int looptimes = in_vector_length; 29 | 30 | for (i = looptimes; i > 0; i--) 31 | { 32 | sabs = (*sptr > 0 ? *sptr++ : -*sptr++); 33 | smax = (sabs > smax ? sabs : smax); 34 | } 35 | t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); 36 | 37 | if (smax == 0) 38 | { 39 | return 0; // Since norm(0) returns 0 40 | } else 41 | { 42 | return (t > nbits) ? 0 : nbits - t; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /WebRtcMoudle/min_max_operations.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 | /* 12 | * This file contains the implementation of functions 13 | * WebRtcSpl_MaxAbsValueW16C() 14 | * WebRtcSpl_MaxAbsValueW32C() 15 | * WebRtcSpl_MaxValueW16C() 16 | * WebRtcSpl_MaxValueW32C() 17 | * WebRtcSpl_MinValueW16C() 18 | * WebRtcSpl_MinValueW32C() 19 | * WebRtcSpl_MaxAbsIndexW16() 20 | * WebRtcSpl_MaxIndexW16() 21 | * WebRtcSpl_MaxIndexW32() 22 | * WebRtcSpl_MinIndexW16() 23 | * WebRtcSpl_MinIndexW32() 24 | * 25 | */ 26 | 27 | #include "signal_processing_library.h" 28 | 29 | #include 30 | 31 | // TODO(bjorn/kma): Consolidate function pairs (e.g. combine 32 | // WebRtcSpl_MaxAbsValueW16C and WebRtcSpl_MaxAbsIndexW16 into a single one.) 33 | // TODO(kma): Move the next six functions into min_max_operations_c.c. 34 | 35 | // Maximum absolute value of word16 vector. C version for generic platforms. 36 | int16_t WebRtcSpl_MaxAbsValueW16C(const int16_t* vector, int length) { 37 | int i = 0, absolute = 0, maximum = 0; 38 | 39 | if (vector == NULL || length <= 0) { 40 | return -1; 41 | } 42 | 43 | for (i = 0; i < length; i++) { 44 | absolute = abs((int)vector[i]); 45 | 46 | if (absolute > maximum) { 47 | maximum = absolute; 48 | } 49 | } 50 | 51 | // Guard the case for abs(-32768). 52 | if (maximum > WEBRTC_SPL_WORD16_MAX) { 53 | maximum = WEBRTC_SPL_WORD16_MAX; 54 | } 55 | 56 | return (int16_t)maximum; 57 | } 58 | 59 | // Maximum absolute value of word32 vector. C version for generic platforms. 60 | int32_t WebRtcSpl_MaxAbsValueW32C(const int32_t* vector, int length) { 61 | // Use uint32_t for the local variables, to accommodate the return value 62 | // of abs(0x80000000), which is 0x80000000. 63 | 64 | uint32_t absolute = 0, maximum = 0; 65 | int i = 0; 66 | 67 | if (vector == NULL || length <= 0) { 68 | return -1; 69 | } 70 | 71 | for (i = 0; i < length; i++) { 72 | absolute = abs((int)vector[i]); 73 | if (absolute > maximum) { 74 | maximum = absolute; 75 | } 76 | } 77 | 78 | maximum = WEBRTC_SPL_MIN(maximum, WEBRTC_SPL_WORD32_MAX); 79 | 80 | return (int32_t)maximum; 81 | } 82 | 83 | // Maximum value of word16 vector. C version for generic platforms. 84 | int16_t WebRtcSpl_MaxValueW16C(const int16_t* vector, int length) { 85 | int16_t maximum = WEBRTC_SPL_WORD16_MIN; 86 | int i = 0; 87 | 88 | if (vector == NULL || length <= 0) { 89 | return maximum; 90 | } 91 | 92 | for (i = 0; i < length; i++) { 93 | if (vector[i] > maximum) 94 | maximum = vector[i]; 95 | } 96 | return maximum; 97 | } 98 | 99 | // Maximum value of word32 vector. C version for generic platforms. 100 | int32_t WebRtcSpl_MaxValueW32C(const int32_t* vector, int length) { 101 | int32_t maximum = WEBRTC_SPL_WORD32_MIN; 102 | int i = 0; 103 | 104 | if (vector == NULL || length <= 0) { 105 | return maximum; 106 | } 107 | 108 | for (i = 0; i < length; i++) { 109 | if (vector[i] > maximum) 110 | maximum = vector[i]; 111 | } 112 | return maximum; 113 | } 114 | 115 | // Minimum value of word16 vector. C version for generic platforms. 116 | int16_t WebRtcSpl_MinValueW16C(const int16_t* vector, int length) { 117 | int16_t minimum = WEBRTC_SPL_WORD16_MAX; 118 | int i = 0; 119 | 120 | if (vector == NULL || length <= 0) { 121 | return minimum; 122 | } 123 | 124 | for (i = 0; i < length; i++) { 125 | if (vector[i] < minimum) 126 | minimum = vector[i]; 127 | } 128 | return minimum; 129 | } 130 | 131 | // Minimum value of word32 vector. C version for generic platforms. 132 | int32_t WebRtcSpl_MinValueW32C(const int32_t* vector, int length) { 133 | int32_t minimum = WEBRTC_SPL_WORD32_MAX; 134 | int i = 0; 135 | 136 | if (vector == NULL || length <= 0) { 137 | return minimum; 138 | } 139 | 140 | for (i = 0; i < length; i++) { 141 | if (vector[i] < minimum) 142 | minimum = vector[i]; 143 | } 144 | return minimum; 145 | } 146 | 147 | // Index of maximum absolute value in a word16 vector. 148 | int WebRtcSpl_MaxAbsIndexW16(const int16_t* vector, int length) { 149 | // Use type int for local variables, to accomodate the value of abs(-32768). 150 | 151 | int i = 0, absolute = 0, maximum = 0, index = 0; 152 | 153 | if (vector == NULL || length <= 0) { 154 | return -1; 155 | } 156 | 157 | for (i = 0; i < length; i++) { 158 | absolute = abs((int)vector[i]); 159 | 160 | if (absolute > maximum) { 161 | maximum = absolute; 162 | index = i; 163 | } 164 | } 165 | 166 | return index; 167 | } 168 | 169 | // Index of maximum value in a word16 vector. 170 | int WebRtcSpl_MaxIndexW16(const int16_t* vector, int length) { 171 | int i = 0, index = 0; 172 | int16_t maximum = WEBRTC_SPL_WORD16_MIN; 173 | 174 | if (vector == NULL || length <= 0) { 175 | return -1; 176 | } 177 | 178 | for (i = 0; i < length; i++) { 179 | if (vector[i] > maximum) { 180 | maximum = vector[i]; 181 | index = i; 182 | } 183 | } 184 | 185 | return index; 186 | } 187 | 188 | // Index of maximum value in a word32 vector. 189 | int WebRtcSpl_MaxIndexW32(const int32_t* vector, int length) { 190 | int i = 0, index = 0; 191 | int32_t maximum = WEBRTC_SPL_WORD32_MIN; 192 | 193 | if (vector == NULL || length <= 0) { 194 | return -1; 195 | } 196 | 197 | for (i = 0; i < length; i++) { 198 | if (vector[i] > maximum) { 199 | maximum = vector[i]; 200 | index = i; 201 | } 202 | } 203 | 204 | return index; 205 | } 206 | 207 | // Index of minimum value in a word16 vector. 208 | int WebRtcSpl_MinIndexW16(const int16_t* vector, int length) { 209 | int i = 0, index = 0; 210 | int16_t minimum = WEBRTC_SPL_WORD16_MAX; 211 | 212 | if (vector == NULL || length <= 0) { 213 | return -1; 214 | } 215 | 216 | for (i = 0; i < length; i++) { 217 | if (vector[i] < minimum) { 218 | minimum = vector[i]; 219 | index = i; 220 | } 221 | } 222 | 223 | return index; 224 | } 225 | 226 | // Index of minimum value in a word32 vector. 227 | int WebRtcSpl_MinIndexW32(const int32_t* vector, int length) { 228 | int i = 0, index = 0; 229 | int32_t minimum = WEBRTC_SPL_WORD32_MAX; 230 | 231 | if (vector == NULL || length <= 0) { 232 | return -1; 233 | } 234 | 235 | for (i = 0; i < length; i++) { 236 | if (vector[i] < minimum) { 237 | minimum = vector[i]; 238 | index = i; 239 | } 240 | } 241 | 242 | return index; 243 | } 244 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "noise_suppression.h" 12 | 13 | #include 14 | #include 15 | 16 | #include "signal_processing_library.h" 17 | #include "defines.h" 18 | #include "ns_core.h" 19 | 20 | int WebRtcNs_Create(NsHandle** NS_inst) { 21 | *NS_inst = (NsHandle*) malloc(sizeof(NSinst_t)); 22 | if (*NS_inst != NULL) { 23 | (*(NSinst_t**)NS_inst)->initFlag = 0; 24 | return 0; 25 | } else { 26 | return -1; 27 | } 28 | 29 | } 30 | 31 | int WebRtcNs_Free(NsHandle* NS_inst) { 32 | free(NS_inst); 33 | return 0; 34 | } 35 | 36 | 37 | int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs) { 38 | return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs); 39 | } 40 | 41 | int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) { 42 | return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode); 43 | } 44 | 45 | 46 | int WebRtcNs_Process(NsHandle* NS_inst, short* spframe, short* spframe_H, 47 | short* outframe, short* outframe_H) { 48 | return WebRtcNs_ProcessCore( 49 | (NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H); 50 | } 51 | 52 | float WebRtcNs_prior_speech_probability(NsHandle* handle) { 53 | NSinst_t* self = (NSinst_t*) handle; 54 | if (handle == NULL) { 55 | return -1; 56 | } 57 | if (self->initFlag == 0) { 58 | return -1; 59 | } 60 | return self->priorSpeechProb; 61 | } 62 | -------------------------------------------------------------------------------- /WebRtcMoudle/noise_suppression.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_NS_INCLUDE_NOISE_SUPPRESSION_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_H_ 13 | 14 | #include "typedefs.h" 15 | 16 | typedef struct NsHandleT NsHandle; 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /* 23 | * This function creates an instance to the noise suppression structure 24 | * 25 | * Input: 26 | * - NS_inst : Pointer to noise suppression instance that should be 27 | * created 28 | * 29 | * Output: 30 | * - NS_inst : Pointer to created noise suppression instance 31 | * 32 | * Return value : 0 - Ok 33 | * -1 - Error 34 | */ 35 | int WebRtcNs_Create(NsHandle** NS_inst); 36 | 37 | 38 | /* 39 | * This function frees the dynamic memory of a specified noise suppression 40 | * instance. 41 | * 42 | * Input: 43 | * - NS_inst : Pointer to NS instance that should be freed 44 | * 45 | * Return value : 0 - Ok 46 | * -1 - Error 47 | */ 48 | int WebRtcNs_Free(NsHandle* NS_inst); 49 | 50 | 51 | /* 52 | * This function initializes a NS instance and has to be called before any other 53 | * processing is made. 54 | * 55 | * Input: 56 | * - NS_inst : Instance that should be initialized 57 | * - fs : sampling frequency 58 | * 59 | * Output: 60 | * - NS_inst : Initialized instance 61 | * 62 | * Return value : 0 - Ok 63 | * -1 - Error 64 | */ 65 | int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs); 66 | 67 | /* 68 | * This changes the aggressiveness of the noise suppression method. 69 | * 70 | * Input: 71 | * - NS_inst : Noise suppression instance. 72 | * - mode : 0: Mild, 1: Medium , 2: Aggressive 73 | * 74 | * Output: 75 | * - NS_inst : Updated instance. 76 | * 77 | * Return value : 0 - Ok 78 | * -1 - Error 79 | */ 80 | int WebRtcNs_set_policy(NsHandle* NS_inst, int mode); 81 | 82 | 83 | /* 84 | * This functions does Noise Suppression for the inserted speech frame. The 85 | * input and output signals should always be 10ms (80 or 160 samples). 86 | * 87 | * Input 88 | * - NS_inst : Noise suppression instance. 89 | * - spframe : Pointer to speech frame buffer for L band 90 | * - spframe_H : Pointer to speech frame buffer for H band 91 | * - fs : sampling frequency 92 | * 93 | * Output: 94 | * - NS_inst : Updated NS instance 95 | * - outframe : Pointer to output frame for L band 96 | * - outframe_H : Pointer to output frame for H band 97 | * 98 | * Return value : 0 - OK 99 | * -1 - Error 100 | */ 101 | int WebRtcNs_Process(NsHandle* NS_inst, 102 | short* spframe, 103 | short* spframe_H, 104 | short* outframe, 105 | short* outframe_H); 106 | 107 | /* Returns the internally used prior speech probability of the current frame. 108 | * There is a frequency bin based one as well, with which this should not be 109 | * confused. 110 | * 111 | * Input 112 | * - handle : Noise suppression instance. 113 | * 114 | * Return value : Prior speech probability in interval [0.0, 1.0]. 115 | * -1 - NULL pointer or uninitialized instance. 116 | */ 117 | float WebRtcNs_prior_speech_probability(NsHandle* handle); 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_H_ 124 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "noise_suppression_x.h" 12 | 13 | #include 14 | 15 | #include "real_fft.h" 16 | #include "nsx_core.h" 17 | #include "nsx_defines.h" 18 | 19 | int WebRtcNsx_Create(NsxHandle** nsxInst) { 20 | NsxInst_t* self = malloc(sizeof(NsxInst_t)); 21 | *nsxInst = (NsxHandle*)self; 22 | 23 | if (self != NULL) { 24 | WebRtcSpl_Init(); 25 | self->real_fft = NULL; 26 | self->initFlag = 0; 27 | return 0; 28 | } else { 29 | return -1; 30 | } 31 | 32 | } 33 | 34 | int WebRtcNsx_Free(NsxHandle* nsxInst) { 35 | WebRtcSpl_FreeRealFFT(((NsxInst_t*)nsxInst)->real_fft); 36 | free(nsxInst); 37 | return 0; 38 | } 39 | 40 | int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs) { 41 | return WebRtcNsx_InitCore((NsxInst_t*)nsxInst, fs); 42 | } 43 | 44 | int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode) { 45 | return WebRtcNsx_set_policy_core((NsxInst_t*)nsxInst, mode); 46 | } 47 | 48 | int WebRtcNsx_Process(NsxHandle* nsxInst, short* speechFrame, 49 | short* speechFrameHB, short* outFrame, 50 | short* outFrameHB) { 51 | return WebRtcNsx_ProcessCore( 52 | (NsxInst_t*)nsxInst, speechFrame, speechFrameHB, outFrame, outFrameHB); 53 | } 54 | -------------------------------------------------------------------------------- /WebRtcMoudle/noise_suppression_x.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_NS_INCLUDE_NOISE_SUPPRESSION_X_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_X_H_ 13 | 14 | #include "typedefs.h" 15 | 16 | typedef struct NsxHandleT NsxHandle; 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /* 23 | * This function creates an instance to the noise reduction structure 24 | * 25 | * Input: 26 | * - nsxInst : Pointer to noise reduction instance that should be 27 | * created 28 | * 29 | * Output: 30 | * - nsxInst : Pointer to created noise reduction instance 31 | * 32 | * Return value : 0 - Ok 33 | * -1 - Error 34 | */ 35 | int WebRtcNsx_Create(NsxHandle** nsxInst); 36 | 37 | 38 | /* 39 | * This function frees the dynamic memory of a specified Noise Suppression 40 | * instance. 41 | * 42 | * Input: 43 | * - nsxInst : Pointer to NS instance that should be freed 44 | * 45 | * Return value : 0 - Ok 46 | * -1 - Error 47 | */ 48 | int WebRtcNsx_Free(NsxHandle* nsxInst); 49 | 50 | 51 | /* 52 | * This function initializes a NS instance 53 | * 54 | * Input: 55 | * - nsxInst : Instance that should be initialized 56 | * - fs : sampling frequency 57 | * 58 | * Output: 59 | * - nsxInst : Initialized instance 60 | * 61 | * Return value : 0 - Ok 62 | * -1 - Error 63 | */ 64 | int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs); 65 | 66 | /* 67 | * This changes the aggressiveness of the noise suppression method. 68 | * 69 | * Input: 70 | * - nsxInst : Instance that should be initialized 71 | * - mode : 0: Mild, 1: Medium , 2: Aggressive 72 | * 73 | * Output: 74 | * - nsxInst : Initialized instance 75 | * 76 | * Return value : 0 - Ok 77 | * -1 - Error 78 | */ 79 | int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode); 80 | 81 | /* 82 | * This functions does noise suppression for the inserted speech frame. The 83 | * input and output signals should always be 10ms (80 or 160 samples). 84 | * 85 | * Input 86 | * - nsxInst : NSx instance. Needs to be initiated before call. 87 | * - speechFrame : Pointer to speech frame buffer for L band 88 | * - speechFrameHB : Pointer to speech frame buffer for H band 89 | * - fs : sampling frequency 90 | * 91 | * Output: 92 | * - nsxInst : Updated NSx instance 93 | * - outFrame : Pointer to output frame for L band 94 | * - outFrameHB : Pointer to output frame for H band 95 | * 96 | * Return value : 0 - OK 97 | * -1 - Error 98 | */ 99 | int WebRtcNsx_Process(NsxHandle* nsxInst, 100 | short* speechFrame, 101 | short* speechFrameHB, 102 | short* outFrame, 103 | short* outFrameHB); 104 | 105 | #ifdef __cplusplus 106 | } 107 | #endif 108 | 109 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_X_H_ 110 | -------------------------------------------------------------------------------- /WebRtcMoudle/ns_core.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_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NS_CORE_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NS_CORE_H_ 13 | 14 | #include "defines.h" 15 | 16 | typedef struct NSParaExtract_t_ { 17 | 18 | //bin size of histogram 19 | float binSizeLrt; 20 | float binSizeSpecFlat; 21 | float binSizeSpecDiff; 22 | //range of histogram over which lrt threshold is computed 23 | float rangeAvgHistLrt; 24 | //scale parameters: multiply dominant peaks of the histograms by scale factor to obtain 25 | //thresholds for prior model 26 | float factor1ModelPars; //for lrt and spectral difference 27 | float factor2ModelPars; //for spectral_flatness: used when noise is flatter than speech 28 | //peak limit for spectral flatness (varies between 0 and 1) 29 | float thresPosSpecFlat; 30 | //limit on spacing of two highest peaks in histogram: spacing determined by bin size 31 | float limitPeakSpacingSpecFlat; 32 | float limitPeakSpacingSpecDiff; 33 | //limit on relevance of second peak: 34 | float limitPeakWeightsSpecFlat; 35 | float limitPeakWeightsSpecDiff; 36 | //limit on fluctuation of lrt feature 37 | float thresFluctLrt; 38 | //limit on the max and min values for the feature thresholds 39 | float maxLrt; 40 | float minLrt; 41 | float maxSpecFlat; 42 | float minSpecFlat; 43 | float maxSpecDiff; 44 | float minSpecDiff; 45 | //criteria of weight of histogram peak to accept/reject feature 46 | int thresWeightSpecFlat; 47 | int thresWeightSpecDiff; 48 | 49 | } NSParaExtract_t; 50 | 51 | typedef struct NSinst_t_ { 52 | 53 | uint32_t fs; 54 | int blockLen; 55 | int blockLen10ms; 56 | int windShift; 57 | int outLen; 58 | int anaLen; 59 | int magnLen; 60 | int aggrMode; 61 | const float* window; 62 | float dataBuf[ANAL_BLOCKL_MAX]; 63 | float syntBuf[ANAL_BLOCKL_MAX]; 64 | float outBuf[3 * BLOCKL_MAX]; 65 | 66 | int initFlag; 67 | // parameters for quantile noise estimation 68 | float density[SIMULT* HALF_ANAL_BLOCKL]; 69 | float lquantile[SIMULT* HALF_ANAL_BLOCKL]; 70 | float quantile[HALF_ANAL_BLOCKL]; 71 | int counter[SIMULT]; 72 | int updates; 73 | // parameters for Wiener filter 74 | float smooth[HALF_ANAL_BLOCKL]; 75 | float overdrive; 76 | float denoiseBound; 77 | int gainmap; 78 | // fft work arrays. 79 | int ip[IP_LENGTH]; 80 | float wfft[W_LENGTH]; 81 | 82 | // parameters for new method: some not needed, will reduce/cleanup later 83 | int32_t blockInd; //frame index counter 84 | int modelUpdatePars[4]; //parameters for updating or estimating 85 | // thresholds/weights for prior model 86 | float priorModelPars[7]; //parameters for prior model 87 | float noisePrev[HALF_ANAL_BLOCKL]; //noise spectrum from previous frame 88 | float magnPrev[HALF_ANAL_BLOCKL]; //magnitude spectrum of previous frame 89 | float logLrtTimeAvg[HALF_ANAL_BLOCKL]; //log lrt factor with time-smoothing 90 | float priorSpeechProb; //prior speech/noise probability 91 | float featureData[7]; //data for features 92 | float magnAvgPause[HALF_ANAL_BLOCKL]; //conservative noise spectrum estimate 93 | float signalEnergy; //energy of magn 94 | float sumMagn; //sum of magn 95 | float whiteNoiseLevel; //initial noise estimate 96 | float initMagnEst[HALF_ANAL_BLOCKL]; //initial magnitude spectrum estimate 97 | float pinkNoiseNumerator; //pink noise parameter: numerator 98 | float pinkNoiseExp; //pink noise parameter: power of freq 99 | NSParaExtract_t featureExtractionParams; //parameters for feature extraction 100 | //histograms for parameter estimation 101 | int histLrt[HIST_PAR_EST]; 102 | int histSpecFlat[HIST_PAR_EST]; 103 | int histSpecDiff[HIST_PAR_EST]; 104 | //quantities for high band estimate 105 | float speechProbHB[HALF_ANAL_BLOCKL]; //final speech/noise prob: prior + LRT 106 | float dataBufHB[ANAL_BLOCKL_MAX]; //buffering data for HB 107 | 108 | } NSinst_t; 109 | 110 | 111 | #ifdef __cplusplus 112 | extern "C" { 113 | #endif 114 | 115 | /**************************************************************************** 116 | * WebRtcNs_InitCore(...) 117 | * 118 | * This function initializes a noise suppression instance 119 | * 120 | * Input: 121 | * - inst : Instance that should be initialized 122 | * - fs : Sampling frequency 123 | * 124 | * Output: 125 | * - inst : Initialized instance 126 | * 127 | * Return value : 0 - Ok 128 | * -1 - Error 129 | */ 130 | int WebRtcNs_InitCore(NSinst_t* inst, uint32_t fs); 131 | 132 | /**************************************************************************** 133 | * WebRtcNs_set_policy_core(...) 134 | * 135 | * This changes the aggressiveness of the noise suppression method. 136 | * 137 | * Input: 138 | * - inst : Instance that should be initialized 139 | * - mode : 0: Mild (6 dB), 1: Medium (10 dB), 2: Aggressive (15 dB) 140 | * 141 | * Output: 142 | * - NS_inst : Initialized instance 143 | * 144 | * Return value : 0 - Ok 145 | * -1 - Error 146 | */ 147 | int WebRtcNs_set_policy_core(NSinst_t* inst, int mode); 148 | 149 | /**************************************************************************** 150 | * WebRtcNs_ProcessCore 151 | * 152 | * Do noise suppression. 153 | * 154 | * Input: 155 | * - inst : Instance that should be initialized 156 | * - inFrameLow : Input speech frame for lower band 157 | * - inFrameHigh : Input speech frame for higher band 158 | * 159 | * Output: 160 | * - inst : Updated instance 161 | * - outFrameLow : Output speech frame for lower band 162 | * - outFrameHigh : Output speech frame for higher band 163 | * 164 | * Return value : 0 - OK 165 | * -1 - Error 166 | */ 167 | 168 | 169 | int WebRtcNs_ProcessCore(NSinst_t* inst, 170 | short* inFrameLow, 171 | short* inFrameHigh, 172 | short* outFrameLow, 173 | short* outFrameHigh); 174 | 175 | 176 | #ifdef __cplusplus 177 | } 178 | #endif 179 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NS_CORE_H_ 180 | -------------------------------------------------------------------------------- /WebRtcMoudle/nsx_core_neon_offsets.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 "nsx_core.h" 12 | 13 | #include 14 | 15 | // Define offset variables that will be compiled and abstracted to constant 16 | // defines, which will then only be used in ARM assembly code. 17 | int offset_nsx_anaLen = offsetof(NsxInst_t, anaLen); 18 | int offset_nsx_anaLen2 = offsetof(NsxInst_t, anaLen2); 19 | int offset_nsx_normData = offsetof(NsxInst_t, normData); 20 | int offset_nsx_analysisBuffer = offsetof(NsxInst_t, analysisBuffer); 21 | int offset_nsx_synthesisBuffer = offsetof(NsxInst_t, synthesisBuffer); 22 | int offset_nsx_blockLen10ms = offsetof(NsxInst_t, blockLen10ms); 23 | int offset_nsx_window = offsetof(NsxInst_t, window); 24 | int offset_nsx_real = offsetof(NsxInst_t, real); 25 | int offset_nsx_imag = offsetof(NsxInst_t, imag); 26 | int offset_nsx_noiseSupFilter = offsetof(NsxInst_t, noiseSupFilter); 27 | int offset_nsx_magnLen = offsetof(NsxInst_t, magnLen); 28 | int offset_nsx_noiseEstLogQuantile = offsetof(NsxInst_t, noiseEstLogQuantile); 29 | int offset_nsx_noiseEstQuantile = offsetof(NsxInst_t, noiseEstQuantile); 30 | int offset_nsx_qNoise = offsetof(NsxInst_t, qNoise); 31 | int offset_nsx_stages = offsetof(NsxInst_t, stages); 32 | int offset_nsx_blockIndex = offsetof(NsxInst_t, blockIndex); 33 | int offset_nsx_noiseEstCounter = offsetof(NsxInst_t, noiseEstCounter); 34 | int offset_nsx_noiseEstDensity = offsetof(NsxInst_t, noiseEstDensity); 35 | -------------------------------------------------------------------------------- /WebRtcMoudle/nsx_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_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ 13 | 14 | #define ANAL_BLOCKL_MAX 256 /* Max analysis block length */ 15 | #define HALF_ANAL_BLOCKL 129 /* Half max analysis block length + 1 */ 16 | #define SIMULT 3 17 | #define END_STARTUP_LONG 200 18 | #define END_STARTUP_SHORT 50 19 | #define FACTOR_Q16 2621440 /* 40 in Q16 */ 20 | #define FACTOR_Q7 5120 /* 40 in Q7 */ 21 | #define FACTOR_Q7_STARTUP 1024 /* 8 in Q7 */ 22 | #define WIDTH_Q8 3 /* 0.01 in Q8 (or 25 ) */ 23 | 24 | /* PARAMETERS FOR NEW METHOD */ 25 | #define DD_PR_SNR_Q11 2007 /* ~= Q11(0.98) DD update of prior SNR */ 26 | #define ONE_MINUS_DD_PR_SNR_Q11 41 /* DD update of prior SNR */ 27 | #define SPECT_FLAT_TAVG_Q14 4915 /* (0.30) tavg parameter for spectral flatness measure */ 28 | #define SPECT_DIFF_TAVG_Q8 77 /* (0.30) tavg parameter for spectral flatness measure */ 29 | #define PRIOR_UPDATE_Q14 1638 /* Q14(0.1) Update parameter of prior model */ 30 | #define NOISE_UPDATE_Q8 26 /* 26 ~= Q8(0.1) Update parameter for noise */ 31 | 32 | /* Probability threshold for noise state in speech/noise likelihood. */ 33 | #define ONE_MINUS_PROB_RANGE_Q8 205 /* 205 ~= Q8(0.8) */ 34 | #define HIST_PAR_EST 1000 /* Histogram size for estimation of parameters */ 35 | 36 | /* FEATURE EXTRACTION CONFIG */ 37 | /* Bin size of histogram */ 38 | #define BIN_SIZE_LRT 10 39 | /* Scale parameters: multiply dominant peaks of the histograms by scale factor to obtain. */ 40 | /* Thresholds for prior model */ 41 | #define FACTOR_1_LRT_DIFF 6 /* For LRT and spectral difference (5 times bigger) */ 42 | /* For spectral_flatness: used when noise is flatter than speech (10 times bigger). */ 43 | #define FACTOR_2_FLAT_Q10 922 44 | /* Peak limit for spectral flatness (varies between 0 and 1) */ 45 | #define THRES_PEAK_FLAT 24 /* * 2 * BIN_SIZE_FLAT_FX */ 46 | /* Limit on spacing of two highest peaks in histogram: spacing determined by bin size. */ 47 | #define LIM_PEAK_SPACE_FLAT_DIFF 4 /* * 2 * BIN_SIZE_DIFF_FX */ 48 | /* Limit on relevance of second peak */ 49 | #define LIM_PEAK_WEIGHT_FLAT_DIFF 2 50 | #define THRES_FLUCT_LRT 10240 /* = 20 * inst->modelUpdate; fluctuation limit of LRT feat. */ 51 | /* Limit on the max and min values for the feature thresholds */ 52 | #define MAX_FLAT_Q10 38912 /* * 2 * BIN_SIZE_FLAT_FX */ 53 | #define MIN_FLAT_Q10 4096 /* * 2 * BIN_SIZE_FLAT_FX */ 54 | #define MAX_DIFF 100 /* * 2 * BIN_SIZE_DIFF_FX */ 55 | #define MIN_DIFF 16 /* * 2 * BIN_SIZE_DIFF_FX */ 56 | /* Criteria of weight of histogram peak to accept/reject feature */ 57 | #define THRES_WEIGHT_FLAT_DIFF 154 /*(int)(0.3*(inst->modelUpdate)) for flatness and difference */ 58 | 59 | #define STAT_UPDATES 9 /* Update every 512 = 1 << 9 block */ 60 | #define ONE_MINUS_GAMMA_PAUSE_Q8 13 /* ~= Q8(0.05) Update for conservative noise estimate */ 61 | #define GAMMA_NOISE_TRANS_AND_SPEECH_Q8 3 /* ~= Q8(0.01) Update for transition and noise region */ 62 | 63 | #endif /* WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ */ 64 | -------------------------------------------------------------------------------- /WebRtcMoudle/randomization_functions.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 implementations of the randomization functions 14 | * WebRtcSpl_IncreaseSeed() 15 | * WebRtcSpl_RandU() 16 | * WebRtcSpl_RandN() 17 | * WebRtcSpl_RandUArray() 18 | * 19 | * The description header can be found in signal_processing_library.h 20 | * 21 | */ 22 | 23 | #include "signal_processing_library.h" 24 | 25 | static const int16_t kRandNTable[] = { 26 | 9178, -7260, 40, 10189, 4894, -3531, -13779, 14764, 27 | -4008, -8884, -8990, 1008, 7368, 5184, 3251, -5817, 28 | -9786, 5963, 1770, 8066, -7135, 10772, -2298, 1361, 29 | 6484, 2241, -8633, 792, 199, -3344, 6553, -10079, 30 | -15040, 95, 11608, -12469, 14161, -4176, 2476, 6403, 31 | 13685, -16005, 6646, 2239, 10916, -3004, -602, -3141, 32 | 2142, 14144, -5829, 5305, 8209, 4713, 2697, -5112, 33 | 16092, -1210, -2891, -6631, -5360, -11878, -6781, -2739, 34 | -6392, 536, 10923, 10872, 5059, -4748, -7770, 5477, 35 | 38, -1025, -2892, 1638, 6304, 14375, -11028, 1553, 36 | -1565, 10762, -393, 4040, 5257, 12310, 6554, -4799, 37 | 4899, -6354, 1603, -1048, -2220, 8247, -186, -8944, 38 | -12004, 2332, 4801, -4933, 6371, 131, 8614, -5927, 39 | -8287, -22760, 4033, -15162, 3385, 3246, 3153, -5250, 40 | 3766, 784, 6494, -62, 3531, -1582, 15572, 662, 41 | -3952, -330, -3196, 669, 7236, -2678, -6569, 23319, 42 | -8645, -741, 14830, -15976, 4903, 315, -11342, 10311, 43 | 1858, -7777, 2145, 5436, 5677, -113, -10033, 826, 44 | -1353, 17210, 7768, 986, -1471, 8291, -4982, 8207, 45 | -14911, -6255, -2449, -11881, -7059, -11703, -4338, 8025, 46 | 7538, -2823, -12490, 9470, -1613, -2529, -10092, -7807, 47 | 9480, 6970, -12844, 5123, 3532, 4816, 4803, -8455, 48 | -5045, 14032, -4378, -1643, 5756, -11041, -2732, -16618, 49 | -6430, -18375, -3320, 6098, 5131, -4269, -8840, 2482, 50 | -7048, 1547, -21890, -6505, -7414, -424, -11722, 7955, 51 | 1653, -17299, 1823, 473, -9232, 3337, 1111, 873, 52 | 4018, -8982, 9889, 3531, -11763, -3799, 7373, -4539, 53 | 3231, 7054, -8537, 7616, 6244, 16635, 447, -2915, 54 | 13967, 705, -2669, -1520, -1771, -16188, 5956, 5117, 55 | 6371, -9936, -1448, 2480, 5128, 7550, -8130, 5236, 56 | 8213, -6443, 7707, -1950, -13811, 7218, 7031, -3883, 57 | 67, 5731, -2874, 13480, -3743, 9298, -3280, 3552, 58 | -4425, -18, -3785, -9988, -5357, 5477, -11794, 2117, 59 | 1416, -9935, 3376, 802, -5079, -8243, 12652, 66, 60 | 3653, -2368, 6781, -21895, -7227, 2487, 7839, -385, 61 | 6646, -7016, -4658, 5531, -1705, 834, 129, 3694, 62 | -1343, 2238, -22640, -6417, -11139, 11301, -2945, -3494, 63 | -5626, 185, -3615, -2041, -7972, -3106, -60, -23497, 64 | -1566, 17064, 3519, 2518, 304, -6805, -10269, 2105, 65 | 1936, -426, -736, -8122, -1467, 4238, -6939, -13309, 66 | 360, 7402, -7970, 12576, 3287, 12194, -6289, -16006, 67 | 9171, 4042, -9193, 9123, -2512, 6388, -4734, -8739, 68 | 1028, -5406, -1696, 5889, -666, -4736, 4971, 3565, 69 | 9362, -6292, 3876, -3652, -19666, 7523, -4061, 391, 70 | -11773, 7502, -3763, 4929, -9478, 13278, 2805, 4496, 71 | 7814, 16419, 12455, -14773, 2127, -2746, 3763, 4847, 72 | 3698, 6978, 4751, -6957, -3581, -45, 6252, 1513, 73 | -4797, -7925, 11270, 16188, -2359, -5269, 9376, -10777, 74 | 7262, 20031, -6515, -2208, -5353, 8085, -1341, -1303, 75 | 7333, 5576, 3625, 5763, -7931, 9833, -3371, -10305, 76 | 6534, -13539, -9971, 997, 8464, -4064, -1495, 1857, 77 | 13624, 5458, 9490, -11086, -4524, 12022, -550, -198, 78 | 408, -8455, -7068, 10289, 9712, -3366, 9028, -7621, 79 | -5243, 2362, 6909, 4672, -4933, -1799, 4709, -4563, 80 | -62, -566, 1624, -7010, 14730, -17791, -3697, -2344, 81 | -1741, 7099, -9509, -6855, -1989, 3495, -2289, 2031, 82 | 12784, 891, 14189, -3963, -5683, 421, -12575, 1724, 83 | -12682, -5970, -8169, 3143, -1824, -5488, -5130, 8536, 84 | 12799, 794, 5738, 3459, -11689, -258, -3738, -3775, 85 | -8742, 2333, 8312, -9383, 10331, 13119, 8398, 10644, 86 | -19433, -6446, -16277, -11793, 16284, 9345, 15222, 15834, 87 | 2009, -7349, 130, -14547, 338, -5998, 3337, 21492, 88 | 2406, 7703, -951, 11196, -564, 3406, 2217, 4806, 89 | 2374, -5797, 11839, 8940, -11874, 18213, 2855, 10492 90 | }; 91 | 92 | uint32_t WebRtcSpl_IncreaseSeed(uint32_t *seed) 93 | { 94 | seed[0] = (seed[0] * ((int32_t)69069) + 1) & (WEBRTC_SPL_MAX_SEED_USED - 1); 95 | return seed[0]; 96 | } 97 | 98 | int16_t WebRtcSpl_RandU(uint32_t *seed) 99 | { 100 | return (int16_t)(WebRtcSpl_IncreaseSeed(seed) >> 16); 101 | } 102 | 103 | int16_t WebRtcSpl_RandN(uint32_t *seed) 104 | { 105 | return kRandNTable[WebRtcSpl_IncreaseSeed(seed) >> 23]; 106 | } 107 | 108 | // Creates an array of uniformly distributed variables 109 | int16_t WebRtcSpl_RandUArray(int16_t* vector, 110 | int16_t vector_length, 111 | uint32_t* seed) 112 | { 113 | int i; 114 | for (i = 0; i < vector_length; i++) 115 | { 116 | vector[i] = WebRtcSpl_RandU(seed); 117 | } 118 | return vector_length; 119 | } 120 | -------------------------------------------------------------------------------- /WebRtcMoudle/real_fft.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 "real_fft.h" 12 | 13 | #include 14 | 15 | #include "signal_processing_library.h" 16 | 17 | struct RealFFT { 18 | int order; 19 | }; 20 | 21 | struct RealFFT* WebRtcSpl_CreateRealFFTC(int order) { 22 | struct RealFFT* self = NULL; 23 | 24 | if (order > kMaxFFTOrder || order < 0) { 25 | return NULL; 26 | } 27 | 28 | self = malloc(sizeof(struct RealFFT)); 29 | if (self == NULL) { 30 | return NULL; 31 | } 32 | self->order = order; 33 | 34 | return self; 35 | } 36 | 37 | void WebRtcSpl_FreeRealFFTC(struct RealFFT* self) { 38 | if (self != NULL) { 39 | free(self); 40 | } 41 | } 42 | 43 | // The C version FFT functions (i.e. WebRtcSpl_RealForwardFFTC and 44 | // WebRtcSpl_RealInverseFFTC) are real-valued FFT wrappers for complex-valued 45 | // FFT implementation in SPL. 46 | 47 | int WebRtcSpl_RealForwardFFTC(struct RealFFT* self, 48 | const int16_t* real_data_in, 49 | int16_t* complex_data_out) { 50 | int i = 0; 51 | int j = 0; 52 | int result = 0; 53 | int n = 1 << self->order; 54 | // The complex-value FFT implementation needs a buffer to hold 2^order 55 | // 16-bit COMPLEX numbers, for both time and frequency data. 56 | int16_t complex_buffer[2 << kMaxFFTOrder]; 57 | 58 | // Insert zeros to the imaginary parts for complex forward FFT input. 59 | for (i = 0, j = 0; i < n; i += 1, j += 2) { 60 | complex_buffer[j] = real_data_in[i]; 61 | complex_buffer[j + 1] = 0; 62 | }; 63 | 64 | WebRtcSpl_ComplexBitReverse(complex_buffer, self->order); 65 | result = WebRtcSpl_ComplexFFT(complex_buffer, self->order, 1); 66 | 67 | // For real FFT output, use only the first N + 2 elements from 68 | // complex forward FFT. 69 | memcpy(complex_data_out, complex_buffer, sizeof(int16_t) * (n + 2)); 70 | 71 | return result; 72 | } 73 | 74 | int WebRtcSpl_RealInverseFFTC(struct RealFFT* self, 75 | const int16_t* complex_data_in, 76 | int16_t* real_data_out) { 77 | int i = 0; 78 | int j = 0; 79 | int result = 0; 80 | int n = 1 << self->order; 81 | // Create the buffer specific to complex-valued FFT implementation. 82 | int16_t complex_buffer[2 << kMaxFFTOrder]; 83 | 84 | // For n-point FFT, first copy the first n + 2 elements into complex 85 | // FFT, then construct the remaining n - 2 elements by real FFT's 86 | // conjugate-symmetric properties. 87 | memcpy(complex_buffer, complex_data_in, sizeof(int16_t) * (n + 2)); 88 | for (i = n + 2; i < 2 * n; i += 2) { 89 | complex_buffer[i] = complex_data_in[2 * n - i]; 90 | complex_buffer[i + 1] = -complex_data_in[2 * n - i + 1]; 91 | } 92 | 93 | WebRtcSpl_ComplexBitReverse(complex_buffer, self->order); 94 | result = WebRtcSpl_ComplexIFFT(complex_buffer, self->order, 1); 95 | 96 | // Strip out the imaginary parts of the complex inverse FFT output. 97 | for (i = 0, j = 0; i < n; i += 1, j += 2) { 98 | real_data_out[i] = complex_buffer[j]; 99 | } 100 | 101 | return result; 102 | } 103 | 104 | #if defined(WEBRTC_DETECT_ARM_NEON) || defined(WEBRTC_ARCH_ARM_NEON) 105 | // TODO(kma): Replace the following function bodies into optimized functions 106 | // for ARM Neon. 107 | struct RealFFT* WebRtcSpl_CreateRealFFTNeon(int order) { 108 | return WebRtcSpl_CreateRealFFTC(order); 109 | } 110 | 111 | void WebRtcSpl_FreeRealFFTNeon(struct RealFFT* self) { 112 | WebRtcSpl_FreeRealFFTC(self); 113 | } 114 | 115 | int WebRtcSpl_RealForwardFFTNeon(struct RealFFT* self, 116 | const int16_t* real_data_in, 117 | int16_t* complex_data_out) { 118 | return WebRtcSpl_RealForwardFFTC(self, real_data_in, complex_data_out); 119 | } 120 | 121 | int WebRtcSpl_RealInverseFFTNeon(struct RealFFT* self, 122 | const int16_t* complex_data_in, 123 | int16_t* real_data_out) { 124 | return WebRtcSpl_RealInverseFFTC(self, complex_data_in, real_data_out); 125 | } 126 | #endif // WEBRTC_DETECT_ARM_NEON || WEBRTC_ARCH_ARM_NEON 127 | -------------------------------------------------------------------------------- /WebRtcMoudle/real_fft.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_COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_REAL_FFT_H_ 12 | #define WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_REAL_FFT_H_ 13 | 14 | #include "typedefs.h" 15 | 16 | // For ComplexFFT(), the maximum fft order is 10; 17 | // for OpenMax FFT in ARM, it is 12; 18 | // WebRTC APM uses orders of only 7 and 8. 19 | enum {kMaxFFTOrder = 10}; 20 | 21 | struct RealFFT; 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef struct RealFFT* (*CreateRealFFT)(int order); 28 | typedef void (*FreeRealFFT)(struct RealFFT* self); 29 | typedef int (*RealForwardFFT)(struct RealFFT* self, 30 | const int16_t* real_data_in, 31 | int16_t* complex_data_out); 32 | typedef int (*RealInverseFFT)(struct RealFFT* self, 33 | const int16_t* complex_data_in, 34 | int16_t* real_data_out); 35 | 36 | extern CreateRealFFT WebRtcSpl_CreateRealFFT; 37 | extern FreeRealFFT WebRtcSpl_FreeRealFFT; 38 | extern RealForwardFFT WebRtcSpl_RealForwardFFT; 39 | extern RealInverseFFT WebRtcSpl_RealInverseFFT; 40 | 41 | struct RealFFT* WebRtcSpl_CreateRealFFTC(int order); 42 | void WebRtcSpl_FreeRealFFTC(struct RealFFT* self); 43 | 44 | #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON) 45 | struct RealFFT* WebRtcSpl_CreateRealFFTNeon(int order); 46 | void WebRtcSpl_FreeRealFFTNeon(struct RealFFT* self); 47 | #endif 48 | 49 | // Compute an FFT for a real-valued signal of length of 2^order, 50 | // where 1 < order <= MAX_FFT_ORDER. Transform length is determined by the 51 | // specification structure, which must be initialized prior to calling the FFT 52 | // function with WebRtcSpl_CreateRealFFT(). 53 | // The relationship between the input and output sequences can 54 | // be expressed in terms of the DFT, i.e.: 55 | // x[n] = (2^(-scalefactor)/N) . SUM[k=0,...,N-1] X[k].e^(jnk.2.pi/N) 56 | // n=0,1,2,...N-1 57 | // N=2^order. 58 | // The conjugate-symmetric output sequence is represented using a CCS vector, 59 | // which is of length N+2, and is organized as follows: 60 | // Index: 0 1 2 3 4 5 . . . N-2 N-1 N N+1 61 | // Component: R0 0 R1 I1 R2 I2 . . . R[N/2-1] I[N/2-1] R[N/2] 0 62 | // where R[n] and I[n], respectively, denote the real and imaginary components 63 | // for FFT bin 'n'. Bins are numbered from 0 to N/2, where N is the FFT length. 64 | // Bin index 0 corresponds to the DC component, and bin index N/2 corresponds to 65 | // the foldover frequency. 66 | // 67 | // Input Arguments: 68 | // self - pointer to preallocated and initialized FFT specification structure. 69 | // real_data_in - the input signal. For an ARM Neon platform, it must be 70 | // aligned on a 32-byte boundary. 71 | // 72 | // Output Arguments: 73 | // complex_data_out - the output complex signal with (2^order + 2) 16-bit 74 | // elements. For an ARM Neon platform, it must be different 75 | // from real_data_in, and aligned on a 32-byte boundary. 76 | // 77 | // Return Value: 78 | // 0 - FFT calculation is successful. 79 | // -1 - Error with bad arguments (NULL pointers). 80 | int WebRtcSpl_RealForwardFFTC(struct RealFFT* self, 81 | const int16_t* real_data_in, 82 | int16_t* complex_data_out); 83 | 84 | #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON) 85 | int WebRtcSpl_RealForwardFFTNeon(struct RealFFT* self, 86 | const int16_t* real_data_in, 87 | int16_t* complex_data_out); 88 | #endif 89 | 90 | // Compute the inverse FFT for a conjugate-symmetric input sequence of length of 91 | // 2^order, where 1 < order <= MAX_FFT_ORDER. Transform length is determined by 92 | // the specification structure, which must be initialized prior to calling the 93 | // FFT function with WebRtcSpl_CreateRealFFT(). 94 | // For a transform of length M, the input sequence is represented using a packed 95 | // CCS vector of length M+2, which is explained in the comments for 96 | // WebRtcSpl_RealForwardFFTC above. 97 | // 98 | // Input Arguments: 99 | // self - pointer to preallocated and initialized FFT specification structure. 100 | // complex_data_in - the input complex signal with (2^order + 2) 16-bit 101 | // elements. For an ARM Neon platform, it must be aligned on 102 | // a 32-byte boundary. 103 | // 104 | // Output Arguments: 105 | // real_data_out - the output real signal. For an ARM Neon platform, it must 106 | // be different to complex_data_in, and aligned on a 32-byte 107 | // boundary. 108 | // 109 | // Return Value: 110 | // 0 or a positive number - a value that the elements in the |real_data_out| 111 | // should be shifted left with in order to get 112 | // correct physical values. 113 | // -1 - Error with bad arguments (NULL pointers). 114 | int WebRtcSpl_RealInverseFFTC(struct RealFFT* self, 115 | const int16_t* complex_data_in, 116 | int16_t* real_data_out); 117 | 118 | #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON) 119 | int WebRtcSpl_RealInverseFFTNeon(struct RealFFT* self, 120 | const int16_t* complex_data_in, 121 | int16_t* real_data_out); 122 | #endif 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | 128 | #endif // WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_REAL_FFT_H_ 129 | -------------------------------------------------------------------------------- /WebRtcMoudle/resample_48khz.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 resampling functions between 48 kHz and nb/wb. 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include 19 | #include "signal_processing_library.h" 20 | #include "resample_by_2_internal.h" 21 | 22 | //////////////////////////// 23 | ///// 48 kHz -> 16 kHz ///// 24 | //////////////////////////// 25 | 26 | // 48 -> 16 resampler 27 | void WebRtcSpl_Resample48khzTo16khz(const int16_t* in, int16_t* out, 28 | WebRtcSpl_State48khzTo16khz* state, int32_t* tmpmem) 29 | { 30 | ///// 48 --> 48(LP) ///// 31 | // int16_t in[480] 32 | // int32_t out[480] 33 | ///// 34 | WebRtcSpl_LPBy2ShortToInt(in, 480, tmpmem + 16, state->S_48_48); 35 | 36 | ///// 48 --> 32 ///// 37 | // int32_t in[480] 38 | // int32_t out[320] 39 | ///// 40 | // copy state to and from input array 41 | memcpy(tmpmem + 8, state->S_48_32, 8 * sizeof(int32_t)); 42 | memcpy(state->S_48_32, tmpmem + 488, 8 * sizeof(int32_t)); 43 | WebRtcSpl_Resample48khzTo32khz(tmpmem + 8, tmpmem, 160); 44 | 45 | ///// 32 --> 16 ///// 46 | // int32_t in[320] 47 | // int16_t out[160] 48 | ///// 49 | WebRtcSpl_DownBy2IntToShort(tmpmem, 320, out, state->S_32_16); 50 | } 51 | 52 | // initialize state of 48 -> 16 resampler 53 | void WebRtcSpl_ResetResample48khzTo16khz(WebRtcSpl_State48khzTo16khz* state) 54 | { 55 | memset(state->S_48_48, 0, 16 * sizeof(int32_t)); 56 | memset(state->S_48_32, 0, 8 * sizeof(int32_t)); 57 | memset(state->S_32_16, 0, 8 * sizeof(int32_t)); 58 | } 59 | 60 | //////////////////////////// 61 | ///// 16 kHz -> 48 kHz ///// 62 | //////////////////////////// 63 | 64 | // 16 -> 48 resampler 65 | void WebRtcSpl_Resample16khzTo48khz(const int16_t* in, int16_t* out, 66 | WebRtcSpl_State16khzTo48khz* state, int32_t* tmpmem) 67 | { 68 | ///// 16 --> 32 ///// 69 | // int16_t in[160] 70 | // int32_t out[320] 71 | ///// 72 | WebRtcSpl_UpBy2ShortToInt(in, 160, tmpmem + 16, state->S_16_32); 73 | 74 | ///// 32 --> 24 ///// 75 | // int32_t in[320] 76 | // int32_t out[240] 77 | // copy state to and from input array 78 | ///// 79 | memcpy(tmpmem + 8, state->S_32_24, 8 * sizeof(int32_t)); 80 | memcpy(state->S_32_24, tmpmem + 328, 8 * sizeof(int32_t)); 81 | WebRtcSpl_Resample32khzTo24khz(tmpmem + 8, tmpmem, 80); 82 | 83 | ///// 24 --> 48 ///// 84 | // int32_t in[240] 85 | // int16_t out[480] 86 | ///// 87 | WebRtcSpl_UpBy2IntToShort(tmpmem, 240, out, state->S_24_48); 88 | } 89 | 90 | // initialize state of 16 -> 48 resampler 91 | void WebRtcSpl_ResetResample16khzTo48khz(WebRtcSpl_State16khzTo48khz* state) 92 | { 93 | memset(state->S_16_32, 0, 8 * sizeof(int32_t)); 94 | memset(state->S_32_24, 0, 8 * sizeof(int32_t)); 95 | memset(state->S_24_48, 0, 8 * sizeof(int32_t)); 96 | } 97 | 98 | //////////////////////////// 99 | ///// 48 kHz -> 8 kHz ///// 100 | //////////////////////////// 101 | 102 | // 48 -> 8 resampler 103 | void WebRtcSpl_Resample48khzTo8khz(const int16_t* in, int16_t* out, 104 | WebRtcSpl_State48khzTo8khz* state, int32_t* tmpmem) 105 | { 106 | ///// 48 --> 24 ///// 107 | // int16_t in[480] 108 | // int32_t out[240] 109 | ///// 110 | WebRtcSpl_DownBy2ShortToInt(in, 480, tmpmem + 256, state->S_48_24); 111 | 112 | ///// 24 --> 24(LP) ///// 113 | // int32_t in[240] 114 | // int32_t out[240] 115 | ///// 116 | WebRtcSpl_LPBy2IntToInt(tmpmem + 256, 240, tmpmem + 16, state->S_24_24); 117 | 118 | ///// 24 --> 16 ///// 119 | // int32_t in[240] 120 | // int32_t out[160] 121 | ///// 122 | // copy state to and from input array 123 | memcpy(tmpmem + 8, state->S_24_16, 8 * sizeof(int32_t)); 124 | memcpy(state->S_24_16, tmpmem + 248, 8 * sizeof(int32_t)); 125 | WebRtcSpl_Resample48khzTo32khz(tmpmem + 8, tmpmem, 80); 126 | 127 | ///// 16 --> 8 ///// 128 | // int32_t in[160] 129 | // int16_t out[80] 130 | ///// 131 | WebRtcSpl_DownBy2IntToShort(tmpmem, 160, out, state->S_16_8); 132 | } 133 | 134 | // initialize state of 48 -> 8 resampler 135 | void WebRtcSpl_ResetResample48khzTo8khz(WebRtcSpl_State48khzTo8khz* state) 136 | { 137 | memset(state->S_48_24, 0, 8 * sizeof(int32_t)); 138 | memset(state->S_24_24, 0, 16 * sizeof(int32_t)); 139 | memset(state->S_24_16, 0, 8 * sizeof(int32_t)); 140 | memset(state->S_16_8, 0, 8 * sizeof(int32_t)); 141 | } 142 | 143 | //////////////////////////// 144 | ///// 8 kHz -> 48 kHz ///// 145 | //////////////////////////// 146 | 147 | // 8 -> 48 resampler 148 | void WebRtcSpl_Resample8khzTo48khz(const int16_t* in, int16_t* out, 149 | WebRtcSpl_State8khzTo48khz* state, int32_t* tmpmem) 150 | { 151 | ///// 8 --> 16 ///// 152 | // int16_t in[80] 153 | // int32_t out[160] 154 | ///// 155 | WebRtcSpl_UpBy2ShortToInt(in, 80, tmpmem + 264, state->S_8_16); 156 | 157 | ///// 16 --> 12 ///// 158 | // int32_t in[160] 159 | // int32_t out[120] 160 | ///// 161 | // copy state to and from input array 162 | memcpy(tmpmem + 256, state->S_16_12, 8 * sizeof(int32_t)); 163 | memcpy(state->S_16_12, tmpmem + 416, 8 * sizeof(int32_t)); 164 | WebRtcSpl_Resample32khzTo24khz(tmpmem + 256, tmpmem + 240, 40); 165 | 166 | ///// 12 --> 24 ///// 167 | // int32_t in[120] 168 | // int16_t out[240] 169 | ///// 170 | WebRtcSpl_UpBy2IntToInt(tmpmem + 240, 120, tmpmem, state->S_12_24); 171 | 172 | ///// 24 --> 48 ///// 173 | // int32_t in[240] 174 | // int16_t out[480] 175 | ///// 176 | WebRtcSpl_UpBy2IntToShort(tmpmem, 240, out, state->S_24_48); 177 | } 178 | 179 | // initialize state of 8 -> 48 resampler 180 | void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state) 181 | { 182 | memset(state->S_8_16, 0, 8 * sizeof(int32_t)); 183 | memset(state->S_16_12, 0, 8 * sizeof(int32_t)); 184 | memset(state->S_12_24, 0, 8 * sizeof(int32_t)); 185 | memset(state->S_24_48, 0, 8 * sizeof(int32_t)); 186 | } 187 | -------------------------------------------------------------------------------- /WebRtcMoudle/resample_by_2.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 resampling by two functions. 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | #ifdef WEBRTC_ARCH_ARM_V7 21 | 22 | // allpass filter coefficients. 23 | static const uint32_t kResampleAllpass1[3] = {3284, 24441, 49528 << 15}; 24 | static const uint32_t kResampleAllpass2[3] = 25 | {12199, 37471 << 15, 60255 << 15}; 26 | 27 | // Multiply two 32-bit values and accumulate to another input value. 28 | // Return: state + ((diff * tbl_value) >> 16) 29 | 30 | static __inline int32_t MUL_ACCUM_1(int32_t tbl_value, 31 | int32_t diff, 32 | int32_t state) { 33 | int32_t result; 34 | __asm __volatile ("smlawb %0, %1, %2, %3": "=r"(result): "r"(diff), 35 | "r"(tbl_value), "r"(state)); 36 | return result; 37 | } 38 | 39 | // Multiply two 32-bit values and accumulate to another input value. 40 | // Return: Return: state + (((diff << 1) * tbl_value) >> 32) 41 | // 42 | // The reason to introduce this function is that, in case we can't use smlawb 43 | // instruction (in MUL_ACCUM_1) due to input value range, we can still use 44 | // smmla to save some cycles. 45 | 46 | static __inline int32_t MUL_ACCUM_2(int32_t tbl_value, 47 | int32_t diff, 48 | int32_t state) { 49 | int32_t result; 50 | __asm __volatile ("smmla %0, %1, %2, %3": "=r"(result): "r"(diff << 1), 51 | "r"(tbl_value), "r"(state)); 52 | return result; 53 | } 54 | 55 | #else 56 | 57 | // allpass filter coefficients. 58 | static const uint16_t kResampleAllpass1[3] = {3284, 24441, 49528}; 59 | static const uint16_t kResampleAllpass2[3] = {12199, 37471, 60255}; 60 | 61 | // Multiply a 32-bit value with a 16-bit value and accumulate to another input: 62 | #define MUL_ACCUM_1(a, b, c) WEBRTC_SPL_SCALEDIFF32(a, b, c) 63 | #define MUL_ACCUM_2(a, b, c) WEBRTC_SPL_SCALEDIFF32(a, b, c) 64 | 65 | #endif // WEBRTC_ARCH_ARM_V7 66 | 67 | 68 | // decimator 69 | #if !defined(MIPS32_LE) 70 | void WebRtcSpl_DownsampleBy2(const int16_t* in, int16_t len, 71 | int16_t* out, int32_t* filtState) { 72 | int32_t tmp1, tmp2, diff, in32, out32; 73 | int16_t i; 74 | 75 | register int32_t state0 = filtState[0]; 76 | register int32_t state1 = filtState[1]; 77 | register int32_t state2 = filtState[2]; 78 | register int32_t state3 = filtState[3]; 79 | register int32_t state4 = filtState[4]; 80 | register int32_t state5 = filtState[5]; 81 | register int32_t state6 = filtState[6]; 82 | register int32_t state7 = filtState[7]; 83 | 84 | for (i = (len >> 1); i > 0; i--) { 85 | // lower allpass filter 86 | in32 = (int32_t)(*in++) << 10; 87 | diff = in32 - state1; 88 | tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0); 89 | state0 = in32; 90 | diff = tmp1 - state2; 91 | tmp2 = MUL_ACCUM_2(kResampleAllpass2[1], diff, state1); 92 | state1 = tmp1; 93 | diff = tmp2 - state3; 94 | state3 = MUL_ACCUM_2(kResampleAllpass2[2], diff, state2); 95 | state2 = tmp2; 96 | 97 | // upper allpass filter 98 | in32 = (int32_t)(*in++) << 10; 99 | diff = in32 - state5; 100 | tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4); 101 | state4 = in32; 102 | diff = tmp1 - state6; 103 | tmp2 = MUL_ACCUM_1(kResampleAllpass1[1], diff, state5); 104 | state5 = tmp1; 105 | diff = tmp2 - state7; 106 | state7 = MUL_ACCUM_2(kResampleAllpass1[2], diff, state6); 107 | state6 = tmp2; 108 | 109 | // add two allpass outputs, divide by two and round 110 | out32 = (state3 + state7 + 1024) >> 11; 111 | 112 | // limit amplitude to prevent wrap-around, and write to output array 113 | *out++ = WebRtcSpl_SatW32ToW16(out32); 114 | } 115 | 116 | filtState[0] = state0; 117 | filtState[1] = state1; 118 | filtState[2] = state2; 119 | filtState[3] = state3; 120 | filtState[4] = state4; 121 | filtState[5] = state5; 122 | filtState[6] = state6; 123 | filtState[7] = state7; 124 | } 125 | #endif // #if defined(MIPS32_LE) 126 | 127 | 128 | void WebRtcSpl_UpsampleBy2(const int16_t* in, int16_t len, 129 | int16_t* out, int32_t* filtState) { 130 | int32_t tmp1, tmp2, diff, in32, out32; 131 | int16_t i; 132 | 133 | register int32_t state0 = filtState[0]; 134 | register int32_t state1 = filtState[1]; 135 | register int32_t state2 = filtState[2]; 136 | register int32_t state3 = filtState[3]; 137 | register int32_t state4 = filtState[4]; 138 | register int32_t state5 = filtState[5]; 139 | register int32_t state6 = filtState[6]; 140 | register int32_t state7 = filtState[7]; 141 | 142 | for (i = len; i > 0; i--) { 143 | // lower allpass filter 144 | in32 = (int32_t)(*in++) << 10; 145 | diff = in32 - state1; 146 | tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state0); 147 | state0 = in32; 148 | diff = tmp1 - state2; 149 | tmp2 = MUL_ACCUM_1(kResampleAllpass1[1], diff, state1); 150 | state1 = tmp1; 151 | diff = tmp2 - state3; 152 | state3 = MUL_ACCUM_2(kResampleAllpass1[2], diff, state2); 153 | state2 = tmp2; 154 | 155 | // round; limit amplitude to prevent wrap-around; write to output array 156 | out32 = (state3 + 512) >> 10; 157 | *out++ = WebRtcSpl_SatW32ToW16(out32); 158 | 159 | // upper allpass filter 160 | diff = in32 - state5; 161 | tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state4); 162 | state4 = in32; 163 | diff = tmp1 - state6; 164 | tmp2 = MUL_ACCUM_2(kResampleAllpass2[1], diff, state5); 165 | state5 = tmp1; 166 | diff = tmp2 - state7; 167 | state7 = MUL_ACCUM_2(kResampleAllpass2[2], diff, state6); 168 | state6 = tmp2; 169 | 170 | // round; limit amplitude to prevent wrap-around; write to output array 171 | out32 = (state7 + 512) >> 10; 172 | *out++ = WebRtcSpl_SatW32ToW16(out32); 173 | } 174 | 175 | filtState[0] = state0; 176 | filtState[1] = state1; 177 | filtState[2] = state2; 178 | filtState[3] = state3; 179 | filtState[4] = state4; 180 | filtState[5] = state5; 181 | filtState[6] = state6; 182 | filtState[7] = state7; 183 | } 184 | -------------------------------------------------------------------------------- /WebRtcMoudle/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 "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 | -------------------------------------------------------------------------------- /WebRtcMoudle/resample_fractional.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 resampling functions between 48, 44, 32 and 24 kHz. 14 | * The description headers can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | // interpolation coefficients 21 | static const int16_t kCoefficients48To32[2][8] = { 22 | {778, -2050, 1087, 23285, 12903, -3783, 441, 222}, 23 | {222, 441, -3783, 12903, 23285, 1087, -2050, 778} 24 | }; 25 | 26 | static const int16_t kCoefficients32To24[3][8] = { 27 | {767, -2362, 2434, 24406, 10620, -3838, 721, 90}, 28 | {386, -381, -2646, 19062, 19062, -2646, -381, 386}, 29 | {90, 721, -3838, 10620, 24406, 2434, -2362, 767} 30 | }; 31 | 32 | static const int16_t kCoefficients44To32[4][9] = { 33 | {117, -669, 2245, -6183, 26267, 13529, -3245, 845, -138}, 34 | {-101, 612, -2283, 8532, 29790, -5138, 1789, -524, 91}, 35 | {50, -292, 1016, -3064, 32010, 3933, -1147, 315, -53}, 36 | {-156, 974, -3863, 18603, 21691, -6246, 2353, -712, 126} 37 | }; 38 | 39 | // Resampling ratio: 2/3 40 | // input: int32_t (normalized, not saturated) :: size 3 * K 41 | // output: int32_t (shifted 15 positions to the left, + offset 16384) :: size 2 * K 42 | // K: number of blocks 43 | 44 | void WebRtcSpl_Resample48khzTo32khz(const int32_t *In, int32_t *Out, 45 | int32_t K) 46 | { 47 | ///////////////////////////////////////////////////////////// 48 | // Filter operation: 49 | // 50 | // Perform resampling (3 input samples -> 2 output samples); 51 | // process in sub blocks of size 3 samples. 52 | int32_t tmp; 53 | int32_t m; 54 | 55 | for (m = 0; m < K; m++) 56 | { 57 | tmp = 1 << 14; 58 | tmp += kCoefficients48To32[0][0] * In[0]; 59 | tmp += kCoefficients48To32[0][1] * In[1]; 60 | tmp += kCoefficients48To32[0][2] * In[2]; 61 | tmp += kCoefficients48To32[0][3] * In[3]; 62 | tmp += kCoefficients48To32[0][4] * In[4]; 63 | tmp += kCoefficients48To32[0][5] * In[5]; 64 | tmp += kCoefficients48To32[0][6] * In[6]; 65 | tmp += kCoefficients48To32[0][7] * In[7]; 66 | Out[0] = tmp; 67 | 68 | tmp = 1 << 14; 69 | tmp += kCoefficients48To32[1][0] * In[1]; 70 | tmp += kCoefficients48To32[1][1] * In[2]; 71 | tmp += kCoefficients48To32[1][2] * In[3]; 72 | tmp += kCoefficients48To32[1][3] * In[4]; 73 | tmp += kCoefficients48To32[1][4] * In[5]; 74 | tmp += kCoefficients48To32[1][5] * In[6]; 75 | tmp += kCoefficients48To32[1][6] * In[7]; 76 | tmp += kCoefficients48To32[1][7] * In[8]; 77 | Out[1] = tmp; 78 | 79 | // update pointers 80 | In += 3; 81 | Out += 2; 82 | } 83 | } 84 | 85 | // Resampling ratio: 3/4 86 | // input: int32_t (normalized, not saturated) :: size 4 * K 87 | // output: int32_t (shifted 15 positions to the left, + offset 16384) :: size 3 * K 88 | // K: number of blocks 89 | 90 | void WebRtcSpl_Resample32khzTo24khz(const int32_t *In, int32_t *Out, 91 | int32_t K) 92 | { 93 | ///////////////////////////////////////////////////////////// 94 | // Filter operation: 95 | // 96 | // Perform resampling (4 input samples -> 3 output samples); 97 | // process in sub blocks of size 4 samples. 98 | int32_t m; 99 | int32_t tmp; 100 | 101 | for (m = 0; m < K; m++) 102 | { 103 | tmp = 1 << 14; 104 | tmp += kCoefficients32To24[0][0] * In[0]; 105 | tmp += kCoefficients32To24[0][1] * In[1]; 106 | tmp += kCoefficients32To24[0][2] * In[2]; 107 | tmp += kCoefficients32To24[0][3] * In[3]; 108 | tmp += kCoefficients32To24[0][4] * In[4]; 109 | tmp += kCoefficients32To24[0][5] * In[5]; 110 | tmp += kCoefficients32To24[0][6] * In[6]; 111 | tmp += kCoefficients32To24[0][7] * In[7]; 112 | Out[0] = tmp; 113 | 114 | tmp = 1 << 14; 115 | tmp += kCoefficients32To24[1][0] * In[1]; 116 | tmp += kCoefficients32To24[1][1] * In[2]; 117 | tmp += kCoefficients32To24[1][2] * In[3]; 118 | tmp += kCoefficients32To24[1][3] * In[4]; 119 | tmp += kCoefficients32To24[1][4] * In[5]; 120 | tmp += kCoefficients32To24[1][5] * In[6]; 121 | tmp += kCoefficients32To24[1][6] * In[7]; 122 | tmp += kCoefficients32To24[1][7] * In[8]; 123 | Out[1] = tmp; 124 | 125 | tmp = 1 << 14; 126 | tmp += kCoefficients32To24[2][0] * In[2]; 127 | tmp += kCoefficients32To24[2][1] * In[3]; 128 | tmp += kCoefficients32To24[2][2] * In[4]; 129 | tmp += kCoefficients32To24[2][3] * In[5]; 130 | tmp += kCoefficients32To24[2][4] * In[6]; 131 | tmp += kCoefficients32To24[2][5] * In[7]; 132 | tmp += kCoefficients32To24[2][6] * In[8]; 133 | tmp += kCoefficients32To24[2][7] * In[9]; 134 | Out[2] = tmp; 135 | 136 | // update pointers 137 | In += 4; 138 | Out += 3; 139 | } 140 | } 141 | 142 | // 143 | // fractional resampling filters 144 | // Fout = 11/16 * Fin 145 | // Fout = 8/11 * Fin 146 | // 147 | 148 | // compute two inner-products and store them to output array 149 | static void WebRtcSpl_ResampDotProduct(const int32_t *in1, const int32_t *in2, 150 | const int16_t *coef_ptr, int32_t *out1, 151 | int32_t *out2) 152 | { 153 | int32_t tmp1 = 16384; 154 | int32_t tmp2 = 16384; 155 | int16_t coef; 156 | 157 | coef = coef_ptr[0]; 158 | tmp1 += coef * in1[0]; 159 | tmp2 += coef * in2[-0]; 160 | 161 | coef = coef_ptr[1]; 162 | tmp1 += coef * in1[1]; 163 | tmp2 += coef * in2[-1]; 164 | 165 | coef = coef_ptr[2]; 166 | tmp1 += coef * in1[2]; 167 | tmp2 += coef * in2[-2]; 168 | 169 | coef = coef_ptr[3]; 170 | tmp1 += coef * in1[3]; 171 | tmp2 += coef * in2[-3]; 172 | 173 | coef = coef_ptr[4]; 174 | tmp1 += coef * in1[4]; 175 | tmp2 += coef * in2[-4]; 176 | 177 | coef = coef_ptr[5]; 178 | tmp1 += coef * in1[5]; 179 | tmp2 += coef * in2[-5]; 180 | 181 | coef = coef_ptr[6]; 182 | tmp1 += coef * in1[6]; 183 | tmp2 += coef * in2[-6]; 184 | 185 | coef = coef_ptr[7]; 186 | tmp1 += coef * in1[7]; 187 | tmp2 += coef * in2[-7]; 188 | 189 | coef = coef_ptr[8]; 190 | *out1 = tmp1 + coef * in1[8]; 191 | *out2 = tmp2 + coef * in2[-8]; 192 | } 193 | 194 | // Resampling ratio: 8/11 195 | // input: int32_t (normalized, not saturated) :: size 11 * K 196 | // output: int32_t (shifted 15 positions to the left, + offset 16384) :: size 8 * K 197 | // K: number of blocks 198 | 199 | void WebRtcSpl_Resample44khzTo32khz(const int32_t *In, int32_t *Out, 200 | int32_t K) 201 | { 202 | ///////////////////////////////////////////////////////////// 203 | // Filter operation: 204 | // 205 | // Perform resampling (11 input samples -> 8 output samples); 206 | // process in sub blocks of size 11 samples. 207 | int32_t tmp; 208 | int32_t m; 209 | 210 | for (m = 0; m < K; m++) 211 | { 212 | tmp = 1 << 14; 213 | 214 | // first output sample 215 | Out[0] = ((int32_t)In[3] << 15) + tmp; 216 | 217 | // sum and accumulate filter coefficients and input samples 218 | tmp += kCoefficients44To32[3][0] * In[5]; 219 | tmp += kCoefficients44To32[3][1] * In[6]; 220 | tmp += kCoefficients44To32[3][2] * In[7]; 221 | tmp += kCoefficients44To32[3][3] * In[8]; 222 | tmp += kCoefficients44To32[3][4] * In[9]; 223 | tmp += kCoefficients44To32[3][5] * In[10]; 224 | tmp += kCoefficients44To32[3][6] * In[11]; 225 | tmp += kCoefficients44To32[3][7] * In[12]; 226 | tmp += kCoefficients44To32[3][8] * In[13]; 227 | Out[4] = tmp; 228 | 229 | // sum and accumulate filter coefficients and input samples 230 | WebRtcSpl_ResampDotProduct(&In[0], &In[17], kCoefficients44To32[0], &Out[1], &Out[7]); 231 | 232 | // sum and accumulate filter coefficients and input samples 233 | WebRtcSpl_ResampDotProduct(&In[2], &In[15], kCoefficients44To32[1], &Out[2], &Out[6]); 234 | 235 | // sum and accumulate filter coefficients and input samples 236 | WebRtcSpl_ResampDotProduct(&In[3], &In[14], kCoefficients44To32[2], &Out[3], &Out[5]); 237 | 238 | // update pointers 239 | In += 11; 240 | Out += 8; 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /WebRtcMoudle/ring_buffer.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 | // A ring buffer to hold arbitrary data. Provides no thread safety. Unless 12 | // otherwise specified, functions return 0 on success and -1 on error. 13 | 14 | #include "ring_buffer.h" 15 | 16 | #include // size_t 17 | #include 18 | #include 19 | 20 | enum Wrap { 21 | SAME_WRAP, 22 | DIFF_WRAP 23 | }; 24 | 25 | struct RingBuffer { 26 | size_t read_pos; 27 | size_t write_pos; 28 | size_t element_count; 29 | size_t element_size; 30 | enum Wrap rw_wrap; 31 | char* data; 32 | }; 33 | 34 | // Get address of region(s) from which we can read data. 35 | // If the region is contiguous, |data_ptr_bytes_2| will be zero. 36 | // If non-contiguous, |data_ptr_bytes_2| will be the size in bytes of the second 37 | // region. Returns room available to be read or |element_count|, whichever is 38 | // smaller. 39 | static size_t GetBufferReadRegions(RingBuffer* buf, 40 | size_t element_count, 41 | void** data_ptr_1, 42 | size_t* data_ptr_bytes_1, 43 | void** data_ptr_2, 44 | size_t* data_ptr_bytes_2) { 45 | 46 | const size_t readable_elements = WebRtc_available_read(buf); 47 | const size_t read_elements = (readable_elements < element_count ? 48 | readable_elements : element_count); 49 | const size_t margin = buf->element_count - buf->read_pos; 50 | 51 | // Check to see if read is not contiguous. 52 | if (read_elements > margin) { 53 | // Write data in two blocks that wrap the buffer. 54 | *data_ptr_1 = buf->data + buf->read_pos * buf->element_size; 55 | *data_ptr_bytes_1 = margin * buf->element_size; 56 | *data_ptr_2 = buf->data; 57 | *data_ptr_bytes_2 = (read_elements - margin) * buf->element_size; 58 | } else { 59 | *data_ptr_1 = buf->data + buf->read_pos * buf->element_size; 60 | *data_ptr_bytes_1 = read_elements * buf->element_size; 61 | *data_ptr_2 = NULL; 62 | *data_ptr_bytes_2 = 0; 63 | } 64 | 65 | return read_elements; 66 | } 67 | 68 | RingBuffer* WebRtc_CreateBuffer(size_t element_count, size_t element_size) { 69 | RingBuffer* self = NULL; 70 | if (element_count == 0 || element_size == 0) { 71 | return NULL; 72 | } 73 | 74 | self = malloc(sizeof(RingBuffer)); 75 | if (!self) { 76 | return NULL; 77 | } 78 | 79 | self->data = malloc(element_count * element_size); 80 | if (!self->data) { 81 | free(self); 82 | self = NULL; 83 | return NULL; 84 | } 85 | 86 | self->element_count = element_count; 87 | self->element_size = element_size; 88 | 89 | return self; 90 | } 91 | 92 | int WebRtc_InitBuffer(RingBuffer* self) { 93 | if (!self) { 94 | return -1; 95 | } 96 | 97 | self->read_pos = 0; 98 | self->write_pos = 0; 99 | self->rw_wrap = SAME_WRAP; 100 | 101 | // Initialize buffer to zeros 102 | memset(self->data, 0, self->element_count * self->element_size); 103 | 104 | return 0; 105 | } 106 | 107 | void WebRtc_FreeBuffer(void* handle) { 108 | RingBuffer* self = (RingBuffer*)handle; 109 | if (!self) { 110 | return; 111 | } 112 | 113 | free(self->data); 114 | free(self); 115 | } 116 | 117 | size_t WebRtc_ReadBuffer(RingBuffer* self, 118 | void** data_ptr, 119 | void* data, 120 | size_t element_count) { 121 | 122 | if (self == NULL) { 123 | return 0; 124 | } 125 | if (data == NULL) { 126 | return 0; 127 | } 128 | 129 | { 130 | void* buf_ptr_1 = NULL; 131 | void* buf_ptr_2 = NULL; 132 | size_t buf_ptr_bytes_1 = 0; 133 | size_t buf_ptr_bytes_2 = 0; 134 | const size_t read_count = GetBufferReadRegions(self, 135 | element_count, 136 | &buf_ptr_1, 137 | &buf_ptr_bytes_1, 138 | &buf_ptr_2, 139 | &buf_ptr_bytes_2); 140 | 141 | if (buf_ptr_bytes_2 > 0) { 142 | // We have a wrap around when reading the buffer. Copy the buffer data to 143 | // |data| and point to it. 144 | memcpy(data, buf_ptr_1, buf_ptr_bytes_1); 145 | memcpy(((char*) data) + buf_ptr_bytes_1, buf_ptr_2, buf_ptr_bytes_2); 146 | buf_ptr_1 = data; 147 | } else if (!data_ptr) { 148 | // No wrap, but a memcpy was requested. 149 | memcpy(data, buf_ptr_1, buf_ptr_bytes_1); 150 | } 151 | if (data_ptr) { 152 | // |buf_ptr_1| == |data| in the case of a wrap. 153 | *data_ptr = buf_ptr_1; 154 | } 155 | 156 | // Update read position 157 | WebRtc_MoveReadPtr(self, (int) read_count); 158 | 159 | return read_count; 160 | } 161 | } 162 | 163 | size_t WebRtc_WriteBuffer(RingBuffer* self, 164 | const void* data, 165 | size_t element_count) { 166 | if (!self) { 167 | return 0; 168 | } 169 | if (!data) { 170 | return 0; 171 | } 172 | 173 | { 174 | const size_t free_elements = WebRtc_available_write(self); 175 | const size_t write_elements = (free_elements < element_count ? free_elements 176 | : element_count); 177 | size_t n = write_elements; 178 | const size_t margin = self->element_count - self->write_pos; 179 | 180 | if (write_elements > margin) { 181 | // Buffer wrap around when writing. 182 | memcpy(self->data + self->write_pos * self->element_size, 183 | data, margin * self->element_size); 184 | self->write_pos = 0; 185 | n -= margin; 186 | self->rw_wrap = DIFF_WRAP; 187 | } 188 | memcpy(self->data + self->write_pos * self->element_size, 189 | ((const char*) data) + ((write_elements - n) * self->element_size), 190 | n * self->element_size); 191 | self->write_pos += n; 192 | 193 | return write_elements; 194 | } 195 | } 196 | 197 | int WebRtc_MoveReadPtr(RingBuffer* self, int element_count) { 198 | if (!self) { 199 | return 0; 200 | } 201 | 202 | { 203 | // We need to be able to take care of negative changes, hence use "int" 204 | // instead of "size_t". 205 | const int free_elements = (int) WebRtc_available_write(self); 206 | const int readable_elements = (int) WebRtc_available_read(self); 207 | int read_pos = (int) self->read_pos; 208 | 209 | if (element_count > readable_elements) { 210 | element_count = readable_elements; 211 | } 212 | if (element_count < -free_elements) { 213 | element_count = -free_elements; 214 | } 215 | 216 | read_pos += element_count; 217 | if (read_pos > (int) self->element_count) { 218 | // Buffer wrap around. Restart read position and wrap indicator. 219 | read_pos -= (int) self->element_count; 220 | self->rw_wrap = SAME_WRAP; 221 | } 222 | if (read_pos < 0) { 223 | // Buffer wrap around. Restart read position and wrap indicator. 224 | read_pos += (int) self->element_count; 225 | self->rw_wrap = DIFF_WRAP; 226 | } 227 | 228 | self->read_pos = (size_t) read_pos; 229 | 230 | return element_count; 231 | } 232 | } 233 | 234 | size_t WebRtc_available_read(const RingBuffer* self) { 235 | if (!self) { 236 | return 0; 237 | } 238 | 239 | if (self->rw_wrap == SAME_WRAP) { 240 | return self->write_pos - self->read_pos; 241 | } else { 242 | return self->element_count - self->read_pos + self->write_pos; 243 | } 244 | } 245 | 246 | size_t WebRtc_available_write(const RingBuffer* self) { 247 | if (!self) { 248 | return 0; 249 | } 250 | 251 | return self->element_count - WebRtc_available_read(self); 252 | } 253 | -------------------------------------------------------------------------------- /WebRtcMoudle/ring_buffer.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 | // A ring buffer to hold arbitrary data. Provides no thread safety. Unless 12 | // otherwise specified, functions return 0 on success and -1 on error. 13 | 14 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_RING_BUFFER_H_ 15 | #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_RING_BUFFER_H_ 16 | 17 | #include // size_t 18 | 19 | typedef struct RingBuffer RingBuffer; 20 | 21 | // Returns NULL on failure. 22 | RingBuffer* WebRtc_CreateBuffer(size_t element_count, size_t element_size); 23 | int WebRtc_InitBuffer(RingBuffer* handle); 24 | void WebRtc_FreeBuffer(void* handle); 25 | 26 | // Reads data from the buffer. The |data_ptr| will point to the address where 27 | // it is located. If all |element_count| data are feasible to read without 28 | // buffer wrap around |data_ptr| will point to the location in the buffer. 29 | // Otherwise, the data will be copied to |data| (memory allocation done by the 30 | // user) and |data_ptr| points to the address of |data|. |data_ptr| is only 31 | // guaranteed to be valid until the next call to WebRtc_WriteBuffer(). 32 | // 33 | // To force a copying to |data|, pass a NULL |data_ptr|. 34 | // 35 | // Returns number of elements read. 36 | size_t WebRtc_ReadBuffer(RingBuffer* handle, 37 | void** data_ptr, 38 | void* data, 39 | size_t element_count); 40 | 41 | // Writes |data| to buffer and returns the number of elements written. 42 | size_t WebRtc_WriteBuffer(RingBuffer* handle, const void* data, 43 | size_t element_count); 44 | 45 | // Moves the buffer read position and returns the number of elements moved. 46 | // Positive |element_count| moves the read position towards the write position, 47 | // that is, flushing the buffer. Negative |element_count| moves the read 48 | // position away from the the write position, that is, stuffing the buffer. 49 | // Returns number of elements moved. 50 | int WebRtc_MoveReadPtr(RingBuffer* handle, int element_count); 51 | 52 | // Returns number of available elements to read. 53 | size_t WebRtc_available_read(const RingBuffer* handle); 54 | 55 | // Returns number of available elements for write. 56 | size_t WebRtc_available_write(const RingBuffer* handle); 57 | 58 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_RING_BUFFER_H_ 59 | -------------------------------------------------------------------------------- /WebRtcMoudle/spl_init.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 | /* The global function contained in this file initializes SPL function 12 | * pointers, currently only for ARM platforms. 13 | * 14 | * Some code came from common/rtcd.c in the WebM project. 15 | */ 16 | 17 | #include "real_fft.h" 18 | #include "signal_processing_library.h" 19 | #include "cpu_features_wrapper.h" 20 | 21 | /* Declare function pointers. */ 22 | MaxAbsValueW16 WebRtcSpl_MaxAbsValueW16; 23 | MaxAbsValueW32 WebRtcSpl_MaxAbsValueW32; 24 | MaxValueW16 WebRtcSpl_MaxValueW16; 25 | MaxValueW32 WebRtcSpl_MaxValueW32; 26 | MinValueW16 WebRtcSpl_MinValueW16; 27 | MinValueW32 WebRtcSpl_MinValueW32; 28 | CrossCorrelation WebRtcSpl_CrossCorrelation; 29 | DownsampleFast WebRtcSpl_DownsampleFast; 30 | ScaleAndAddVectorsWithRound WebRtcSpl_ScaleAndAddVectorsWithRound; 31 | CreateRealFFT WebRtcSpl_CreateRealFFT; 32 | FreeRealFFT WebRtcSpl_FreeRealFFT; 33 | RealForwardFFT WebRtcSpl_RealForwardFFT; 34 | RealInverseFFT WebRtcSpl_RealInverseFFT; 35 | 36 | #if (defined(WEBRTC_DETECT_ARM_NEON) || !defined(WEBRTC_ARCH_ARM_NEON)) && \ 37 | !defined(MIPS32_LE) 38 | /* Initialize function pointers to the generic C version. */ 39 | static void InitPointersToC() { 40 | WebRtcSpl_MaxAbsValueW16 = WebRtcSpl_MaxAbsValueW16C; 41 | WebRtcSpl_MaxAbsValueW32 = WebRtcSpl_MaxAbsValueW32C; 42 | WebRtcSpl_MaxValueW16 = WebRtcSpl_MaxValueW16C; 43 | WebRtcSpl_MaxValueW32 = WebRtcSpl_MaxValueW32C; 44 | WebRtcSpl_MinValueW16 = WebRtcSpl_MinValueW16C; 45 | WebRtcSpl_MinValueW32 = WebRtcSpl_MinValueW32C; 46 | WebRtcSpl_CrossCorrelation = WebRtcSpl_CrossCorrelationC; 47 | WebRtcSpl_DownsampleFast = WebRtcSpl_DownsampleFastC; 48 | WebRtcSpl_ScaleAndAddVectorsWithRound = 49 | WebRtcSpl_ScaleAndAddVectorsWithRoundC; 50 | WebRtcSpl_CreateRealFFT = WebRtcSpl_CreateRealFFTC; 51 | WebRtcSpl_FreeRealFFT = WebRtcSpl_FreeRealFFTC; 52 | WebRtcSpl_RealForwardFFT = WebRtcSpl_RealForwardFFTC; 53 | WebRtcSpl_RealInverseFFT = WebRtcSpl_RealInverseFFTC; 54 | } 55 | #endif 56 | 57 | #if defined(WEBRTC_DETECT_ARM_NEON) || defined(WEBRTC_ARCH_ARM_NEON) 58 | /* Initialize function pointers to the Neon version. */ 59 | static void InitPointersToNeon() { 60 | WebRtcSpl_MaxAbsValueW16 = WebRtcSpl_MaxAbsValueW16Neon; 61 | WebRtcSpl_MaxAbsValueW32 = WebRtcSpl_MaxAbsValueW32Neon; 62 | WebRtcSpl_MaxValueW16 = WebRtcSpl_MaxValueW16Neon; 63 | WebRtcSpl_MaxValueW32 = WebRtcSpl_MaxValueW32Neon; 64 | WebRtcSpl_MinValueW16 = WebRtcSpl_MinValueW16Neon; 65 | WebRtcSpl_MinValueW32 = WebRtcSpl_MinValueW32Neon; 66 | WebRtcSpl_CrossCorrelation = WebRtcSpl_CrossCorrelationNeon; 67 | WebRtcSpl_DownsampleFast = WebRtcSpl_DownsampleFastNeon; 68 | /* TODO(henrik.lundin): re-enable NEON when the crash from bug 3243 is 69 | understood. */ 70 | WebRtcSpl_ScaleAndAddVectorsWithRound = 71 | WebRtcSpl_ScaleAndAddVectorsWithRoundC; 72 | WebRtcSpl_CreateRealFFT = WebRtcSpl_CreateRealFFTNeon; 73 | WebRtcSpl_FreeRealFFT = WebRtcSpl_FreeRealFFTNeon; 74 | WebRtcSpl_RealForwardFFT = WebRtcSpl_RealForwardFFTNeon; 75 | WebRtcSpl_RealInverseFFT = WebRtcSpl_RealInverseFFTNeon; 76 | } 77 | #endif 78 | 79 | #if defined(MIPS32_LE) 80 | /* Initialize function pointers to the MIPS version. */ 81 | static void InitPointersToMIPS() { 82 | WebRtcSpl_MaxAbsValueW16 = WebRtcSpl_MaxAbsValueW16_mips; 83 | WebRtcSpl_MaxValueW16 = WebRtcSpl_MaxValueW16_mips; 84 | WebRtcSpl_MaxValueW32 = WebRtcSpl_MaxValueW32_mips; 85 | WebRtcSpl_MinValueW16 = WebRtcSpl_MinValueW16_mips; 86 | WebRtcSpl_MinValueW32 = WebRtcSpl_MinValueW32_mips; 87 | WebRtcSpl_CrossCorrelation = WebRtcSpl_CrossCorrelation_mips; 88 | WebRtcSpl_DownsampleFast = WebRtcSpl_DownsampleFast_mips; 89 | WebRtcSpl_CreateRealFFT = WebRtcSpl_CreateRealFFTC; 90 | WebRtcSpl_FreeRealFFT = WebRtcSpl_FreeRealFFTC; 91 | WebRtcSpl_RealForwardFFT = WebRtcSpl_RealForwardFFTC; 92 | WebRtcSpl_RealInverseFFT = WebRtcSpl_RealInverseFFTC; 93 | #if defined(MIPS_DSP_R1_LE) 94 | WebRtcSpl_MaxAbsValueW32 = WebRtcSpl_MaxAbsValueW32_mips; 95 | WebRtcSpl_ScaleAndAddVectorsWithRound = 96 | WebRtcSpl_ScaleAndAddVectorsWithRound_mips; 97 | #else 98 | WebRtcSpl_MaxAbsValueW32 = WebRtcSpl_MaxAbsValueW32C; 99 | WebRtcSpl_ScaleAndAddVectorsWithRound = 100 | WebRtcSpl_ScaleAndAddVectorsWithRoundC; 101 | #endif 102 | } 103 | #endif 104 | 105 | static void InitFunctionPointers(void) { 106 | #if defined(WEBRTC_DETECT_ARM_NEON) 107 | if ((WebRtc_GetCPUFeaturesARM() & kCPUFeatureNEON) != 0) { 108 | InitPointersToNeon(); 109 | } else { 110 | InitPointersToC(); 111 | } 112 | #elif defined(WEBRTC_ARCH_ARM_NEON) 113 | InitPointersToNeon(); 114 | #elif defined(MIPS32_LE) 115 | InitPointersToMIPS(); 116 | #else 117 | InitPointersToC(); 118 | #endif /* WEBRTC_DETECT_ARM_NEON */ 119 | } 120 | 121 | #if defined(WEBRTC_POSIX) 122 | #include 123 | 124 | static void once(void (*func)(void)) { 125 | static pthread_once_t lock = PTHREAD_ONCE_INIT; 126 | pthread_once(&lock, func); 127 | } 128 | 129 | #elif defined(_WIN32) 130 | #include 131 | 132 | static void once(void (*func)(void)) { 133 | /* Didn't use InitializeCriticalSection() since there's no race-free context 134 | * in which to execute it. 135 | * 136 | * TODO(kma): Change to different implementation (e.g. 137 | * InterlockedCompareExchangePointer) to avoid issues similar to 138 | * http://code.google.com/p/webm/issues/detail?id=467. 139 | */ 140 | static CRITICAL_SECTION lock = {(void *)((size_t)-1), -1, 0, 0, 0, 0}; 141 | static int done = 0; 142 | 143 | EnterCriticalSection(&lock); 144 | if (!done) { 145 | func(); 146 | done = 1; 147 | } 148 | LeaveCriticalSection(&lock); 149 | } 150 | 151 | /* There's no fallback version as an #else block here to ensure thread safety. 152 | * In case of neither pthread for WEBRTC_POSIX nor _WIN32 is present, build 153 | * system should pick it up. 154 | */ 155 | #endif /* WEBRTC_POSIX */ 156 | 157 | void WebRtcSpl_Init() { 158 | once(InitFunctionPointers); 159 | } 160 | -------------------------------------------------------------------------------- /WebRtcMoudle/spl_inl.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 header file includes the inline functions in 13 | // the fix point signal processing library. 14 | 15 | #ifndef WEBRTC_SPL_SPL_INL_H_ 16 | #define WEBRTC_SPL_SPL_INL_H_ 17 | 18 | #ifdef WEBRTC_ARCH_ARM_V7 19 | #include "webrtc/common_audio/signal_processing/include/spl_inl_armv7.h" 20 | #else 21 | 22 | #if defined(MIPS32_LE) 23 | #include "webrtc/common_audio/signal_processing/include/spl_inl_mips.h" 24 | #endif 25 | 26 | #if !defined(MIPS_DSP_R1_LE) 27 | static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) { 28 | int16_t out16 = (int16_t) value32; 29 | 30 | if (value32 > 32767) 31 | out16 = 32767; 32 | else if (value32 < -32768) 33 | out16 = -32768; 34 | 35 | return out16; 36 | } 37 | 38 | static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) { 39 | return WebRtcSpl_SatW32ToW16((int32_t) a + (int32_t) b); 40 | } 41 | 42 | static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) { 43 | return WebRtcSpl_SatW32ToW16((int32_t) var1 - (int32_t) var2); 44 | } 45 | #endif // #if !defined(MIPS_DSP_R1_LE) 46 | 47 | #if !defined(MIPS32_LE) 48 | static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) { 49 | int bits; 50 | 51 | if (0xFFFF0000 & n) { 52 | bits = 16; 53 | } else { 54 | bits = 0; 55 | } 56 | if (0x0000FF00 & (n >> bits)) bits += 8; 57 | if (0x000000F0 & (n >> bits)) bits += 4; 58 | if (0x0000000C & (n >> bits)) bits += 2; 59 | if (0x00000002 & (n >> bits)) bits += 1; 60 | if (0x00000001 & (n >> bits)) bits += 1; 61 | 62 | return bits; 63 | } 64 | 65 | static __inline int WebRtcSpl_NormW32(int32_t a) { 66 | int zeros; 67 | 68 | if (a == 0) { 69 | return 0; 70 | } 71 | else if (a < 0) { 72 | a = ~a; 73 | } 74 | 75 | if (!(0xFFFF8000 & a)) { 76 | zeros = 16; 77 | } else { 78 | zeros = 0; 79 | } 80 | if (!(0xFF800000 & (a << zeros))) zeros += 8; 81 | if (!(0xF8000000 & (a << zeros))) zeros += 4; 82 | if (!(0xE0000000 & (a << zeros))) zeros += 2; 83 | if (!(0xC0000000 & (a << zeros))) zeros += 1; 84 | 85 | return zeros; 86 | } 87 | 88 | static __inline int WebRtcSpl_NormU32(uint32_t a) { 89 | int zeros; 90 | 91 | if (a == 0) return 0; 92 | 93 | if (!(0xFFFF0000 & a)) { 94 | zeros = 16; 95 | } else { 96 | zeros = 0; 97 | } 98 | if (!(0xFF000000 & (a << zeros))) zeros += 8; 99 | if (!(0xF0000000 & (a << zeros))) zeros += 4; 100 | if (!(0xC0000000 & (a << zeros))) zeros += 2; 101 | if (!(0x80000000 & (a << zeros))) zeros += 1; 102 | 103 | return zeros; 104 | } 105 | 106 | static __inline int WebRtcSpl_NormW16(int16_t a) { 107 | int zeros; 108 | 109 | if (a == 0) { 110 | return 0; 111 | } 112 | else if (a < 0) { 113 | a = ~a; 114 | } 115 | 116 | if (!(0xFF80 & a)) { 117 | zeros = 8; 118 | } else { 119 | zeros = 0; 120 | } 121 | if (!(0xF800 & (a << zeros))) zeros += 4; 122 | if (!(0xE000 & (a << zeros))) zeros += 2; 123 | if (!(0xC000 & (a << zeros))) zeros += 1; 124 | 125 | return zeros; 126 | } 127 | 128 | static __inline int32_t WebRtc_MulAccumW16(int16_t a, int16_t b, int32_t c) { 129 | return (a * b + c); 130 | } 131 | #endif // #if !defined(MIPS32_LE) 132 | 133 | #endif // WEBRTC_ARCH_ARM_V7 134 | 135 | // The following functions have no optimized versions. 136 | // TODO(kma): Consider saturating add/sub instructions in X86 platform. 137 | #if !defined(MIPS_DSP_R1_LE) 138 | static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) { 139 | int32_t l_sum; 140 | 141 | // Perform long addition 142 | l_sum = l_var1 + l_var2; 143 | 144 | if (l_var1 < 0) { // Check for underflow. 145 | if ((l_var2 < 0) && (l_sum >= 0)) { 146 | l_sum = (int32_t)0x80000000; 147 | } 148 | } else { // Check for overflow. 149 | if ((l_var2 > 0) && (l_sum < 0)) { 150 | l_sum = (int32_t)0x7FFFFFFF; 151 | } 152 | } 153 | 154 | return l_sum; 155 | } 156 | 157 | static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) { 158 | int32_t l_diff; 159 | 160 | // Perform subtraction. 161 | l_diff = l_var1 - l_var2; 162 | 163 | if (l_var1 < 0) { // Check for underflow. 164 | if ((l_var2 > 0) && (l_diff > 0)) { 165 | l_diff = (int32_t)0x80000000; 166 | } 167 | } else { // Check for overflow. 168 | if ((l_var2 < 0) && (l_diff < 0)) { 169 | l_diff = (int32_t)0x7FFFFFFF; 170 | } 171 | } 172 | 173 | return l_diff; 174 | } 175 | #endif // #if !defined(MIPS_DSP_R1_LE) 176 | 177 | #endif // WEBRTC_SPL_SPL_INL_H_ 178 | -------------------------------------------------------------------------------- /WebRtcMoudle/spl_sqrt.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_Sqrt(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | int32_t WebRtcSpl_SqrtLocal(int32_t in); 21 | 22 | int32_t WebRtcSpl_SqrtLocal(int32_t in) 23 | { 24 | 25 | int16_t x_half, t16; 26 | int32_t A, B, x2; 27 | 28 | /* The following block performs: 29 | y=in/2 30 | x=y-2^30 31 | x_half=x/2^31 32 | t = 1 + (x_half) - 0.5*((x_half)^2) + 0.5*((x_half)^3) - 0.625*((x_half)^4) 33 | + 0.875*((x_half)^5) 34 | */ 35 | 36 | B = in; 37 | 38 | B = WEBRTC_SPL_RSHIFT_W32(B, 1); // B = in/2 39 | B = B - ((int32_t)0x40000000); // B = in/2 - 1/2 40 | x_half = (int16_t)WEBRTC_SPL_RSHIFT_W32(B, 16);// x_half = x/2 = (in-1)/2 41 | B = B + ((int32_t)0x40000000); // B = 1 + x/2 42 | B = B + ((int32_t)0x40000000); // Add 0.5 twice (since 1.0 does not exist in Q31) 43 | 44 | x2 = ((int32_t)x_half) * ((int32_t)x_half) * 2; // A = (x/2)^2 45 | A = -x2; // A = -(x/2)^2 46 | B = B + (A >> 1); // B = 1 + x/2 - 0.5*(x/2)^2 47 | 48 | A = WEBRTC_SPL_RSHIFT_W32(A, 16); 49 | A = A * A * 2; // A = (x/2)^4 50 | t16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(A, 16); 51 | B = B + WEBRTC_SPL_MUL_16_16(-20480, t16) * 2; // B = B - 0.625*A 52 | // After this, B = 1 + x/2 - 0.5*(x/2)^2 - 0.625*(x/2)^4 53 | 54 | t16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(A, 16); 55 | A = WEBRTC_SPL_MUL_16_16(x_half, t16) * 2; // A = (x/2)^5 56 | t16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(A, 16); 57 | B = B + WEBRTC_SPL_MUL_16_16(28672, t16) * 2; // B = B + 0.875*A 58 | // After this, B = 1 + x/2 - 0.5*(x/2)^2 - 0.625*(x/2)^4 + 0.875*(x/2)^5 59 | 60 | t16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(x2, 16); 61 | A = WEBRTC_SPL_MUL_16_16(x_half, t16) * 2; // A = x/2^3 62 | 63 | B = B + (A >> 1); // B = B + 0.5*A 64 | // After this, B = 1 + x/2 - 0.5*(x/2)^2 + 0.5*(x/2)^3 - 0.625*(x/2)^4 + 0.875*(x/2)^5 65 | 66 | B = B + ((int32_t)32768); // Round off bit 67 | 68 | return B; 69 | } 70 | 71 | int32_t WebRtcSpl_Sqrt(int32_t value) 72 | { 73 | /* 74 | Algorithm: 75 | 76 | Six term Taylor Series is used here to compute the square root of a number 77 | y^0.5 = (1+x)^0.5 where x = y-1 78 | = 1+(x/2)-0.5*((x/2)^2+0.5*((x/2)^3-0.625*((x/2)^4+0.875*((x/2)^5) 79 | 0.5 <= x < 1 80 | 81 | Example of how the algorithm works, with ut=sqrt(in), and 82 | with in=73632 and ut=271 (even shift value case): 83 | 84 | in=73632 85 | y= in/131072 86 | x=y-1 87 | t = 1 + (x/2) - 0.5*((x/2)^2) + 0.5*((x/2)^3) - 0.625*((x/2)^4) + 0.875*((x/2)^5) 88 | ut=t*(1/sqrt(2))*512 89 | 90 | or: 91 | 92 | in=73632 93 | in2=73632*2^14 94 | y= in2/2^31 95 | x=y-1 96 | t = 1 + (x/2) - 0.5*((x/2)^2) + 0.5*((x/2)^3) - 0.625*((x/2)^4) + 0.875*((x/2)^5) 97 | ut=t*(1/sqrt(2)) 98 | ut2=ut*2^9 99 | 100 | which gives: 101 | 102 | in = 73632 103 | in2 = 1206386688 104 | y = 0.56176757812500 105 | x = -0.43823242187500 106 | t = 0.74973506527313 107 | ut = 0.53014274874797 108 | ut2 = 2.714330873589594e+002 109 | 110 | or: 111 | 112 | in=73632 113 | in2=73632*2^14 114 | y=in2/2 115 | x=y-2^30 116 | x_half=x/2^31 117 | t = 1 + (x_half) - 0.5*((x_half)^2) + 0.5*((x_half)^3) - 0.625*((x_half)^4) 118 | + 0.875*((x_half)^5) 119 | ut=t*(1/sqrt(2)) 120 | ut2=ut*2^9 121 | 122 | which gives: 123 | 124 | in = 73632 125 | in2 = 1206386688 126 | y = 603193344 127 | x = -470548480 128 | x_half = -0.21911621093750 129 | t = 0.74973506527313 130 | ut = 0.53014274874797 131 | ut2 = 2.714330873589594e+002 132 | 133 | */ 134 | 135 | int16_t x_norm, nshift, t16, sh; 136 | int32_t A; 137 | 138 | int16_t k_sqrt_2 = 23170; // 1/sqrt2 (==5a82) 139 | 140 | A = value; 141 | 142 | if (A == 0) 143 | return (int32_t)0; // sqrt(0) = 0 144 | 145 | sh = WebRtcSpl_NormW32(A); // # shifts to normalize A 146 | A = WEBRTC_SPL_LSHIFT_W32(A, sh); // Normalize A 147 | if (A < (WEBRTC_SPL_WORD32_MAX - 32767)) 148 | { 149 | A = A + ((int32_t)32768); // Round off bit 150 | } else 151 | { 152 | A = WEBRTC_SPL_WORD32_MAX; 153 | } 154 | 155 | x_norm = (int16_t)WEBRTC_SPL_RSHIFT_W32(A, 16); // x_norm = AH 156 | 157 | nshift = WEBRTC_SPL_RSHIFT_W16(sh, 1); // nshift = sh>>1 158 | nshift = -nshift; // Negate the power for later de-normalization 159 | 160 | A = (int32_t)WEBRTC_SPL_LSHIFT_W32((int32_t)x_norm, 16); 161 | A = WEBRTC_SPL_ABS_W32(A); // A = abs(x_norm<<16) 162 | A = WebRtcSpl_SqrtLocal(A); // A = sqrt(A) 163 | 164 | if ((-2 * nshift) == sh) 165 | { // Even shift value case 166 | 167 | t16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(A, 16); // t16 = AH 168 | 169 | A = WEBRTC_SPL_MUL_16_16(k_sqrt_2, t16) * 2; // A = 1/sqrt(2)*t16 170 | A = A + ((int32_t)32768); // Round off 171 | A = A & ((int32_t)0x7fff0000); // Round off 172 | 173 | A = WEBRTC_SPL_RSHIFT_W32(A, 15); // A = A>>16 174 | 175 | } else 176 | { 177 | A = WEBRTC_SPL_RSHIFT_W32(A, 16); // A = A>>16 178 | } 179 | 180 | A = A & ((int32_t)0x0000ffff); 181 | A = (int32_t)WEBRTC_SPL_SHIFT_W32(A, nshift); // De-normalize the result 182 | 183 | return A; 184 | } 185 | -------------------------------------------------------------------------------- /WebRtcMoudle/spl_sqrt_floor.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by Wilco Dijkstra, 1996. The following email exchange establishes the 3 | * license. 4 | * 5 | * From: Wilco Dijkstra 6 | * Date: Fri, Jun 24, 2011 at 3:20 AM 7 | * Subject: Re: sqrt routine 8 | * To: Kevin Ma 9 | * Hi Kevin, 10 | * Thanks for asking. Those routines are public domain (originally posted to 11 | * comp.sys.arm a long time ago), so you can use them freely for any purpose. 12 | * Cheers, 13 | * Wilco 14 | * 15 | * ----- Original Message ----- 16 | * From: "Kevin Ma" 17 | * To: 18 | * Sent: Thursday, June 23, 2011 11:44 PM 19 | * Subject: Fwd: sqrt routine 20 | * Hi Wilco, 21 | * I saw your sqrt routine from several web sites, including 22 | * http://www.finesse.demon.co.uk/steven/sqrt.html. 23 | * Just wonder if there's any copyright information with your Successive 24 | * approximation routines, or if I can freely use it for any purpose. 25 | * Thanks. 26 | * Kevin 27 | */ 28 | 29 | // Minor modifications in code style for WebRTC, 2012. 30 | 31 | #include "signal_processing_library.h" 32 | 33 | /* 34 | * Algorithm: 35 | * Successive approximation of the equation (root + delta) ^ 2 = N 36 | * until delta < 1. If delta < 1 we have the integer part of SQRT (N). 37 | * Use delta = 2^i for i = 15 .. 0. 38 | * 39 | * Output precision is 16 bits. Note for large input values (close to 40 | * 0x7FFFFFFF), bit 15 (the highest bit of the low 16-bit half word) 41 | * contains the MSB information (a non-sign value). Do with caution 42 | * if you need to cast the output to int16_t type. 43 | * 44 | * If the input value is negative, it returns 0. 45 | */ 46 | 47 | #define WEBRTC_SPL_SQRT_ITER(N) \ 48 | try1 = root + (1 << (N)); \ 49 | if (value >= try1 << (N)) \ 50 | { \ 51 | value -= try1 << (N); \ 52 | root |= 2 << (N); \ 53 | } 54 | 55 | int32_t WebRtcSpl_SqrtFloor(int32_t value) 56 | { 57 | int32_t root = 0, try1; 58 | 59 | WEBRTC_SPL_SQRT_ITER (15); 60 | WEBRTC_SPL_SQRT_ITER (14); 61 | WEBRTC_SPL_SQRT_ITER (13); 62 | WEBRTC_SPL_SQRT_ITER (12); 63 | WEBRTC_SPL_SQRT_ITER (11); 64 | WEBRTC_SPL_SQRT_ITER (10); 65 | WEBRTC_SPL_SQRT_ITER ( 9); 66 | WEBRTC_SPL_SQRT_ITER ( 8); 67 | WEBRTC_SPL_SQRT_ITER ( 7); 68 | WEBRTC_SPL_SQRT_ITER ( 6); 69 | WEBRTC_SPL_SQRT_ITER ( 5); 70 | WEBRTC_SPL_SQRT_ITER ( 4); 71 | WEBRTC_SPL_SQRT_ITER ( 3); 72 | WEBRTC_SPL_SQRT_ITER ( 2); 73 | WEBRTC_SPL_SQRT_ITER ( 1); 74 | WEBRTC_SPL_SQRT_ITER ( 0); 75 | 76 | return root >> 1; 77 | } 78 | -------------------------------------------------------------------------------- /WebRtcMoudle/splitting_filter.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 | * This file contains the splitting filter functions. 13 | * 14 | */ 15 | 16 | #include "signal_processing_library.h" 17 | 18 | #include 19 | 20 | // Maximum number of samples in a low/high-band frame. 21 | enum 22 | { 23 | kMaxBandFrameLength = 240 // 10 ms at 48 kHz. 24 | }; 25 | 26 | // QMF filter coefficients in Q16. 27 | static const uint16_t WebRtcSpl_kAllPassFilter1[3] = {6418, 36982, 57261}; 28 | static const uint16_t WebRtcSpl_kAllPassFilter2[3] = {21333, 49062, 63010}; 29 | 30 | /////////////////////////////////////////////////////////////////////////////////////////////// 31 | // WebRtcSpl_AllPassQMF(...) 32 | // 33 | // Allpass filter used by the analysis and synthesis parts of the QMF filter. 34 | // 35 | // Input: 36 | // - in_data : Input data sequence (Q10) 37 | // - data_length : Length of data sequence (>2) 38 | // - filter_coefficients : Filter coefficients (length 3, Q16) 39 | // 40 | // Input & Output: 41 | // - filter_state : Filter state (length 6, Q10). 42 | // 43 | // Output: 44 | // - out_data : Output data sequence (Q10), length equal to 45 | // |data_length| 46 | // 47 | 48 | void WebRtcSpl_AllPassQMF(int32_t* in_data, int16_t data_length, 49 | int32_t* out_data, const uint16_t* filter_coefficients, 50 | int32_t* filter_state) 51 | { 52 | // The procedure is to filter the input with three first order all pass filters 53 | // (cascade operations). 54 | // 55 | // a_3 + q^-1 a_2 + q^-1 a_1 + q^-1 56 | // y[n] = ----------- ----------- ----------- x[n] 57 | // 1 + a_3q^-1 1 + a_2q^-1 1 + a_1q^-1 58 | // 59 | // The input vector |filter_coefficients| includes these three filter coefficients. 60 | // The filter state contains the in_data state, in_data[-1], followed by 61 | // the out_data state, out_data[-1]. This is repeated for each cascade. 62 | // The first cascade filter will filter the |in_data| and store the output in 63 | // |out_data|. The second will the take the |out_data| as input and make an 64 | // intermediate storage in |in_data|, to save memory. The third, and final, cascade 65 | // filter operation takes the |in_data| (which is the output from the previous cascade 66 | // filter) and store the output in |out_data|. 67 | // Note that the input vector values are changed during the process. 68 | int16_t k; 69 | int32_t diff; 70 | // First all-pass cascade; filter from in_data to out_data. 71 | 72 | // Let y_i[n] indicate the output of cascade filter i (with filter coefficient a_i) at 73 | // vector position n. Then the final output will be y[n] = y_3[n] 74 | 75 | // First loop, use the states stored in memory. 76 | // "diff" should be safe from wrap around since max values are 2^25 77 | diff = WEBRTC_SPL_SUB_SAT_W32(in_data[0], filter_state[1]); // = (x[0] - y_1[-1]) 78 | // y_1[0] = x[-1] + a_1 * (x[0] - y_1[-1]) 79 | out_data[0] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[0], diff, filter_state[0]); 80 | 81 | // For the remaining loops, use previous values. 82 | for (k = 1; k < data_length; k++) 83 | { 84 | diff = WEBRTC_SPL_SUB_SAT_W32(in_data[k], out_data[k - 1]); // = (x[n] - y_1[n-1]) 85 | // y_1[n] = x[n-1] + a_1 * (x[n] - y_1[n-1]) 86 | out_data[k] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[0], diff, in_data[k - 1]); 87 | } 88 | 89 | // Update states. 90 | filter_state[0] = in_data[data_length - 1]; // x[N-1], becomes x[-1] next time 91 | filter_state[1] = out_data[data_length - 1]; // y_1[N-1], becomes y_1[-1] next time 92 | 93 | // Second all-pass cascade; filter from out_data to in_data. 94 | diff = WEBRTC_SPL_SUB_SAT_W32(out_data[0], filter_state[3]); // = (y_1[0] - y_2[-1]) 95 | // y_2[0] = y_1[-1] + a_2 * (y_1[0] - y_2[-1]) 96 | in_data[0] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[1], diff, filter_state[2]); 97 | for (k = 1; k < data_length; k++) 98 | { 99 | diff = WEBRTC_SPL_SUB_SAT_W32(out_data[k], in_data[k - 1]); // =(y_1[n] - y_2[n-1]) 100 | // y_2[0] = y_1[-1] + a_2 * (y_1[0] - y_2[-1]) 101 | in_data[k] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[1], diff, out_data[k-1]); 102 | } 103 | 104 | filter_state[2] = out_data[data_length - 1]; // y_1[N-1], becomes y_1[-1] next time 105 | filter_state[3] = in_data[data_length - 1]; // y_2[N-1], becomes y_2[-1] next time 106 | 107 | // Third all-pass cascade; filter from in_data to out_data. 108 | diff = WEBRTC_SPL_SUB_SAT_W32(in_data[0], filter_state[5]); // = (y_2[0] - y[-1]) 109 | // y[0] = y_2[-1] + a_3 * (y_2[0] - y[-1]) 110 | out_data[0] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[2], diff, filter_state[4]); 111 | for (k = 1; k < data_length; k++) 112 | { 113 | diff = WEBRTC_SPL_SUB_SAT_W32(in_data[k], out_data[k - 1]); // = (y_2[n] - y[n-1]) 114 | // y[n] = y_2[n-1] + a_3 * (y_2[n] - y[n-1]) 115 | out_data[k] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[2], diff, in_data[k-1]); 116 | } 117 | filter_state[4] = in_data[data_length - 1]; // y_2[N-1], becomes y_2[-1] next time 118 | filter_state[5] = out_data[data_length - 1]; // y[N-1], becomes y[-1] next time 119 | } 120 | 121 | void WebRtcSpl_AnalysisQMF(const int16_t* in_data, int in_data_length, 122 | int16_t* low_band, int16_t* high_band, 123 | int32_t* filter_state1, int32_t* filter_state2) 124 | { 125 | int16_t i; 126 | int16_t k; 127 | int32_t tmp; 128 | int32_t half_in1[kMaxBandFrameLength]; 129 | int32_t half_in2[kMaxBandFrameLength]; 130 | int32_t filter1[kMaxBandFrameLength]; 131 | int32_t filter2[kMaxBandFrameLength]; 132 | const int band_length = in_data_length / 2; 133 | assert(in_data_length % 2 == 0); 134 | assert(band_length <= kMaxBandFrameLength); 135 | 136 | // Split even and odd samples. Also shift them to Q10. 137 | for (i = 0, k = 0; i < band_length; i++, k += 2) 138 | { 139 | half_in2[i] = WEBRTC_SPL_LSHIFT_W32((int32_t)in_data[k], 10); 140 | half_in1[i] = WEBRTC_SPL_LSHIFT_W32((int32_t)in_data[k + 1], 10); 141 | } 142 | 143 | // All pass filter even and odd samples, independently. 144 | WebRtcSpl_AllPassQMF(half_in1, band_length, filter1, 145 | WebRtcSpl_kAllPassFilter1, filter_state1); 146 | WebRtcSpl_AllPassQMF(half_in2, band_length, filter2, 147 | WebRtcSpl_kAllPassFilter2, filter_state2); 148 | 149 | // Take the sum and difference of filtered version of odd and even 150 | // branches to get upper & lower band. 151 | for (i = 0; i < band_length; i++) 152 | { 153 | tmp = filter1[i] + filter2[i] + 1024; 154 | tmp = WEBRTC_SPL_RSHIFT_W32(tmp, 11); 155 | low_band[i] = WebRtcSpl_SatW32ToW16(tmp); 156 | 157 | tmp = filter1[i] - filter2[i] + 1024; 158 | tmp = WEBRTC_SPL_RSHIFT_W32(tmp, 11); 159 | high_band[i] = WebRtcSpl_SatW32ToW16(tmp); 160 | } 161 | } 162 | 163 | void WebRtcSpl_SynthesisQMF(const int16_t* low_band, const int16_t* high_band, 164 | int band_length, int16_t* out_data, 165 | int32_t* filter_state1, int32_t* filter_state2) 166 | { 167 | int32_t tmp; 168 | int32_t half_in1[kMaxBandFrameLength]; 169 | int32_t half_in2[kMaxBandFrameLength]; 170 | int32_t filter1[kMaxBandFrameLength]; 171 | int32_t filter2[kMaxBandFrameLength]; 172 | int16_t i; 173 | int16_t k; 174 | assert(band_length <= kMaxBandFrameLength); 175 | 176 | // Obtain the sum and difference channels out of upper and lower-band channels. 177 | // Also shift to Q10 domain. 178 | for (i = 0; i < band_length; i++) 179 | { 180 | tmp = (int32_t)low_band[i] + (int32_t)high_band[i]; 181 | half_in1[i] = WEBRTC_SPL_LSHIFT_W32(tmp, 10); 182 | tmp = (int32_t)low_band[i] - (int32_t)high_band[i]; 183 | half_in2[i] = WEBRTC_SPL_LSHIFT_W32(tmp, 10); 184 | } 185 | 186 | // all-pass filter the sum and difference channels 187 | WebRtcSpl_AllPassQMF(half_in1, band_length, filter1, 188 | WebRtcSpl_kAllPassFilter2, filter_state1); 189 | WebRtcSpl_AllPassQMF(half_in2, band_length, filter2, 190 | WebRtcSpl_kAllPassFilter1, filter_state2); 191 | 192 | // The filtered signals are even and odd samples of the output. Combine 193 | // them. The signals are Q10 should shift them back to Q0 and take care of 194 | // saturation. 195 | for (i = 0, k = 0; i < band_length; i++) 196 | { 197 | tmp = WEBRTC_SPL_RSHIFT_W32(filter2[i] + 512, 10); 198 | out_data[k++] = WebRtcSpl_SatW32ToW16(tmp); 199 | 200 | tmp = WEBRTC_SPL_RSHIFT_W32(filter1[i] + 512, 10); 201 | out_data[k++] = WebRtcSpl_SatW32ToW16(tmp); 202 | } 203 | 204 | } 205 | -------------------------------------------------------------------------------- /WebRtcMoudle/typedefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // This file contains platform-specific typedefs and defines. 12 | // Much of it is derived from Chromium's build/build_config.h. 13 | 14 | #ifndef WEBRTC_TYPEDEFS_H_ 15 | #define WEBRTC_TYPEDEFS_H_ 16 | 17 | // Processor architecture detection. For more info on what's defined, see: 18 | // http://msdn.microsoft.com/en-us/library/b0084kay.aspx 19 | // http://www.agner.org/optimize/calling_conventions.pdf 20 | // or with gcc, run: "echo | gcc -E -dM -" 21 | #if defined(_M_X64) || defined(__x86_64__) 22 | #define WEBRTC_ARCH_X86_FAMILY 23 | #define WEBRTC_ARCH_X86_64 24 | #define WEBRTC_ARCH_64_BITS 25 | #define WEBRTC_ARCH_LITTLE_ENDIAN 26 | #elif defined(__aarch64__) 27 | #define WEBRTC_ARCH_64_BITS 28 | #define WEBRTC_ARCH_LITTLE_ENDIAN 29 | #elif defined(_M_IX86) || defined(__i386__) 30 | #define WEBRTC_ARCH_X86_FAMILY 31 | #define WEBRTC_ARCH_X86 32 | #define WEBRTC_ARCH_32_BITS 33 | #define WEBRTC_ARCH_LITTLE_ENDIAN 34 | #elif defined(__ARMEL__) 35 | // TODO(ajm): We'd prefer to control platform defines here, but this is 36 | // currently provided by the Android makefiles. Commented to avoid duplicate 37 | // definition warnings. 38 | //#define WEBRTC_ARCH_ARM 39 | // TODO(ajm): Chromium uses the following two defines. Should we switch? 40 | //#define WEBRTC_ARCH_ARM_FAMILY 41 | //#define WEBRTC_ARCH_ARMEL 42 | #define WEBRTC_ARCH_32_BITS 43 | #define WEBRTC_ARCH_LITTLE_ENDIAN 44 | #elif defined(__MIPSEL__) 45 | #define WEBRTC_ARCH_32_BITS 46 | #define WEBRTC_ARCH_LITTLE_ENDIAN 47 | #elif defined(__pnacl__) 48 | #define WEBRTC_ARCH_32_BITS 49 | #define WEBRTC_ARCH_LITTLE_ENDIAN 50 | #else 51 | #error Please add support for your architecture in typedefs.h 52 | #endif 53 | 54 | #if !(defined(WEBRTC_ARCH_LITTLE_ENDIAN) ^ defined(WEBRTC_ARCH_BIG_ENDIAN)) 55 | #error Define either WEBRTC_ARCH_LITTLE_ENDIAN or WEBRTC_ARCH_BIG_ENDIAN 56 | #endif 57 | 58 | #if (defined(WEBRTC_ARCH_X86_FAMILY) && !defined(__SSE2__)) || \ 59 | (defined(WEBRTC_ARCH_ARM_V7) && !defined(WEBRTC_ARCH_ARM_NEON)) 60 | #define WEBRTC_CPU_DETECTION 61 | #endif 62 | 63 | #if !defined(_MSC_VER) 64 | #include 65 | #else 66 | // Define C99 equivalent types, since pre-2010 MSVC doesn't provide stdint.h. 67 | typedef signed char int8_t; 68 | typedef signed short int16_t; 69 | typedef signed int int32_t; 70 | typedef __int64 int64_t; 71 | typedef unsigned char uint8_t; 72 | typedef unsigned short uint16_t; 73 | typedef unsigned int uint32_t; 74 | typedef unsigned __int64 uint64_t; 75 | #endif 76 | 77 | // Borrowed from Chromium's base/compiler_specific.h. 78 | // Annotate a virtual method indicating it must be overriding a virtual 79 | // method in the parent class. 80 | // Use like: 81 | // virtual void foo() OVERRIDE; 82 | #if defined(_MSC_VER) 83 | #define OVERRIDE override 84 | #elif defined(__clang__) 85 | // Clang defaults to C++03 and warns about using override. Squelch that. 86 | // Intentionally no push/pop here so all users of OVERRIDE ignore the warning 87 | // too. This is like passing -Wno-c++11-extensions, except that GCC won't die 88 | // (because it won't see this pragma). 89 | #pragma clang diagnostic ignored "-Wc++11-extensions" 90 | #define OVERRIDE override 91 | #elif defined(__GNUC__) && __cplusplus >= 201103 && \ 92 | (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 93 | // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. 94 | #define OVERRIDE override 95 | #else 96 | #define OVERRIDE 97 | #endif 98 | 99 | // Annotate a function indicating the caller must examine the return value. 100 | // Use like: 101 | // int foo() WARN_UNUSED_RESULT; 102 | // TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and 103 | // libjingle are merged. 104 | #if !defined(WARN_UNUSED_RESULT) 105 | #if defined(__GNUC__) 106 | #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 107 | #else 108 | #define WARN_UNUSED_RESULT 109 | #endif 110 | #endif // WARN_UNUSED_RESULT 111 | 112 | #endif // WEBRTC_TYPEDEFS_H_ 113 | -------------------------------------------------------------------------------- /WebRtcMoudle/vector_scaling_operations.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 | 12 | /* 13 | * This file contains implementations of the functions 14 | * WebRtcSpl_VectorBitShiftW16() 15 | * WebRtcSpl_VectorBitShiftW32() 16 | * WebRtcSpl_VectorBitShiftW32ToW16() 17 | * WebRtcSpl_ScaleVector() 18 | * WebRtcSpl_ScaleVectorWithSat() 19 | * WebRtcSpl_ScaleAndAddVectors() 20 | * WebRtcSpl_ScaleAndAddVectorsWithRoundC() 21 | */ 22 | 23 | #include "signal_processing_library.h" 24 | 25 | void WebRtcSpl_VectorBitShiftW16(int16_t *res, int16_t length, 26 | const int16_t *in, int16_t right_shifts) 27 | { 28 | int i; 29 | 30 | if (right_shifts > 0) 31 | { 32 | for (i = length; i > 0; i--) 33 | { 34 | (*res++) = ((*in++) >> right_shifts); 35 | } 36 | } else 37 | { 38 | for (i = length; i > 0; i--) 39 | { 40 | (*res++) = ((*in++) << (-right_shifts)); 41 | } 42 | } 43 | } 44 | 45 | void WebRtcSpl_VectorBitShiftW32(int32_t *out_vector, 46 | int16_t vector_length, 47 | const int32_t *in_vector, 48 | int16_t right_shifts) 49 | { 50 | int i; 51 | 52 | if (right_shifts > 0) 53 | { 54 | for (i = vector_length; i > 0; i--) 55 | { 56 | (*out_vector++) = ((*in_vector++) >> right_shifts); 57 | } 58 | } else 59 | { 60 | for (i = vector_length; i > 0; i--) 61 | { 62 | (*out_vector++) = ((*in_vector++) << (-right_shifts)); 63 | } 64 | } 65 | } 66 | 67 | void WebRtcSpl_VectorBitShiftW32ToW16(int16_t* out, int length, 68 | const int32_t* in, int right_shifts) { 69 | int i; 70 | int32_t tmp_w32; 71 | 72 | if (right_shifts >= 0) { 73 | for (i = length; i > 0; i--) { 74 | tmp_w32 = (*in++) >> right_shifts; 75 | (*out++) = WebRtcSpl_SatW32ToW16(tmp_w32); 76 | } 77 | } else { 78 | int16_t left_shifts = -right_shifts; 79 | for (i = length; i > 0; i--) { 80 | tmp_w32 = (*in++) << left_shifts; 81 | (*out++) = WebRtcSpl_SatW32ToW16(tmp_w32); 82 | } 83 | } 84 | } 85 | 86 | void WebRtcSpl_ScaleVector(const int16_t *in_vector, int16_t *out_vector, 87 | int16_t gain, int16_t in_vector_length, 88 | int16_t right_shifts) 89 | { 90 | // Performs vector operation: out_vector = (gain*in_vector)>>right_shifts 91 | int i; 92 | const int16_t *inptr; 93 | int16_t *outptr; 94 | 95 | inptr = in_vector; 96 | outptr = out_vector; 97 | 98 | for (i = 0; i < in_vector_length; i++) 99 | { 100 | (*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, gain, right_shifts); 101 | } 102 | } 103 | 104 | void WebRtcSpl_ScaleVectorWithSat(const int16_t *in_vector, int16_t *out_vector, 105 | int16_t gain, int16_t in_vector_length, 106 | int16_t right_shifts) 107 | { 108 | // Performs vector operation: out_vector = (gain*in_vector)>>right_shifts 109 | int i; 110 | int32_t tmpW32; 111 | const int16_t *inptr; 112 | int16_t *outptr; 113 | 114 | inptr = in_vector; 115 | outptr = out_vector; 116 | 117 | for (i = 0; i < in_vector_length; i++) 118 | { 119 | tmpW32 = WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, gain, right_shifts); 120 | (*outptr++) = WebRtcSpl_SatW32ToW16(tmpW32); 121 | } 122 | } 123 | 124 | void WebRtcSpl_ScaleAndAddVectors(const int16_t *in1, int16_t gain1, int shift1, 125 | const int16_t *in2, int16_t gain2, int shift2, 126 | int16_t *out, int vector_length) 127 | { 128 | // Performs vector operation: out = (gain1*in1)>>shift1 + (gain2*in2)>>shift2 129 | int i; 130 | const int16_t *in1ptr; 131 | const int16_t *in2ptr; 132 | int16_t *outptr; 133 | 134 | in1ptr = in1; 135 | in2ptr = in2; 136 | outptr = out; 137 | 138 | for (i = 0; i < vector_length; i++) 139 | { 140 | (*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(gain1, *in1ptr++, shift1) 141 | + (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(gain2, *in2ptr++, shift2); 142 | } 143 | } 144 | 145 | // C version of WebRtcSpl_ScaleAndAddVectorsWithRound() for generic platforms. 146 | int WebRtcSpl_ScaleAndAddVectorsWithRoundC(const int16_t* in_vector1, 147 | int16_t in_vector1_scale, 148 | const int16_t* in_vector2, 149 | int16_t in_vector2_scale, 150 | int right_shifts, 151 | int16_t* out_vector, 152 | int length) { 153 | int i = 0; 154 | int round_value = (1 << right_shifts) >> 1; 155 | 156 | if (in_vector1 == NULL || in_vector2 == NULL || out_vector == NULL || 157 | length <= 0 || right_shifts < 0) { 158 | return -1; 159 | } 160 | 161 | for (i = 0; i < length; i++) { 162 | out_vector[i] = (int16_t)(( 163 | WEBRTC_SPL_MUL_16_16(in_vector1[i], in_vector1_scale) 164 | + WEBRTC_SPL_MUL_16_16(in_vector2[i], in_vector2_scale) 165 | + round_value) >> right_shifts); 166 | } 167 | 168 | return 0; 169 | } 170 | -------------------------------------------------------------------------------- /build/Makefile: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.10 3 | 4 | # Default target executed when no arguments are given to make. 5 | default_target: all 6 | 7 | .PHONY : default_target 8 | 9 | # Allow only one "make -f Makefile2" at a time, but pass parallelism. 10 | .NOTPARALLEL: 11 | 12 | 13 | #============================================================================= 14 | # Special targets provided by cmake. 15 | 16 | # Disable implicit rules so canonical targets will work. 17 | .SUFFIXES: 18 | 19 | 20 | # Remove some rules from gmake that .SUFFIXES does not remove. 21 | SUFFIXES = 22 | 23 | .SUFFIXES: .hpux_make_needs_suffix_list 24 | 25 | 26 | # Suppress display of executed commands. 27 | $(VERBOSE).SILENT: 28 | 29 | 30 | # A target that is always out of date. 31 | cmake_force: 32 | 33 | .PHONY : cmake_force 34 | 35 | #============================================================================= 36 | # Set environment variables for the build. 37 | 38 | # The shell in which to execute make rules. 39 | SHELL = /bin/sh 40 | 41 | # The CMake executable. 42 | CMAKE_COMMAND = /usr/bin/cmake 43 | 44 | # The command to remove a file. 45 | RM = /usr/bin/cmake -E remove -f 46 | 47 | # Escaping for special characters. 48 | EQUALS = = 49 | 50 | # The top-level source directory on which CMake was run. 51 | CMAKE_SOURCE_DIR = "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc" 52 | 53 | # The top-level build directory on which CMake was run. 54 | CMAKE_BINARY_DIR = "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/build" 55 | 56 | #============================================================================= 57 | # Targets provided globally by CMake. 58 | 59 | # Special rule for the target rebuild_cache 60 | rebuild_cache: 61 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." 62 | /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 63 | .PHONY : rebuild_cache 64 | 65 | # Special rule for the target rebuild_cache 66 | rebuild_cache/fast: rebuild_cache 67 | 68 | .PHONY : rebuild_cache/fast 69 | 70 | # Special rule for the target edit_cache 71 | edit_cache: 72 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..." 73 | /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available. 74 | .PHONY : edit_cache 75 | 76 | # Special rule for the target edit_cache 77 | edit_cache/fast: edit_cache 78 | 79 | .PHONY : edit_cache/fast 80 | 81 | # The main all target 82 | all: cmake_check_build_system 83 | $(CMAKE_COMMAND) -E cmake_progress_start "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/build/CMakeFiles" "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/build/CMakeFiles/progress.marks" 84 | $(MAKE) -f CMakeFiles/Makefile2 all 85 | $(CMAKE_COMMAND) -E cmake_progress_start "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/build/CMakeFiles" 0 86 | .PHONY : all 87 | 88 | # The main clean target 89 | clean: 90 | $(MAKE) -f CMakeFiles/Makefile2 clean 91 | .PHONY : clean 92 | 93 | # The main clean target 94 | clean/fast: clean 95 | 96 | .PHONY : clean/fast 97 | 98 | # Prepare targets for installation. 99 | preinstall: all 100 | $(MAKE) -f CMakeFiles/Makefile2 preinstall 101 | .PHONY : preinstall 102 | 103 | # Prepare targets for installation. 104 | preinstall/fast: 105 | $(MAKE) -f CMakeFiles/Makefile2 preinstall 106 | .PHONY : preinstall/fast 107 | 108 | # clear depends 109 | depend: 110 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 111 | .PHONY : depend 112 | 113 | #============================================================================= 114 | # Target rules for targets named webRTCtest 115 | 116 | # Build rule for target. 117 | webRTCtest: cmake_check_build_system 118 | $(MAKE) -f CMakeFiles/Makefile2 webRTCtest 119 | .PHONY : webRTCtest 120 | 121 | # fast build rule for target. 122 | webRTCtest/fast: 123 | $(MAKE) -f CMakeFiles/webRTCtest.dir/build.make CMakeFiles/webRTCtest.dir/build 124 | .PHONY : webRTCtest/fast 125 | 126 | WebRtcAudioTest.o: WebRtcAudioTest.cpp.o 127 | 128 | .PHONY : WebRtcAudioTest.o 129 | 130 | # target to build an object file 131 | WebRtcAudioTest.cpp.o: 132 | $(MAKE) -f CMakeFiles/webRTCtest.dir/build.make CMakeFiles/webRTCtest.dir/WebRtcAudioTest.cpp.o 133 | .PHONY : WebRtcAudioTest.cpp.o 134 | 135 | WebRtcAudioTest.i: WebRtcAudioTest.cpp.i 136 | 137 | .PHONY : WebRtcAudioTest.i 138 | 139 | # target to preprocess a source file 140 | WebRtcAudioTest.cpp.i: 141 | $(MAKE) -f CMakeFiles/webRTCtest.dir/build.make CMakeFiles/webRTCtest.dir/WebRtcAudioTest.cpp.i 142 | .PHONY : WebRtcAudioTest.cpp.i 143 | 144 | WebRtcAudioTest.s: WebRtcAudioTest.cpp.s 145 | 146 | .PHONY : WebRtcAudioTest.s 147 | 148 | # target to generate assembly for a file 149 | WebRtcAudioTest.cpp.s: 150 | $(MAKE) -f CMakeFiles/webRTCtest.dir/build.make CMakeFiles/webRTCtest.dir/WebRtcAudioTest.cpp.s 151 | .PHONY : WebRtcAudioTest.cpp.s 152 | 153 | stdafx.o: stdafx.cpp.o 154 | 155 | .PHONY : stdafx.o 156 | 157 | # target to build an object file 158 | stdafx.cpp.o: 159 | $(MAKE) -f CMakeFiles/webRTCtest.dir/build.make CMakeFiles/webRTCtest.dir/stdafx.cpp.o 160 | .PHONY : stdafx.cpp.o 161 | 162 | stdafx.i: stdafx.cpp.i 163 | 164 | .PHONY : stdafx.i 165 | 166 | # target to preprocess a source file 167 | stdafx.cpp.i: 168 | $(MAKE) -f CMakeFiles/webRTCtest.dir/build.make CMakeFiles/webRTCtest.dir/stdafx.cpp.i 169 | .PHONY : stdafx.cpp.i 170 | 171 | stdafx.s: stdafx.cpp.s 172 | 173 | .PHONY : stdafx.s 174 | 175 | # target to generate assembly for a file 176 | stdafx.cpp.s: 177 | $(MAKE) -f CMakeFiles/webRTCtest.dir/build.make CMakeFiles/webRTCtest.dir/stdafx.cpp.s 178 | .PHONY : stdafx.cpp.s 179 | 180 | # Help Target 181 | help: 182 | @echo "The following are some of the valid targets for this Makefile:" 183 | @echo "... all (the default if no target is provided)" 184 | @echo "... clean" 185 | @echo "... depend" 186 | @echo "... rebuild_cache" 187 | @echo "... webRTCtest" 188 | @echo "... edit_cache" 189 | @echo "... WebRtcAudioTest.o" 190 | @echo "... WebRtcAudioTest.i" 191 | @echo "... WebRtcAudioTest.s" 192 | @echo "... stdafx.o" 193 | @echo "... stdafx.i" 194 | @echo "... stdafx.s" 195 | .PHONY : help 196 | 197 | 198 | 199 | #============================================================================= 200 | # Special targets to cleanup operation of make. 201 | 202 | # Special rule to run CMake to check the build system integrity. 203 | # No rule that depends on this can have commands that come from listfiles 204 | # because they might be regenerated. 205 | cmake_check_build_system: 206 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 207 | .PHONY : cmake_check_build_system 208 | 209 | -------------------------------------------------------------------------------- /build/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Install shared libraries without execute permission? 31 | if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) 32 | set(CMAKE_INSTALL_SO_NO_EXE "1") 33 | endif() 34 | 35 | # Is this installation the result of a crosscompile? 36 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 37 | set(CMAKE_CROSSCOMPILING "FALSE") 38 | endif() 39 | 40 | if(CMAKE_INSTALL_COMPONENT) 41 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 42 | else() 43 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 44 | endif() 45 | 46 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 47 | "${CMAKE_INSTALL_MANIFEST_FILES}") 48 | file(WRITE "/home/lijianglong/C++ 编程学习/cmake/webRTC/nsagc/build/${CMAKE_INSTALL_MANIFEST}" 49 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 50 | -------------------------------------------------------------------------------- /build/webRTCtest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljl86400/webRTCtest/e812bbd08b5ba216c55011615ae4f400b7f7376f/build/webRTCtest -------------------------------------------------------------------------------- /stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljl86400/webRTCtest/e812bbd08b5ba216c55011615ae4f400b7f7376f/stdafx.cpp -------------------------------------------------------------------------------- /stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljl86400/webRTCtest/e812bbd08b5ba216c55011615ae4f400b7f7376f/stdafx.h -------------------------------------------------------------------------------- /targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljl86400/webRTCtest/e812bbd08b5ba216c55011615ae4f400b7f7376f/targetver.h -------------------------------------------------------------------------------- /文件备份/WebRtcAudioTest(复件).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljl86400/webRTCtest/e812bbd08b5ba216c55011615ae4f400b7f7376f/文件备份/WebRtcAudioTest(复件).cpp -------------------------------------------------------------------------------- /文件备份/stdafx(复件).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljl86400/webRTCtest/e812bbd08b5ba216c55011615ae4f400b7f7376f/文件备份/stdafx(复件).cpp -------------------------------------------------------------------------------- /文件备份/stdafx(复件).h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljl86400/webRTCtest/e812bbd08b5ba216c55011615ae4f400b7f7376f/文件备份/stdafx(复件).h -------------------------------------------------------------------------------- /文件备份/targetver(复件).h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljl86400/webRTCtest/e812bbd08b5ba216c55011615ae4f400b7f7376f/文件备份/targetver(复件).h --------------------------------------------------------------------------------