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

Side by Side Diff: webrtc/modules/audio_processing/agc/legacy/digital_agc.c

Issue 2274083002: Replace calls to assert() with RTC_DCHECK_*() in .c code (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 3 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) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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
11 /* digital_agc.c 11 /* digital_agc.c
12 * 12 *
13 */ 13 */
14 14
15 #include "webrtc/modules/audio_processing/agc/legacy/digital_agc.h" 15 #include "webrtc/modules/audio_processing/agc/legacy/digital_agc.h"
16 16
17 #include <assert.h>
18 #include <string.h> 17 #include <string.h>
19 #ifdef WEBRTC_AGC_DEBUG_DUMP 18 #ifdef WEBRTC_AGC_DEBUG_DUMP
20 #include <stdio.h> 19 #include <stdio.h>
21 #endif 20 #endif
22 21
22 #include "webrtc/base/checks.h"
23 #include "webrtc/modules/audio_processing/agc/legacy/gain_control.h" 23 #include "webrtc/modules/audio_processing/agc/legacy/gain_control.h"
24 24
25 // To generate the gaintable, copy&paste the following lines to a Matlab window: 25 // To generate the gaintable, copy&paste the following lines to a Matlab window:
26 // MaxGain = 6; MinGain = 0; CompRatio = 3; Knee = 1; 26 // MaxGain = 6; MinGain = 0; CompRatio = 3; Knee = 1;
27 // zeros = 0:31; lvl = 2.^(1-zeros); 27 // zeros = 0:31; lvl = 2.^(1-zeros);
28 // A = -10*log10(lvl) * (CompRatio - 1) / CompRatio; 28 // A = -10*log10(lvl) * (CompRatio - 1) / CompRatio;
29 // B = MaxGain - MinGain; 29 // B = MaxGain - MinGain;
30 // gains = round(2^16*10.^(0.05 * (MinGain + B * ( 30 // gains = round(2^16*10.^(0.05 * (MinGain + B * (
31 // log(exp(-Knee*A)+exp(-Knee*B)) - log(1+exp(-Knee*B)) ) / 31 // log(exp(-Knee*A)+exp(-Knee*B)) - log(1+exp(-Knee*B)) ) /
32 // log(1/(1+exp(Knee*B)))))); 32 // log(1/(1+exp(Knee*B))))));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 limiterOffset = 0; 102 limiterOffset = 0;
103 } 103 }
104 104
105 // Calculate the difference between maximum gain and gain at 0dB0v: 105 // Calculate the difference between maximum gain and gain at 0dB0v:
106 // diffGain = maxGain + (compRatio-1)*zeroGainLvl/compRatio 106 // diffGain = maxGain + (compRatio-1)*zeroGainLvl/compRatio
107 // = (compRatio-1)*digCompGaindB/compRatio 107 // = (compRatio-1)*digCompGaindB/compRatio
108 tmp32no1 = digCompGaindB * (kCompRatio - 1); 108 tmp32no1 = digCompGaindB * (kCompRatio - 1);
109 diffGain = 109 diffGain =
110 WebRtcSpl_DivW32W16ResW16(tmp32no1 + (kCompRatio >> 1), kCompRatio); 110 WebRtcSpl_DivW32W16ResW16(tmp32no1 + (kCompRatio >> 1), kCompRatio);
111 if (diffGain < 0 || diffGain >= kGenFuncTableSize) { 111 if (diffGain < 0 || diffGain >= kGenFuncTableSize) {
112 assert(0); 112 RTC_DCHECK(0);
113 return -1; 113 return -1;
114 } 114 }
115 115
116 // Calculate the limiter level and index: 116 // Calculate the limiter level and index:
117 // limiterLvlX = analogTarget - limiterOffset 117 // limiterLvlX = analogTarget - limiterOffset
118 // limiterLvl = targetLevelDbfs + limiterOffset/compRatio 118 // limiterLvl = targetLevelDbfs + limiterOffset/compRatio
119 limiterLvlX = analogTarget - limiterOffset; 119 limiterLvlX = analogTarget - limiterOffset;
120 limiterIdx = 2 + WebRtcSpl_DivW32W16ResW16((int32_t)limiterLvlX * (1 << 13), 120 limiterIdx = 2 + WebRtcSpl_DivW32W16ResW16((int32_t)limiterLvlX * (1 << 13),
121 kLog10_2 / 2); 121 kLog10_2 / 2);
122 tmp16no1 = 122 tmp16no1 =
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // initialize VADs 261 // initialize VADs
262 WebRtcAgc_InitVad(&stt->vadNearend); 262 WebRtcAgc_InitVad(&stt->vadNearend);
263 WebRtcAgc_InitVad(&stt->vadFarend); 263 WebRtcAgc_InitVad(&stt->vadFarend);
264 264
265 return 0; 265 return 0;
266 } 266 }
267 267
268 int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc* stt, 268 int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc* stt,
269 const int16_t* in_far, 269 const int16_t* in_far,
270 size_t nrSamples) { 270 size_t nrSamples) {
271 assert(stt != NULL); 271 RTC_DCHECK(stt);
272 // VAD for far end 272 // VAD for far end
273 WebRtcAgc_ProcessVad(&stt->vadFarend, in_far, nrSamples); 273 WebRtcAgc_ProcessVad(&stt->vadFarend, in_far, nrSamples);
274 274
275 return 0; 275 return 0;
276 } 276 }
277 277
278 int32_t WebRtcAgc_ProcessDigital(DigitalAgc* stt, 278 int32_t WebRtcAgc_ProcessDigital(DigitalAgc* stt,
279 const int16_t* const* in_near, 279 const int16_t* const* in_near,
280 size_t num_bands, 280 size_t num_bands,
281 int16_t* const* out, 281 int16_t* const* out,
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 // limit 679 // limit
680 if (state->logRatio > 2048) { 680 if (state->logRatio > 2048) {
681 state->logRatio = 2048; 681 state->logRatio = 2048;
682 } 682 }
683 if (state->logRatio < -2048) { 683 if (state->logRatio < -2048) {
684 state->logRatio = -2048; 684 state->logRatio = -2048;
685 } 685 }
686 686
687 return state->logRatio; // Q10 687 return state->logRatio; // Q10
688 } 688 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698