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 |
11 #include "webrtc/base/checks.h" | 11 #include "webrtc/base/checks.h" |
12 #include "webrtc/modules/audio_mixer/audio_frame_manipulator.h" | 12 #include "webrtc/modules/audio_mixer/audio_frame_manipulator.h" |
13 #include "webrtc/modules/include/module_common_types.h" | 13 #include "webrtc/modules/include/module_common_types.h" |
14 #include "webrtc/modules/utility/include/audio_frame_operations.h" | 14 #include "webrtc/modules/utility/include/audio_frame_operations.h" |
15 #include "webrtc/typedefs.h" | |
16 | 15 |
17 namespace webrtc { | 16 namespace webrtc { |
18 | 17 |
19 uint32_t AudioMixerCalculateEnergy(const AudioFrame& audio_frame) { | 18 uint32_t AudioMixerCalculateEnergy(const AudioFrame& audio_frame) { |
20 uint32_t energy = 0; | 19 uint32_t energy = 0; |
21 for (size_t position = 0; position < audio_frame.samples_per_channel_; | 20 for (size_t position = 0; position < audio_frame.samples_per_channel_; |
22 position++) { | 21 position++) { |
23 // TODO(aleloi): This can overflow. Convert to floats. | 22 // TODO(aleloi): This can overflow. Convert to floats. |
24 energy += audio_frame.data_[position] * audio_frame.data_[position]; | 23 energy += audio_frame.data_[position] * audio_frame.data_[position]; |
25 } | 24 } |
(...skipping 22 matching lines...) Expand all Loading... |
48 void RemixFrame(size_t target_number_of_channels, AudioFrame* frame) { | 47 void RemixFrame(size_t target_number_of_channels, AudioFrame* frame) { |
49 RTC_DCHECK_GE(target_number_of_channels, 1u); | 48 RTC_DCHECK_GE(target_number_of_channels, 1u); |
50 RTC_DCHECK_LE(target_number_of_channels, 2u); | 49 RTC_DCHECK_LE(target_number_of_channels, 2u); |
51 if (frame->num_channels_ == 1 && target_number_of_channels == 2) { | 50 if (frame->num_channels_ == 1 && target_number_of_channels == 2) { |
52 AudioFrameOperations::MonoToStereo(frame); | 51 AudioFrameOperations::MonoToStereo(frame); |
53 } else if (frame->num_channels_ == 2 && target_number_of_channels == 1) { | 52 } else if (frame->num_channels_ == 2 && target_number_of_channels == 1) { |
54 AudioFrameOperations::StereoToMono(frame); | 53 AudioFrameOperations::StereoToMono(frame); |
55 } | 54 } |
56 } | 55 } |
57 } // namespace webrtc | 56 } // namespace webrtc |
OLD | NEW |