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

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

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 return num_bands; 42 return num_bands;
43 } 43 }
44 44
45 } // namespace 45 } // namespace
46 46
47 AudioBuffer::AudioBuffer(size_t input_num_frames, 47 AudioBuffer::AudioBuffer(size_t input_num_frames,
48 size_t num_input_channels, 48 size_t num_input_channels,
49 size_t process_num_frames, 49 size_t process_num_frames,
50 size_t num_process_channels, 50 size_t num_process_channels,
51 size_t output_num_frames) 51 size_t output_num_frames)
52 : input_num_frames_(input_num_frames), 52 : input_num_frames_(input_num_frames),
53 num_input_channels_(num_input_channels), 53 num_input_channels_(num_input_channels),
54 proc_num_frames_(process_num_frames), 54 proc_num_frames_(process_num_frames),
55 num_proc_channels_(num_process_channels), 55 num_proc_channels_(num_process_channels),
56 output_num_frames_(output_num_frames), 56 output_num_frames_(output_num_frames),
57 num_channels_(num_process_channels), 57 num_channels_(num_process_channels),
58 num_bands_(NumBandsFromSamplesPerChannel(proc_num_frames_)), 58 num_bands_(NumBandsFromSamplesPerChannel(proc_num_frames_)),
59 num_split_frames_(rtc::CheckedDivExact(proc_num_frames_, num_bands_)), 59 num_split_frames_(rtc::CheckedDivExact(proc_num_frames_, num_bands_)),
60 mixed_low_pass_valid_(false), 60 mixed_low_pass_valid_(false),
61 reference_copied_(false), 61 reference_copied_(false),
62 activity_(AudioFrame::kVadUnknown), 62 activity_(AudioFrame::kVadUnknown),
63 keyboard_data_(NULL), 63 keyboard_data_(nullptr),
64 data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)) { 64 data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)) {
65 RTC_DCHECK_GT(input_num_frames_, 0); 65 RTC_DCHECK_GT(input_num_frames_, 0);
66 RTC_DCHECK_GT(proc_num_frames_, 0); 66 RTC_DCHECK_GT(proc_num_frames_, 0);
67 RTC_DCHECK_GT(output_num_frames_, 0); 67 RTC_DCHECK_GT(output_num_frames_, 0);
68 RTC_DCHECK_GT(num_input_channels_, 0); 68 RTC_DCHECK_GT(num_input_channels_, 0);
69 RTC_DCHECK_GT(num_proc_channels_, 0); 69 RTC_DCHECK_GT(num_proc_channels_, 0);
70 RTC_DCHECK_LE(num_proc_channels_, num_input_channels_); 70 RTC_DCHECK_LE(num_proc_channels_, num_input_channels_);
71 71
72 if (input_num_frames_ != proc_num_frames_ || 72 if (input_num_frames_ != proc_num_frames_ ||
73 output_num_frames_ != proc_num_frames_) { 73 output_num_frames_ != proc_num_frames_) {
74 // Create an intermediate buffer for resampling. 74 // Create an intermediate buffer for resampling.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 } 176 }
177 177
178 // Upmix. 178 // Upmix.
179 for (size_t i = num_channels_; i < stream_config.num_channels(); ++i) { 179 for (size_t i = num_channels_; i < stream_config.num_channels(); ++i) {
180 memcpy(data[i], data[0], output_num_frames_ * sizeof(**data)); 180 memcpy(data[i], data[0], output_num_frames_ * sizeof(**data));
181 } 181 }
182 } 182 }
183 183
184 void AudioBuffer::InitForNewData() { 184 void AudioBuffer::InitForNewData() {
185 keyboard_data_ = NULL; 185 keyboard_data_ = nullptr;
186 mixed_low_pass_valid_ = false; 186 mixed_low_pass_valid_ = false;
187 reference_copied_ = false; 187 reference_copied_ = false;
188 activity_ = AudioFrame::kVadUnknown; 188 activity_ = AudioFrame::kVadUnknown;
189 num_channels_ = num_proc_channels_; 189 num_channels_ = num_proc_channels_;
190 data_->set_num_channels(num_proc_channels_); 190 data_->set_num_channels(num_proc_channels_);
191 if (split_data_.get()) { 191 if (split_data_.get()) {
192 split_data_->set_num_channels(num_proc_channels_); 192 split_data_->set_num_channels(num_proc_channels_);
193 } 193 }
194 } 194 }
195 195
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 DownmixToMono<int16_t, int32_t>(split_channels_const(kBand0To8kHz), 321 DownmixToMono<int16_t, int32_t>(split_channels_const(kBand0To8kHz),
322 num_split_frames_, num_channels_, 322 num_split_frames_, num_channels_,
323 mixed_low_pass_channels_->channels()[0]); 323 mixed_low_pass_channels_->channels()[0]);
324 mixed_low_pass_valid_ = true; 324 mixed_low_pass_valid_ = true;
325 } 325 }
326 return mixed_low_pass_channels_->channels()[0]; 326 return mixed_low_pass_channels_->channels()[0];
327 } 327 }
328 328
329 const int16_t* AudioBuffer::low_pass_reference(int channel) const { 329 const int16_t* AudioBuffer::low_pass_reference(int channel) const {
330 if (!reference_copied_) { 330 if (!reference_copied_) {
331 return NULL; 331 return nullptr;
332 } 332 }
333 333
334 return low_pass_reference_channels_->channels()[channel]; 334 return low_pass_reference_channels_->channels()[channel];
335 } 335 }
336 336
337 const float* AudioBuffer::keyboard_data() const { 337 const float* AudioBuffer::keyboard_data() const {
338 return keyboard_data_; 338 return keyboard_data_;
339 } 339 }
340 340
341 void AudioBuffer::set_activity(AudioFrame::VADActivity activity) { 341 void AudioBuffer::set_activity(AudioFrame::VADActivity activity) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 467
468 void AudioBuffer::SplitIntoFrequencyBands() { 468 void AudioBuffer::SplitIntoFrequencyBands() {
469 splitting_filter_->Analysis(data_.get(), split_data_.get()); 469 splitting_filter_->Analysis(data_.get(), split_data_.get());
470 } 470 }
471 471
472 void AudioBuffer::MergeFrequencyBands() { 472 void AudioBuffer::MergeFrequencyBands() {
473 splitting_filter_->Synthesis(split_data_.get(), data_.get()); 473 splitting_filter_->Synthesis(split_data_.get(), data_.get());
474 } 474 }
475 475
476 } // namespace webrtc 476 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698