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

Side by Side Diff: webrtc/audio/utility/audio_frame_operations.h

Issue 2712743004: Support 4 channel mic in Windows Core Audio (Closed)
Patch Set: Fix another non-Windows build error Created 3 years, 9 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 22 matching lines...) Expand all
33 // |result_frame| is empty. 33 // |result_frame| is empty.
34 static void Add(const AudioFrame& frame_to_add, AudioFrame* result_frame); 34 static void Add(const AudioFrame& frame_to_add, AudioFrame* result_frame);
35 35
36 // Upmixes mono |src_audio| to stereo |dst_audio|. This is an out-of-place 36 // Upmixes mono |src_audio| to stereo |dst_audio|. This is an out-of-place
37 // operation, meaning src_audio and dst_audio must point to different 37 // operation, meaning src_audio and dst_audio must point to different
38 // buffers. It is the caller's responsibility to ensure that |dst_audio| is 38 // buffers. It is the caller's responsibility to ensure that |dst_audio| is
39 // sufficiently large. 39 // sufficiently large.
40 static void MonoToStereo(const int16_t* src_audio, 40 static void MonoToStereo(const int16_t* src_audio,
41 size_t samples_per_channel, 41 size_t samples_per_channel,
42 int16_t* dst_audio); 42 int16_t* dst_audio);
43
43 // |frame.num_channels_| will be updated. This version checks for sufficient 44 // |frame.num_channels_| will be updated. This version checks for sufficient
44 // buffer size and that |num_channels_| is mono. 45 // buffer size and that |num_channels_| is mono.
45 static int MonoToStereo(AudioFrame* frame); 46 static int MonoToStereo(AudioFrame* frame);
46 47
47 // Downmixes stereo |src_audio| to mono |dst_audio|. This is an in-place 48 // 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 49 // operation, meaning |src_audio| and |dst_audio| may point to the same
49 // buffer. 50 // buffer.
50 static void StereoToMono(const int16_t* src_audio, 51 static void StereoToMono(const int16_t* src_audio,
51 size_t samples_per_channel, 52 size_t samples_per_channel,
52 int16_t* dst_audio); 53 int16_t* dst_audio);
54
53 // |frame.num_channels_| will be updated. This version checks that 55 // |frame.num_channels_| will be updated. This version checks that
54 // |num_channels_| is stereo. 56 // |num_channels_| is stereo.
55 static int StereoToMono(AudioFrame* frame); 57 static int StereoToMono(AudioFrame* frame);
56 58
59 // Downmixes 4 channels |src_audio| to stereo |dst_audio|. This is an in-place
60 // operation, meaning |src_audio| and |dst_audio| may point to the same
61 // buffer.
62 static void QuadToStereo(const int16_t* src_audio,
63 size_t samples_per_channel,
64 int16_t* dst_audio);
65
66 // |frame.num_channels_| will be updated. This version checks that
67 // |num_channels_| is 4 channels.
68 static int QuadToStereo(AudioFrame* frame);
69
70 // Downmixes 4 channels |src_audio| to mono |dst_audio|. This is an in-place
71 // operation, meaning |src_audio| and |dst_audio| may point to the same
72 // buffer.
73 static void QuadToMono(const int16_t* src_audio,
74 size_t samples_per_channel,
75 int16_t* dst_audio);
76
77 // |frame.num_channels_| will be updated. This version checks that
78 // |num_channels_| is 4 channels.
79 static int QuadToMono(AudioFrame* frame);
80
81 // Downmixes |src_channels| |src_audio| to |dst_channels| |dst_audio|.
82 // This is an in-place operation, meaning |src_audio| and |dst_audio|
83 // may point to the same buffer. Supported channel combinations are
84 // Stereo to Mono, Quad to Mono, and Quad to Stereo.
85 static void DownmixChannels(const int16_t* src_audio,
86 size_t src_channels,
87 size_t samples_per_channel,
88 size_t dst_channels,
89 int16_t* dst_audio);
90
91 // |frame.num_channels_| will be updated. This version checks that
92 // |num_channels_| and |dst_channels| are valid and performs relevant
93 // downmix. Supported channel combinations are Stereo to Mono, Quad to Mono,
94 // and Quad to Stereo.
95 static int DownmixChannels(size_t dst_channels, AudioFrame* frame);
96
57 // Swap the left and right channels of |frame|. Fails silently if |frame| is 97 // Swap the left and right channels of |frame|. Fails silently if |frame| is
58 // not stereo. 98 // not stereo.
59 static void SwapStereoChannels(AudioFrame* frame); 99 static void SwapStereoChannels(AudioFrame* frame);
60 100
61 // Conditionally zero out contents of |frame| for implementing audio mute: 101 // Conditionally zero out contents of |frame| for implementing audio mute:
62 // |previous_frame_muted| && |current_frame_muted| - Zero out whole frame. 102 // |previous_frame_muted| && |current_frame_muted| - Zero out whole frame.
63 // |previous_frame_muted| && !|current_frame_muted| - Fade-in at frame start. 103 // |previous_frame_muted| && !|current_frame_muted| - Fade-in at frame start.
64 // !|previous_frame_muted| && |current_frame_muted| - Fade-out at frame end. 104 // !|previous_frame_muted| && |current_frame_muted| - Fade-out at frame end.
65 // !|previous_frame_muted| && !|current_frame_muted| - Leave frame untouched. 105 // !|previous_frame_muted| && !|current_frame_muted| - Leave frame untouched.
66 static void Mute(AudioFrame* frame, 106 static void Mute(AudioFrame* frame,
67 bool previous_frame_muted, 107 bool previous_frame_muted,
68 bool current_frame_muted); 108 bool current_frame_muted);
69 109
70 // Zero out contents of frame. 110 // Zero out contents of frame.
71 static void Mute(AudioFrame* frame); 111 static void Mute(AudioFrame* frame);
72 112
73 // Halve samples in |frame|. 113 // Halve samples in |frame|.
74 static void ApplyHalfGain(AudioFrame* frame); 114 static void ApplyHalfGain(AudioFrame* frame);
75 115
76 static int Scale(float left, float right, AudioFrame& frame); 116 static int Scale(float left, float right, AudioFrame& frame);
77 117
78 static int ScaleWithSat(float scale, AudioFrame& frame); 118 static int ScaleWithSat(float scale, AudioFrame& frame);
79 }; 119 };
80 120
81 } // namespace webrtc 121 } // namespace webrtc
82 122
83 #endif // WEBRTC_AUDIO_UTILITY_AUDIO_FRAME_OPERATIONS_H_ 123 #endif // WEBRTC_AUDIO_UTILITY_AUDIO_FRAME_OPERATIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698