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

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

Issue 2750783004: Add mute state field to AudioFrame. (Closed)
Patch Set: Update new usages of AudioFrame::data_ Created 3 years, 6 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 23 matching lines...) Expand all
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 uint32_t CalculateEnergy(const AudioFrame& audioFrame) 42 uint32_t CalculateEnergy(const AudioFrame& audioFrame)
43 { 43 {
44 if (audioFrame.muted()) return 0;
45
44 uint32_t energy = 0; 46 uint32_t energy = 0;
47 const int16_t* frame_data = audioFrame.data();
45 for(size_t position = 0; position < audioFrame.samples_per_channel_; 48 for(size_t position = 0; position < audioFrame.samples_per_channel_;
46 position++) 49 position++)
47 { 50 {
48 // TODO(andrew): this can easily overflow. 51 // TODO(andrew): this can easily overflow.
49 energy += audioFrame.data_[position] * audioFrame.data_[position]; 52 energy += frame_data[position] * frame_data[position];
50 } 53 }
51 return energy; 54 return energy;
52 } 55 }
53 56
54 void RampIn(AudioFrame& audioFrame) 57 void RampIn(AudioFrame& audioFrame)
55 { 58 {
56 assert(rampSize <= audioFrame.samples_per_channel_); 59 assert(rampSize <= audioFrame.samples_per_channel_);
60 if (audioFrame.muted()) return;
61
62 int16_t* frame_data = audioFrame.mutable_data();
57 for(size_t i = 0; i < rampSize; i++) 63 for(size_t i = 0; i < rampSize; i++)
58 { 64 {
59 audioFrame.data_[i] = static_cast<int16_t>(rampArray[i] * 65 frame_data[i] = static_cast<int16_t>(rampArray[i] * frame_data[i]);
60 audioFrame.data_[i]);
61 } 66 }
62 } 67 }
63 68
64 void RampOut(AudioFrame& audioFrame) 69 void RampOut(AudioFrame& audioFrame)
65 { 70 {
66 assert(rampSize <= audioFrame.samples_per_channel_); 71 assert(rampSize <= audioFrame.samples_per_channel_);
72 if (audioFrame.muted()) return;
73
74 int16_t* frame_data = audioFrame.mutable_data();
67 for(size_t i = 0; i < rampSize; i++) 75 for(size_t i = 0; i < rampSize; i++)
68 { 76 {
69 const size_t rampPos = rampSize - 1 - i; 77 const size_t rampPos = rampSize - 1 - i;
70 audioFrame.data_[i] = static_cast<int16_t>(rampArray[rampPos] * 78 frame_data[i] = static_cast<int16_t>(rampArray[rampPos] *
71 audioFrame.data_[i]); 79 frame_data[i]);
72 } 80 }
73 memset(&audioFrame.data_[rampSize], 0, 81 memset(&frame_data[rampSize], 0,
74 (audioFrame.samples_per_channel_ - rampSize) * 82 (audioFrame.samples_per_channel_ - rampSize) *
75 sizeof(audioFrame.data_[0])); 83 sizeof(frame_data[0]));
76 } 84 }
77 } // namespace webrtc 85 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698