OLD | NEW |
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 17 matching lines...) Expand all Loading... |
28 0.5063f, 0.5190f, 0.5316f, 0.5443f, | 28 0.5063f, 0.5190f, 0.5316f, 0.5443f, |
29 0.5570f, 0.5696f, 0.5823f, 0.5949f, | 29 0.5570f, 0.5696f, 0.5823f, 0.5949f, |
30 0.6076f, 0.6203f, 0.6329f, 0.6456f, | 30 0.6076f, 0.6203f, 0.6329f, 0.6456f, |
31 0.6582f, 0.6709f, 0.6835f, 0.6962f, | 31 0.6582f, 0.6709f, 0.6835f, 0.6962f, |
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 int 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 void CalculateEnergy(AudioFrame& audioFrame) |
43 { | 43 { |
44 audioFrame.energy_ = 0; | 44 audioFrame.energy_ = 0; |
45 for(int 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 audioFrame.energy_ += audioFrame.data_[position] * |
50 audioFrame.data_[position]; | 50 audioFrame.data_[position]; |
51 } | 51 } |
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(int 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(int i = 0; i < rampSize; i++) | 67 for(size_t i = 0; i < rampSize; i++) |
68 { | 68 { |
69 const int 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 |
OLD | NEW |