Chromium Code Reviews

Side by Side Diff: webrtc/modules/audio_processing/audio_buffer.h

Issue 1227213002: Update audio code to use size_t more correctly, webrtc/modules/audio_processing/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 15 matching lines...)
26 26
27 enum Band { 27 enum Band {
28 kBand0To8kHz = 0, 28 kBand0To8kHz = 0,
29 kBand8To16kHz = 1, 29 kBand8To16kHz = 1,
30 kBand16To24kHz = 2 30 kBand16To24kHz = 2
31 }; 31 };
32 32
33 class AudioBuffer { 33 class AudioBuffer {
34 public: 34 public:
35 // TODO(ajm): Switch to take ChannelLayouts. 35 // TODO(ajm): Switch to take ChannelLayouts.
36 AudioBuffer(int input_num_frames, 36 AudioBuffer(size_t input_num_frames,
37 int num_input_channels, 37 int num_input_channels,
38 int process_num_frames, 38 size_t process_num_frames,
39 int num_process_channels, 39 int num_process_channels,
40 int output_num_frames); 40 size_t output_num_frames);
41 virtual ~AudioBuffer(); 41 virtual ~AudioBuffer();
42 42
43 int num_channels() const; 43 int num_channels() const;
44 void set_num_channels(int num_channels); 44 void set_num_channels(int num_channels);
45 int num_frames() const; 45 size_t num_frames() const;
46 int num_frames_per_band() const; 46 size_t num_frames_per_band() const;
47 int num_keyboard_frames() const; 47 size_t num_keyboard_frames() const;
48 int num_bands() const; 48 size_t num_bands() const;
49 49
50 // Returns a pointer array to the full-band channels. 50 // Returns a pointer array to the full-band channels.
51 // Usage: 51 // Usage:
52 // channels()[channel][sample]. 52 // channels()[channel][sample].
53 // Where: 53 // Where:
54 // 0 <= channel < |num_proc_channels_| 54 // 0 <= channel < |num_proc_channels_|
55 // 0 <= sample < |proc_num_frames_| 55 // 0 <= sample < |proc_num_frames_|
56 int16_t* const* channels(); 56 int16_t* const* channels();
57 const int16_t* const* channels_const() const; 57 const int16_t* const* channels_const() const;
58 float* const* channels_f(); 58 float* const* channels_f();
(...skipping 47 matching lines...)
106 AudioFrame::VADActivity activity() const; 106 AudioFrame::VADActivity activity() const;
107 107
108 // Use for int16 interleaved data. 108 // Use for int16 interleaved data.
109 void DeinterleaveFrom(AudioFrame* audioFrame); 109 void DeinterleaveFrom(AudioFrame* audioFrame);
110 // If |data_changed| is false, only the non-audio data members will be copied 110 // If |data_changed| is false, only the non-audio data members will be copied
111 // to |frame|. 111 // to |frame|.
112 void InterleaveTo(AudioFrame* frame, bool data_changed) const; 112 void InterleaveTo(AudioFrame* frame, bool data_changed) const;
113 113
114 // Use for float deinterleaved data. 114 // Use for float deinterleaved data.
115 void CopyFrom(const float* const* data, 115 void CopyFrom(const float* const* data,
116 int num_frames, 116 size_t num_frames,
117 AudioProcessing::ChannelLayout layout); 117 AudioProcessing::ChannelLayout layout);
118 void CopyTo(int num_frames, 118 void CopyTo(size_t num_frames,
119 AudioProcessing::ChannelLayout layout, 119 AudioProcessing::ChannelLayout layout,
120 float* const* data); 120 float* const* data);
121 void CopyLowPassToReference(); 121 void CopyLowPassToReference();
122 122
123 // Splits the signal into different bands. 123 // Splits the signal into different bands.
124 void SplitIntoFrequencyBands(); 124 void SplitIntoFrequencyBands();
125 // Recombine the different bands into one signal. 125 // Recombine the different bands into one signal.
126 void MergeFrequencyBands(); 126 void MergeFrequencyBands();
127 127
128 private: 128 private:
129 // Called from DeinterleaveFrom() and CopyFrom(). 129 // Called from DeinterleaveFrom() and CopyFrom().
130 void InitForNewData(); 130 void InitForNewData();
131 131
132 // The audio is passed into DeinterleaveFrom() or CopyFrom() with input 132 // The audio is passed into DeinterleaveFrom() or CopyFrom() with input
133 // format (samples per channel and number of channels). 133 // format (samples per channel and number of channels).
134 const int input_num_frames_; 134 const size_t input_num_frames_;
135 const int num_input_channels_; 135 const int num_input_channels_;
136 // The audio is stored by DeinterleaveFrom() or CopyFrom() with processing 136 // The audio is stored by DeinterleaveFrom() or CopyFrom() with processing
137 // format. 137 // format.
138 const int proc_num_frames_; 138 const size_t proc_num_frames_;
139 const int num_proc_channels_; 139 const int num_proc_channels_;
140 // The audio is returned by InterleaveTo() and CopyTo() with output samples 140 // The audio is returned by InterleaveTo() and CopyTo() with output samples
141 // per channels and the current number of channels. This last one can be 141 // per channels and the current number of channels. This last one can be
142 // changed at any time using set_num_channels(). 142 // changed at any time using set_num_channels().
143 const int output_num_frames_; 143 const size_t output_num_frames_;
144 int num_channels_; 144 int num_channels_;
145 145
146 int num_bands_; 146 size_t num_bands_;
147 int num_split_frames_; 147 size_t num_split_frames_;
148 bool mixed_low_pass_valid_; 148 bool mixed_low_pass_valid_;
149 bool reference_copied_; 149 bool reference_copied_;
150 AudioFrame::VADActivity activity_; 150 AudioFrame::VADActivity activity_;
151 151
152 const float* keyboard_data_; 152 const float* keyboard_data_;
153 rtc::scoped_ptr<IFChannelBuffer> data_; 153 rtc::scoped_ptr<IFChannelBuffer> data_;
154 rtc::scoped_ptr<IFChannelBuffer> split_data_; 154 rtc::scoped_ptr<IFChannelBuffer> split_data_;
155 rtc::scoped_ptr<SplittingFilter> splitting_filter_; 155 rtc::scoped_ptr<SplittingFilter> splitting_filter_;
156 rtc::scoped_ptr<ChannelBuffer<int16_t> > mixed_low_pass_channels_; 156 rtc::scoped_ptr<ChannelBuffer<int16_t> > mixed_low_pass_channels_;
157 rtc::scoped_ptr<ChannelBuffer<int16_t> > low_pass_reference_channels_; 157 rtc::scoped_ptr<ChannelBuffer<int16_t> > low_pass_reference_channels_;
158 rtc::scoped_ptr<IFChannelBuffer> input_buffer_; 158 rtc::scoped_ptr<IFChannelBuffer> input_buffer_;
159 rtc::scoped_ptr<ChannelBuffer<float> > process_buffer_; 159 rtc::scoped_ptr<ChannelBuffer<float> > process_buffer_;
160 ScopedVector<PushSincResampler> input_resamplers_; 160 ScopedVector<PushSincResampler> input_resamplers_;
161 ScopedVector<PushSincResampler> output_resamplers_; 161 ScopedVector<PushSincResampler> output_resamplers_;
162 }; 162 };
163 163
164 } // namespace webrtc 164 } // namespace webrtc
165 165
166 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_BUFFER_H_ 166 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_BUFFER_H_
OLDNEW

Powered by Google App Engine