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

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

Issue 3009373002: Fixed the overflow in the AGC (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 517
518 gain32 += delta; 518 gain32 += delta;
519 } 519 }
520 // iterate over subframes 520 // iterate over subframes
521 for (k = 1; k < 10; k++) { 521 for (k = 1; k < 10; k++) {
522 delta = (gains[k + 1] - gains[k]) * (1 << (4 - L2)); 522 delta = (gains[k + 1] - gains[k]) * (1 << (4 - L2));
523 gain32 = gains[k] * (1 << 4); 523 gain32 = gains[k] * (1 << 4);
524 // iterate over samples 524 // iterate over samples
525 for (n = 0; n < L; n++) { 525 for (n = 0; n < L; n++) {
526 for (i = 0; i < num_bands; ++i) { 526 for (i = 0; i < num_bands; ++i) {
527 tmp32 = out[i][k * L + n] * (gain32 >> 4); 527 int64_t tmp64 = ((int64_t)(out[i][k * L + n])) * (gain32 >> 4);
528 out[i][k * L + n] = (int16_t)(tmp32 >> 16); 528 tmp64 = tmp64 >> 16;
529 if (tmp64 > 32767) {
530 out[i][k * L + n] = 32767;
531 }
532 else if (tmp64 < -32768) {
533 out[i][k * L + n] = -32768;
534 }
535 else {
536 out[i][k * L + n] = (int16_t)(tmp64);
537 }
529 } 538 }
530 gain32 += delta; 539 gain32 += delta;
531 } 540 }
532 } 541 }
533 542
534 return 0; 543 return 0;
535 } 544 }
536 545
537 void WebRtcAgc_InitVad(AgcVad* state) { 546 void WebRtcAgc_InitVad(AgcVad* state) {
538 int16_t k; 547 int16_t k;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 // limit 688 // limit
680 if (state->logRatio > 2048) { 689 if (state->logRatio > 2048) {
681 state->logRatio = 2048; 690 state->logRatio = 2048;
682 } 691 }
683 if (state->logRatio < -2048) { 692 if (state->logRatio < -2048) {
684 state->logRatio = -2048; 693 state->logRatio = -2048;
685 } 694 }
686 695
687 return state->logRatio; // Q10 696 return state->logRatio; // Q10
688 } 697 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698