OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_UTILITY_INCLUDE_AUDIO_FRAME_OPERATIONS_H_ | |
12 #define WEBRTC_MODULES_UTILITY_INCLUDE_AUDIO_FRAME_OPERATIONS_H_ | |
13 | |
14 #pragma message("WARNING: utility/interface is DEPRECATED; use utility/include") | |
15 | |
16 #include "webrtc/typedefs.h" | |
17 | |
18 namespace webrtc { | |
19 | |
20 class AudioFrame; | |
21 | |
22 // TODO(andrew): consolidate this with utility.h and audio_frame_manipulator.h. | |
23 // Change reference parameters to pointers. Consider using a namespace rather | |
24 // than a class. | |
25 class AudioFrameOperations { | |
26 public: | |
27 // Upmixes mono |src_audio| to stereo |dst_audio|. This is an out-of-place | |
28 // operation, meaning src_audio and dst_audio must point to different | |
29 // buffers. It is the caller's responsibility to ensure that |dst_audio| is | |
30 // sufficiently large. | |
31 static void MonoToStereo(const int16_t* src_audio, size_t samples_per_channel, | |
32 int16_t* dst_audio); | |
33 // |frame.num_channels_| will be updated. This version checks for sufficient | |
34 // buffer size and that |num_channels_| is mono. | |
35 static int MonoToStereo(AudioFrame* frame); | |
36 | |
37 // Downmixes stereo |src_audio| to mono |dst_audio|. This is an in-place | |
38 // operation, meaning |src_audio| and |dst_audio| may point to the same | |
39 // buffer. | |
40 static void StereoToMono(const int16_t* src_audio, size_t samples_per_channel, | |
41 int16_t* dst_audio); | |
42 // |frame.num_channels_| will be updated. This version checks that | |
43 // |num_channels_| is stereo. | |
44 static int StereoToMono(AudioFrame* frame); | |
45 | |
46 // Swap the left and right channels of |frame|. Fails silently if |frame| is | |
47 // not stereo. | |
48 static void SwapStereoChannels(AudioFrame* frame); | |
49 | |
50 // Zeros out the audio and sets |frame.energy| to zero. | |
51 static void Mute(AudioFrame& frame); | |
52 | |
53 static int Scale(float left, float right, AudioFrame& frame); | |
54 | |
55 static int ScaleWithSat(float scale, AudioFrame& frame); | |
56 }; | |
57 | |
58 } // namespace webrtc | |
59 | |
60 #endif // #ifndef WEBRTC_MODULES_UTILITY_INCLUDE_AUDIO_FRAME_OPERATIONS_H_ | |
OLD | NEW |