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 #ifndef WEBRTC_VOICE_ENGINE_AUDIO_FRAME_OPERATIONS_H_ | 11 #ifndef WEBRTC_VOICE_ENGINE_AUDIO_FRAME_OPERATIONS_H_ |
12 #define WEBRTC_VOICE_ENGINE_AUDIO_FRAME_OPERATIONS_H_ | 12 #define WEBRTC_VOICE_ENGINE_AUDIO_FRAME_OPERATIONS_H_ |
13 | 13 |
14 #include "webrtc/typedefs.h" | 14 #include "webrtc/typedefs.h" |
15 | 15 |
16 namespace webrtc { | 16 namespace webrtc { |
17 | 17 |
18 class AudioFrame; | 18 class AudioFrame; |
19 | 19 |
20 // TODO(andrew): consolidate this with utility.h and audio_frame_manipulator.h. | 20 // TODO(andrew): consolidate this with utility.h and audio_frame_manipulator.h. |
21 // Change reference parameters to pointers. Consider using a namespace rather | 21 // Change reference parameters to pointers. Consider using a namespace rather |
22 // than a class. | 22 // than a class. |
23 class AudioFrameOperations { | 23 class AudioFrameOperations { |
24 public: | 24 public: |
25 // Upmixes mono |src_audio| to stereo |dst_audio|. This is an out-of-place | 25 // Upmixes mono |src_audio| to stereo |dst_audio|. This is an out-of-place |
26 // operation, meaning src_audio and dst_audio must point to different | 26 // operation, meaning src_audio and dst_audio must point to different |
27 // buffers. It is the caller's responsibility to ensure that |dst_audio| is | 27 // buffers. It is the caller's responsibility to ensure that |dst_audio| is |
28 // sufficiently large. | 28 // sufficiently large. |
29 static void MonoToStereo(const int16_t* src_audio, int samples_per_channel, | 29 static void MonoToStereo(const int16_t* src_audio, size_t samples_per_channel, |
30 int16_t* dst_audio); | 30 int16_t* dst_audio); |
31 // |frame.num_channels_| will be updated. This version checks for sufficient | 31 // |frame.num_channels_| will be updated. This version checks for sufficient |
32 // buffer size and that |num_channels_| is mono. | 32 // buffer size and that |num_channels_| is mono. |
33 static int MonoToStereo(AudioFrame* frame); | 33 static int MonoToStereo(AudioFrame* frame); |
34 | 34 |
35 // Downmixes stereo |src_audio| to mono |dst_audio|. This is an in-place | 35 // Downmixes stereo |src_audio| to mono |dst_audio|. This is an in-place |
36 // operation, meaning |src_audio| and |dst_audio| may point to the same | 36 // operation, meaning |src_audio| and |dst_audio| may point to the same |
37 // buffer. | 37 // buffer. |
38 static void StereoToMono(const int16_t* src_audio, int samples_per_channel, | 38 static void StereoToMono(const int16_t* src_audio, size_t samples_per_channel, |
39 int16_t* dst_audio); | 39 int16_t* dst_audio); |
40 // |frame.num_channels_| will be updated. This version checks that | 40 // |frame.num_channels_| will be updated. This version checks that |
41 // |num_channels_| is stereo. | 41 // |num_channels_| is stereo. |
42 static int StereoToMono(AudioFrame* frame); | 42 static int StereoToMono(AudioFrame* frame); |
43 | 43 |
44 // Swap the left and right channels of |frame|. Fails silently if |frame| is | 44 // Swap the left and right channels of |frame|. Fails silently if |frame| is |
45 // not stereo. | 45 // not stereo. |
46 static void SwapStereoChannels(AudioFrame* frame); | 46 static void SwapStereoChannels(AudioFrame* frame); |
47 | 47 |
48 // Zeros out the audio and sets |frame.energy| to zero. | 48 // Zeros out the audio and sets |frame.energy| to zero. |
49 static void Mute(AudioFrame& frame); | 49 static void Mute(AudioFrame& frame); |
50 | 50 |
51 static int Scale(float left, float right, AudioFrame& frame); | 51 static int Scale(float left, float right, AudioFrame& frame); |
52 | 52 |
53 static int ScaleWithSat(float scale, AudioFrame& frame); | 53 static int ScaleWithSat(float scale, AudioFrame& frame); |
54 }; | 54 }; |
55 | 55 |
56 } // namespace webrtc | 56 } // namespace webrtc |
57 | 57 |
58 #endif // #ifndef WEBRTC_VOICE_ENGINE_AUDIO_FRAME_OPERATIONS_H_ | 58 #endif // #ifndef WEBRTC_VOICE_ENGINE_AUDIO_FRAME_OPERATIONS_H_ |
OLD | NEW |