Chromium Code Reviews| Index: webrtc/modules/audio_conference_mixer/source/audio_frame_manipulator.cc |
| diff --git a/webrtc/modules/audio_conference_mixer/source/audio_frame_manipulator.cc b/webrtc/modules/audio_conference_mixer/source/audio_frame_manipulator.cc |
| index 1e679af914b3664746971037a6a2b7cc7a60f0bc..8f70d5131e038f4e297c2e9ee8410c49c44caaf6 100644 |
| --- a/webrtc/modules/audio_conference_mixer/source/audio_frame_manipulator.cc |
| +++ b/webrtc/modules/audio_conference_mixer/source/audio_frame_manipulator.cc |
| @@ -42,11 +42,15 @@ namespace webrtc { |
| uint32_t CalculateEnergy(const AudioFrame& audioFrame) |
| { |
| uint32_t energy = 0; |
| - for(size_t position = 0; position < audioFrame.samples_per_channel_; |
| - position++) |
| + if (!audioFrame.muted()) |
|
hlundin-webrtc
2017/03/17 14:29:39
I think I would prefer an early return when muted.
yujo
2017/03/17 23:55:54
Done.
|
| { |
| - // TODO(andrew): this can easily overflow. |
| - energy += audioFrame.data_[position] * audioFrame.data_[position]; |
| + const int16_t* frame_data = audioFrame.data(); |
| + for(size_t position = 0; position < audioFrame.samples_per_channel_; |
| + position++) |
| + { |
| + // TODO(andrew): this can easily overflow. |
| + energy += frame_data[position] * frame_data[position]; |
| + } |
| } |
| return energy; |
| } |
| @@ -54,24 +58,31 @@ uint32_t CalculateEnergy(const AudioFrame& audioFrame) |
| void RampIn(AudioFrame& audioFrame) |
| { |
| assert(rampSize <= audioFrame.samples_per_channel_); |
| - for(size_t i = 0; i < rampSize; i++) |
| + if (!audioFrame.muted()) |
|
hlundin-webrtc
2017/03/17 14:29:39
Early return.
yujo
2017/03/17 23:55:54
Done.
|
| { |
| - audioFrame.data_[i] = static_cast<int16_t>(rampArray[i] * |
| - audioFrame.data_[i]); |
| + int16_t* frame_data = audioFrame.mutable_data(); |
| + for(size_t i = 0; i < rampSize; i++) |
| + { |
| + frame_data[i] = static_cast<int16_t>(rampArray[i] * frame_data[i]); |
| + } |
| } |
| } |
| void RampOut(AudioFrame& audioFrame) |
| { |
| assert(rampSize <= audioFrame.samples_per_channel_); |
| - for(size_t i = 0; i < rampSize; i++) |
| + if (!audioFrame.muted()) |
|
hlundin-webrtc
2017/03/17 14:29:39
Early return.
yujo
2017/03/17 23:55:54
Done.
|
| { |
| - const size_t rampPos = rampSize - 1 - i; |
| - audioFrame.data_[i] = static_cast<int16_t>(rampArray[rampPos] * |
| - audioFrame.data_[i]); |
| + int16_t* frame_data = audioFrame.mutable_data(); |
| + for(size_t i = 0; i < rampSize; i++) |
| + { |
| + const size_t rampPos = rampSize - 1 - i; |
| + frame_data[i] = static_cast<int16_t>(rampArray[rampPos] * |
| + frame_data[i]); |
| + } |
| + memset(&frame_data[rampSize], 0, |
| + (audioFrame.samples_per_channel_ - rampSize) * |
| + sizeof(frame_data[0])); |
| } |
| - memset(&audioFrame.data_[rampSize], 0, |
| - (audioFrame.samples_per_channel_ - rampSize) * |
| - sizeof(audioFrame.data_[0])); |
| } |
| } // namespace webrtc |