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

Side by Side Diff: webrtc/modules/audio_processing/agc/legacy/analog_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) 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
11 /* analog_agc.c 11 /* analog_agc.c
12 * 12 *
13 * Using a feedback system, determines an appropriate analog volume level 13 * Using a feedback system, determines an appropriate analog volume level
14 * given an input signal and current volume level. Targets a conservative 14 * given an input signal and current volume level. Targets a conservative
15 * signal level and is intended for use with a digital AGC to apply 15 * signal level and is intended for use with a digital AGC to apply
16 * additional gain. 16 * additional gain.
17 * 17 *
18 */ 18 */
19 19
20 #include "webrtc/modules/audio_processing/agc/legacy/analog_agc.h" 20 #include "webrtc/modules/audio_processing/agc/legacy/analog_agc.h"
21 21
22 #include <assert.h>
23 #include <stdlib.h> 22 #include <stdlib.h>
24 #ifdef WEBRTC_AGC_DEBUG_DUMP 23 #ifdef WEBRTC_AGC_DEBUG_DUMP
25 #include <stdio.h> 24 #include <stdio.h>
26 #endif 25 #endif
27 26
27 #include "webrtc/base/checks.h"
28
28 /* The slope of in Q13*/ 29 /* The slope of in Q13*/
29 static const int16_t kSlope1[8] = {21793, 12517, 7189, 4129, 30 static const int16_t kSlope1[8] = {21793, 12517, 7189, 4129,
30 2372, 1362, 472, 78}; 31 2372, 1362, 472, 78};
31 32
32 /* The offset in Q14 */ 33 /* The offset in Q14 */
33 static const int16_t kOffset1[8] = {25395, 23911, 22206, 20737, 34 static const int16_t kOffset1[8] = {25395, 23911, 22206, 20737,
34 19612, 18805, 17951, 17367}; 35 19612, 18805, 17951, 17367};
35 36
36 /* The slope of in Q13*/ 37 /* The slope of in Q13*/
37 static const int16_t kSlope2[8] = {2063, 1731, 1452, 1218, 1021, 857, 597, 337}; 38 static const int16_t kSlope2[8] = {2063, 1731, 1452, 1218, 1021, 857, 597, 337};
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 L = 16; 149 L = 16;
149 if (samples != 160) { 150 if (samples != 160) {
150 return -1; 151 return -1;
151 } 152 }
152 } 153 }
153 154
154 /* apply slowly varying digital gain */ 155 /* apply slowly varying digital gain */
155 if (stt->micVol > stt->maxAnalog) { 156 if (stt->micVol > stt->maxAnalog) {
156 /* |maxLevel| is strictly >= |micVol|, so this condition should be 157 /* |maxLevel| is strictly >= |micVol|, so this condition should be
157 * satisfied here, ensuring there is no divide-by-zero. */ 158 * satisfied here, ensuring there is no divide-by-zero. */
158 assert(stt->maxLevel > stt->maxAnalog); 159 RTC_DCHECK_GT(stt->maxLevel, stt->maxAnalog);
159 160
160 /* Q1 */ 161 /* Q1 */
161 tmp16 = (int16_t)(stt->micVol - stt->maxAnalog); 162 tmp16 = (int16_t)(stt->micVol - stt->maxAnalog);
162 tmp32 = (GAIN_TBL_LEN - 1) * tmp16; 163 tmp32 = (GAIN_TBL_LEN - 1) * tmp16;
163 tmp16 = (int16_t)(stt->maxLevel - stt->maxAnalog); 164 tmp16 = (int16_t)(stt->maxLevel - stt->maxAnalog);
164 targetGainIdx = tmp32 / tmp16; 165 targetGainIdx = tmp32 / tmp16;
165 assert(targetGainIdx < GAIN_TBL_LEN); 166 RTC_DCHECK_LT(targetGainIdx, GAIN_TBL_LEN);
166 167
167 /* Increment through the table towards the target gain. 168 /* Increment through the table towards the target gain.
168 * If micVol drops below maxAnalog, we allow the gain 169 * If micVol drops below maxAnalog, we allow the gain
169 * to be dropped immediately. */ 170 * to be dropped immediately. */
170 if (stt->gainTableIdx < targetGainIdx) { 171 if (stt->gainTableIdx < targetGainIdx) {
171 stt->gainTableIdx++; 172 stt->gainTableIdx++;
172 } else if (stt->gainTableIdx > targetGainIdx) { 173 } else if (stt->gainTableIdx > targetGainIdx) {
173 stt->gainTableIdx--; 174 stt->gainTableIdx--;
174 } 175 }
175 176
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 fprintf(stt->fpt, "minLevel, maxLevel value(s) are invalid\n\n"); 1381 fprintf(stt->fpt, "minLevel, maxLevel value(s) are invalid\n\n");
1381 #endif 1382 #endif
1382 return -1; 1383 return -1;
1383 } else { 1384 } else {
1384 #ifdef WEBRTC_AGC_DEBUG_DUMP 1385 #ifdef WEBRTC_AGC_DEBUG_DUMP
1385 fprintf(stt->fpt, "\n"); 1386 fprintf(stt->fpt, "\n");
1386 #endif 1387 #endif
1387 return 0; 1388 return 0;
1388 } 1389 }
1389 } 1390 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698