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 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 // Downmixes stereo |src_audio| to mono |dst_audio|. This is an in-place | 47 // Downmixes stereo |src_audio| to mono |dst_audio|. This is an in-place |
48 // operation, meaning |src_audio| and |dst_audio| may point to the same | 48 // operation, meaning |src_audio| and |dst_audio| may point to the same |
49 // buffer. | 49 // buffer. |
50 static void StereoToMono(const int16_t* src_audio, | 50 static void StereoToMono(const int16_t* src_audio, |
51 size_t samples_per_channel, | 51 size_t samples_per_channel, |
52 int16_t* dst_audio); | 52 int16_t* dst_audio); |
53 // |frame.num_channels_| will be updated. This version checks that | 53 // |frame.num_channels_| will be updated. This version checks that |
54 // |num_channels_| is stereo. | 54 // |num_channels_| is stereo. |
55 static int StereoToMono(AudioFrame* frame); | 55 static int StereoToMono(AudioFrame* frame); |
56 | 56 |
57 // Downmixes 4 channels |src_audio| to stereo |dst_audio|. This is an in-place | |
58 // operation, meaning |src_audio| and |dst_audio| may point to the same | |
59 // buffer. | |
60 static void QuadToStereo(const int16_t* src_audio, | |
61 size_t samples_per_channel, | |
62 int16_t* dst_audio); | |
aleloi
2017/02/24 10:39:31
Add blank line
jens.nielsen
2017/02/24 14:55:49
Done.
| |
63 // |frame.num_channels_| will be updated. This version checks that | |
64 // |num_channels_| is 4 channels. | |
65 static int QuadToStereo(AudioFrame* frame); | |
66 | |
67 // Downmixes 4 channels |src_audio| to mono |dst_audio|. This is an in-place | |
68 // operation, meaning |src_audio| and |dst_audio| may point to the same | |
69 // buffer. | |
70 static void QuadToMono(const int16_t* src_audio, | |
71 size_t samples_per_channel, | |
72 int16_t* dst_audio); | |
aleloi
2017/02/24 10:39:31
Add blank line
jens.nielsen
2017/02/24 14:55:48
Done.
| |
73 // |frame.num_channels_| will be updated. This version checks that | |
74 // |num_channels_| is stereo. | |
aleloi
2017/02/24 10:39:31
Shouldn't |num_channels_| be 4 here and not stereo
jens.nielsen
2017/02/24 14:55:48
Done. (Silly copy-paste error, sorry about that)
| |
75 static int QuadToMono(AudioFrame* frame); | |
76 | |
77 // Downmixes |src_channels| |src_audio| to |dst_channels| |dst_audio|. | |
78 // This is an in-place operation, meaning |src_audio| and |dst_audio| | |
79 // may point to the same buffer. | |
hlundin-webrtc
2017/02/24 09:46:36
Comment on which combinations of src_channels and
jens.nielsen
2017/02/24 14:55:49
Done.
| |
80 static void AudioFrameOperations::DownmixChannels(const int16_t* src_audio, | |
81 size_t src_channels, | |
82 size_t samples_per_channel, | |
83 int16_t* dst_audio, | |
84 size_t dst_channels); | |
aleloi
2017/02/24 10:39:31
Please move the dst_audio to the end.
Quote from
jens.nielsen
2017/02/24 14:55:49
Done.
| |
85 | |
86 // |frame.num_channels_| will be updated. This version checks that | |
87 // |num_channels_| and |dst_channels| are valid and performs relevant | |
88 // downmix. | |
hlundin-webrtc
2017/02/24 09:46:36
Comment on which combinations of src_channels and
jens.nielsen
2017/02/24 14:55:49
Done.
| |
89 static int AudioFrameOperations::DownmixChannels(AudioFrame* frame, | |
90 size_t dst_channels); | |
aleloi
2017/02/24 10:39:31
Please swap function parameters here as well. |dst
jens.nielsen
2017/02/24 14:55:49
Done.
| |
91 | |
57 // Swap the left and right channels of |frame|. Fails silently if |frame| is | 92 // Swap the left and right channels of |frame|. Fails silently if |frame| is |
58 // not stereo. | 93 // not stereo. |
59 static void SwapStereoChannels(AudioFrame* frame); | 94 static void SwapStereoChannels(AudioFrame* frame); |
60 | 95 |
61 // Conditionally zero out contents of |frame| for implementing audio mute: | 96 // Conditionally zero out contents of |frame| for implementing audio mute: |
62 // |previous_frame_muted| && |current_frame_muted| - Zero out whole frame. | 97 // |previous_frame_muted| && |current_frame_muted| - Zero out whole frame. |
63 // |previous_frame_muted| && !|current_frame_muted| - Fade-in at frame start. | 98 // |previous_frame_muted| && !|current_frame_muted| - Fade-in at frame start. |
64 // !|previous_frame_muted| && |current_frame_muted| - Fade-out at frame end. | 99 // !|previous_frame_muted| && |current_frame_muted| - Fade-out at frame end. |
65 // !|previous_frame_muted| && !|current_frame_muted| - Leave frame untouched. | 100 // !|previous_frame_muted| && !|current_frame_muted| - Leave frame untouched. |
66 static void Mute(AudioFrame* frame, | 101 static void Mute(AudioFrame* frame, |
67 bool previous_frame_muted, | 102 bool previous_frame_muted, |
68 bool current_frame_muted); | 103 bool current_frame_muted); |
69 | 104 |
70 // Zero out contents of frame. | 105 // Zero out contents of frame. |
71 static void Mute(AudioFrame* frame); | 106 static void Mute(AudioFrame* frame); |
72 | 107 |
73 // Halve samples in |frame|. | 108 // Halve samples in |frame|. |
74 static void ApplyHalfGain(AudioFrame* frame); | 109 static void ApplyHalfGain(AudioFrame* frame); |
75 | 110 |
76 static int Scale(float left, float right, AudioFrame& frame); | 111 static int Scale(float left, float right, AudioFrame& frame); |
77 | 112 |
78 static int ScaleWithSat(float scale, AudioFrame& frame); | 113 static int ScaleWithSat(float scale, AudioFrame& frame); |
79 }; | 114 }; |
80 | 115 |
81 } // namespace webrtc | 116 } // namespace webrtc |
82 | 117 |
83 #endif // WEBRTC_AUDIO_UTILITY_AUDIO_FRAME_OPERATIONS_H_ | 118 #endif // WEBRTC_AUDIO_UTILITY_AUDIO_FRAME_OPERATIONS_H_ |
OLD | NEW |