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

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

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (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) 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
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 // initialize VADs 277 // initialize VADs
278 WebRtcAgc_InitVad(&stt->vadNearend); 278 WebRtcAgc_InitVad(&stt->vadNearend);
279 WebRtcAgc_InitVad(&stt->vadFarend); 279 WebRtcAgc_InitVad(&stt->vadFarend);
280 280
281 return 0; 281 return 0;
282 } 282 }
283 283
284 int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc* stt, 284 int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc* stt,
285 const int16_t* in_far, 285 const int16_t* in_far,
286 int16_t nrSamples) { 286 size_t nrSamples) {
287 assert(stt != NULL); 287 assert(stt != NULL);
288 // VAD for far end 288 // VAD for far end
289 WebRtcAgc_ProcessVad(&stt->vadFarend, in_far, nrSamples); 289 WebRtcAgc_ProcessVad(&stt->vadFarend, in_far, nrSamples);
290 290
291 return 0; 291 return 0;
292 } 292 }
293 293
294 int32_t WebRtcAgc_ProcessDigital(DigitalAgc* stt, 294 int32_t WebRtcAgc_ProcessDigital(DigitalAgc* stt,
295 const int16_t* const* in_near, 295 const int16_t* const* in_near,
296 int16_t num_bands, 296 size_t num_bands,
297 int16_t* const* out, 297 int16_t* const* out,
298 uint32_t FS, 298 uint32_t FS,
299 int16_t lowlevelSignal) { 299 int16_t lowlevelSignal) {
300 // array for gains (one value per ms, incl start & end) 300 // array for gains (one value per ms, incl start & end)
301 int32_t gains[11]; 301 int32_t gains[11];
302 302
303 int32_t out_tmp, tmp32; 303 int32_t out_tmp, tmp32;
304 int32_t env[10]; 304 int32_t env[10];
305 int32_t max_nrg; 305 int32_t max_nrg;
306 int32_t cur_level; 306 int32_t cur_level;
307 int32_t gain32, delta; 307 int32_t gain32, delta;
308 int16_t logratio; 308 int16_t logratio;
309 int16_t lower_thr, upper_thr; 309 int16_t lower_thr, upper_thr;
310 int16_t zeros = 0, zeros_fast, frac = 0; 310 int16_t zeros = 0, zeros_fast, frac = 0;
311 int16_t decay; 311 int16_t decay;
312 int16_t gate, gain_adj; 312 int16_t gate, gain_adj;
313 int16_t k, n, i; 313 int16_t k;
314 int16_t L, L2; // samples/subframe 314 size_t n, i, L;
315 int16_t L2; // samples/subframe
315 316
316 // determine number of samples per ms 317 // determine number of samples per ms
317 if (FS == 8000) 318 if (FS == 8000)
318 { 319 {
319 L = 8; 320 L = 8;
320 L2 = 3; 321 L2 = 3;
321 } else if (FS == 16000 || FS == 32000 || FS == 48000) 322 } else if (FS == 16000 || FS == 32000 || FS == 48000)
322 { 323 {
323 L = 16; 324 L = 16;
324 L2 = 4; 325 L2 = 4;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 state->counter = 3; // counts updates 626 state->counter = 3; // counts updates
626 for (k = 0; k < 8; k++) 627 for (k = 0; k < 8; k++)
627 { 628 {
628 // downsampling filter 629 // downsampling filter
629 state->downState[k] = 0; 630 state->downState[k] = 0;
630 } 631 }
631 } 632 }
632 633
633 int16_t WebRtcAgc_ProcessVad(AgcVad* state, // (i) VAD state 634 int16_t WebRtcAgc_ProcessVad(AgcVad* state, // (i) VAD state
634 const int16_t* in, // (i) Speech signal 635 const int16_t* in, // (i) Speech signal
635 int16_t nrSamples) // (i) number of samples 636 size_t nrSamples) // (i) number of samples
636 { 637 {
637 int32_t out, nrg, tmp32, tmp32b; 638 int32_t out, nrg, tmp32, tmp32b;
638 uint16_t tmpU16; 639 uint16_t tmpU16;
639 int16_t k, subfr, tmp16; 640 int16_t k, subfr, tmp16;
640 int16_t buf1[8]; 641 int16_t buf1[8];
641 int16_t buf2[4]; 642 int16_t buf2[4];
642 int16_t HPstate; 643 int16_t HPstate;
643 int16_t zeros, dB; 644 int16_t zeros, dB;
644 645
645 // process in 10 sub frames of 1 ms (to save on memory) 646 // process in 10 sub frames of 1 ms (to save on memory)
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 { 763 {
763 state->logRatio = 2048; 764 state->logRatio = 2048;
764 } 765 }
765 if (state->logRatio < -2048) 766 if (state->logRatio < -2048)
766 { 767 {
767 state->logRatio = -2048; 768 state->logRatio = -2048;
768 } 769 }
769 770
770 return state->logRatio; // Q10 771 return state->logRatio; // Q10
771 } 772 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/agc/legacy/digital_agc.h ('k') | webrtc/modules/audio_processing/agc/legacy/gain_control.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698