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

Side by Side Diff: webrtc/modules/audio_conference_mixer/source/audio_frame_manipulator.cc

Issue 1589953002: Removing webrtc::AudioFrame::energy_. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: after review Created 4 years, 11 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 21 matching lines...) Expand all
32 0.7089f, 0.7215f, 0.7342f, 0.7468f, 32 0.7089f, 0.7215f, 0.7342f, 0.7468f,
33 0.7595f, 0.7722f, 0.7848f, 0.7975f, 33 0.7595f, 0.7722f, 0.7848f, 0.7975f,
34 0.8101f, 0.8228f, 0.8354f, 0.8481f, 34 0.8101f, 0.8228f, 0.8354f, 0.8481f,
35 0.8608f, 0.8734f, 0.8861f, 0.8987f, 35 0.8608f, 0.8734f, 0.8861f, 0.8987f,
36 0.9114f, 0.9241f, 0.9367f, 0.9494f, 36 0.9114f, 0.9241f, 0.9367f, 0.9494f,
37 0.9620f, 0.9747f, 0.9873f, 1.0000f}; 37 0.9620f, 0.9747f, 0.9873f, 1.0000f};
38 const size_t rampSize = sizeof(rampArray)/sizeof(rampArray[0]); 38 const size_t rampSize = sizeof(rampArray)/sizeof(rampArray[0]);
39 } // namespace 39 } // namespace
40 40
41 namespace webrtc { 41 namespace webrtc {
42 void CalculateEnergy(AudioFrame& audioFrame) 42 uint32_t CalculateEnergy(const AudioFrame& audioFrame)
43 { 43 {
44 audioFrame.energy_ = 0; 44 uint32_t energy = 0;
45 for(size_t position = 0; position < audioFrame.samples_per_channel_; 45 for(size_t position = 0; position < audioFrame.samples_per_channel_;
46 position++) 46 position++)
47 { 47 {
48 // TODO(andrew): this can easily overflow. 48 // TODO(andrew): this can easily overflow.
49 audioFrame.energy_ += audioFrame.data_[position] * 49 energy += audioFrame.data_[position] * audioFrame.data_[position];
50 audioFrame.data_[position];
51 } 50 }
51 return energy;
52 } 52 }
53 53
54 void RampIn(AudioFrame& audioFrame) 54 void RampIn(AudioFrame& audioFrame)
55 { 55 {
56 assert(rampSize <= audioFrame.samples_per_channel_); 56 assert(rampSize <= audioFrame.samples_per_channel_);
57 for(size_t i = 0; i < rampSize; i++) 57 for(size_t i = 0; i < rampSize; i++)
58 { 58 {
59 audioFrame.data_[i] = static_cast<int16_t>(rampArray[i] * 59 audioFrame.data_[i] = static_cast<int16_t>(rampArray[i] *
60 audioFrame.data_[i]); 60 audioFrame.data_[i]);
61 } 61 }
62 } 62 }
63 63
64 void RampOut(AudioFrame& audioFrame) 64 void RampOut(AudioFrame& audioFrame)
65 { 65 {
66 assert(rampSize <= audioFrame.samples_per_channel_); 66 assert(rampSize <= audioFrame.samples_per_channel_);
67 for(size_t i = 0; i < rampSize; i++) 67 for(size_t i = 0; i < rampSize; i++)
68 { 68 {
69 const size_t rampPos = rampSize - 1 - i; 69 const size_t rampPos = rampSize - 1 - i;
70 audioFrame.data_[i] = static_cast<int16_t>(rampArray[rampPos] * 70 audioFrame.data_[i] = static_cast<int16_t>(rampArray[rampPos] *
71 audioFrame.data_[i]); 71 audioFrame.data_[i]);
72 } 72 }
73 memset(&audioFrame.data_[rampSize], 0, 73 memset(&audioFrame.data_[rampSize], 0,
74 (audioFrame.samples_per_channel_ - rampSize) * 74 (audioFrame.samples_per_channel_ - rampSize) *
75 sizeof(audioFrame.data_[0])); 75 sizeof(audioFrame.data_[0]));
76 } 76 }
77 } // namespace webrtc 77 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_conference_mixer/source/audio_frame_manipulator.h ('k') | webrtc/modules/include/module_common_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698