Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Side by Side Diff: webrtc/modules/audio_processing/aec/aec_core.c

Issue 1227213002: Update audio code to use size_t more correctly, webrtc/modules/audio_processing/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 } 938 }
939 939
940 static void NonLinearProcessing(AecCore* aec, 940 static void NonLinearProcessing(AecCore* aec,
941 float* output, 941 float* output,
942 float* const* outputH) { 942 float* const* outputH) {
943 float efw[2][PART_LEN1], xfw[2][PART_LEN1]; 943 float efw[2][PART_LEN1], xfw[2][PART_LEN1];
944 complex_t comfortNoiseHband[PART_LEN1]; 944 complex_t comfortNoiseHband[PART_LEN1];
945 float fft[PART_LEN2]; 945 float fft[PART_LEN2];
946 float scale, dtmp; 946 float scale, dtmp;
947 float nlpGainHband; 947 float nlpGainHband;
948 int i, j; 948 int i;
949 size_t j;
949 950
950 // Coherence and non-linear filter 951 // Coherence and non-linear filter
951 float cohde[PART_LEN1], cohxd[PART_LEN1]; 952 float cohde[PART_LEN1], cohxd[PART_LEN1];
952 float hNlDeAvg, hNlXdAvg; 953 float hNlDeAvg, hNlXdAvg;
953 float hNl[PART_LEN1]; 954 float hNl[PART_LEN1];
954 float hNlPref[kPrefBandSize]; 955 float hNlPref[kPrefBandSize];
955 float hNlFb = 0, hNlFbLow = 0; 956 float hNlFb = 0, hNlFbLow = 0;
956 const float prefBandQuant = 0.75f, prefBandQuantLow = 0.5f; 957 const float prefBandQuant = 0.75f, prefBandQuantLow = 0.5f;
957 const int prefBandSize = kPrefBandSize / aec->mult; 958 const int prefBandSize = kPrefBandSize / aec->mult;
958 const int minPrefBand = 4 / aec->mult; 959 const int minPrefBand = 4 / aec->mult;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 WEBRTC_SPL_WORD16_MAX, dtmp, WEBRTC_SPL_WORD16_MIN); 1154 WEBRTC_SPL_WORD16_MAX, dtmp, WEBRTC_SPL_WORD16_MIN);
1154 } 1155 }
1155 } 1156 }
1156 } 1157 }
1157 1158
1158 // Copy the current block to the old position. 1159 // Copy the current block to the old position.
1159 memcpy(aec->dBuf, aec->dBuf + PART_LEN, sizeof(float) * PART_LEN); 1160 memcpy(aec->dBuf, aec->dBuf + PART_LEN, sizeof(float) * PART_LEN);
1160 memcpy(aec->eBuf, aec->eBuf + PART_LEN, sizeof(float) * PART_LEN); 1161 memcpy(aec->eBuf, aec->eBuf + PART_LEN, sizeof(float) * PART_LEN);
1161 1162
1162 // Copy the current block to the old position for H band 1163 // Copy the current block to the old position for H band
1163 for (i = 0; i < aec->num_bands - 1; ++i) { 1164 for (j = 0; j < aec->num_bands - 1; ++j) {
1164 memcpy(aec->dBufH[i], aec->dBufH[i] + PART_LEN, sizeof(float) * PART_LEN); 1165 memcpy(aec->dBufH[j], aec->dBufH[j] + PART_LEN, sizeof(float) * PART_LEN);
1165 } 1166 }
1166 1167
1167 memmove(aec->xfwBuf + PART_LEN1, 1168 memmove(aec->xfwBuf + PART_LEN1,
1168 aec->xfwBuf, 1169 aec->xfwBuf,
1169 sizeof(aec->xfwBuf) - sizeof(complex_t) * PART_LEN1); 1170 sizeof(aec->xfwBuf) - sizeof(complex_t) * PART_LEN1);
1170 } 1171 }
1171 1172
1172 static void ProcessBlock(AecCore* aec) { 1173 static void ProcessBlock(AecCore* aec) {
1173 int i; 1174 size_t i;
1174 float y[PART_LEN], e[PART_LEN]; 1175 float y[PART_LEN], e[PART_LEN];
1175 float scale; 1176 float scale;
1176 1177
1177 float fft[PART_LEN2]; 1178 float fft[PART_LEN2];
1178 float xf[2][PART_LEN1], yf[2][PART_LEN1], ef[2][PART_LEN1]; 1179 float xf[2][PART_LEN1], yf[2][PART_LEN1], ef[2][PART_LEN1];
1179 float df[2][PART_LEN1]; 1180 float df[2][PART_LEN1];
1180 float far_spectrum = 0.0f; 1181 float far_spectrum = 0.0f;
1181 float near_spectrum = 0.0f; 1182 float near_spectrum = 0.0f;
1182 float abs_far_spectrum[PART_LEN1]; 1183 float abs_far_spectrum[PART_LEN1];
1183 float abs_near_spectrum[PART_LEN1]; 1184 float abs_near_spectrum[PART_LEN1];
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 1551
1551 aec->sampFreq = sampFreq; 1552 aec->sampFreq = sampFreq;
1552 1553
1553 if (sampFreq == 8000) { 1554 if (sampFreq == 8000) {
1554 aec->normal_mu = 0.6f; 1555 aec->normal_mu = 0.6f;
1555 aec->normal_error_threshold = 2e-6f; 1556 aec->normal_error_threshold = 2e-6f;
1556 aec->num_bands = 1; 1557 aec->num_bands = 1;
1557 } else { 1558 } else {
1558 aec->normal_mu = 0.5f; 1559 aec->normal_mu = 0.5f;
1559 aec->normal_error_threshold = 1.5e-6f; 1560 aec->normal_error_threshold = 1.5e-6f;
1560 aec->num_bands = sampFreq / 16000; 1561 aec->num_bands = (size_t)(sampFreq / 16000);
1561 } 1562 }
1562 1563
1563 WebRtc_InitBuffer(aec->nearFrBuf); 1564 WebRtc_InitBuffer(aec->nearFrBuf);
1564 WebRtc_InitBuffer(aec->outFrBuf); 1565 WebRtc_InitBuffer(aec->outFrBuf);
1565 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { 1566 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) {
1566 WebRtc_InitBuffer(aec->nearFrBufH[i]); 1567 WebRtc_InitBuffer(aec->nearFrBufH[i]);
1567 WebRtc_InitBuffer(aec->outFrBufH[i]); 1568 WebRtc_InitBuffer(aec->outFrBufH[i]);
1568 } 1569 }
1569 1570
1570 // Initialize far-end buffers. 1571 // Initialize far-end buffers.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 } 1725 }
1725 1726
1726 int WebRtcAec_MoveFarReadPtr(AecCore* aec, int elements) { 1727 int WebRtcAec_MoveFarReadPtr(AecCore* aec, int elements) {
1727 int elements_moved = MoveFarReadPtrWithoutSystemDelayUpdate(aec, elements); 1728 int elements_moved = MoveFarReadPtrWithoutSystemDelayUpdate(aec, elements);
1728 aec->system_delay -= elements_moved * PART_LEN; 1729 aec->system_delay -= elements_moved * PART_LEN;
1729 return elements_moved; 1730 return elements_moved;
1730 } 1731 }
1731 1732
1732 void WebRtcAec_ProcessFrames(AecCore* aec, 1733 void WebRtcAec_ProcessFrames(AecCore* aec,
1733 const float* const* nearend, 1734 const float* const* nearend,
1734 int num_bands, 1735 size_t num_bands,
1735 int num_samples, 1736 size_t num_samples,
1736 int knownDelay, 1737 int knownDelay,
1737 float* const* out) { 1738 float* const* out) {
1738 int i, j; 1739 size_t i, j;
1739 int out_elements = 0; 1740 int out_elements = 0;
1740 1741
1741 aec->frame_count++; 1742 aec->frame_count++;
1742 // For each frame the process is as follows: 1743 // For each frame the process is as follows:
1743 // 1) If the system_delay indicates on being too small for processing a 1744 // 1) If the system_delay indicates on being too small for processing a
1744 // frame we stuff the buffer with enough data for 10 ms. 1745 // frame we stuff the buffer with enough data for 10 ms.
1745 // 2 a) Adjust the buffer to the system delay, by moving the read pointer. 1746 // 2 a) Adjust the buffer to the system delay, by moving the read pointer.
1746 // b) Apply signal based delay correction, if we have detected poor AEC 1747 // b) Apply signal based delay correction, if we have detected poor AEC
1747 // performance. 1748 // performance.
1748 // 3) TODO(bjornv): Investigate if we need to add this: 1749 // 3) TODO(bjornv): Investigate if we need to add this:
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 int WebRtcAec_extended_filter_enabled(AecCore* self) { 1925 int WebRtcAec_extended_filter_enabled(AecCore* self) {
1925 return self->extended_filter_enabled; 1926 return self->extended_filter_enabled;
1926 } 1927 }
1927 1928
1928 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } 1929 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; }
1929 1930
1930 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { 1931 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) {
1931 assert(delay >= 0); 1932 assert(delay >= 0);
1932 self->system_delay = delay; 1933 self->system_delay = delay;
1933 } 1934 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/aec/aec_core.h ('k') | webrtc/modules/audio_processing/aec/aec_core_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698