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

Side by Side Diff: webrtc/modules/audio_processing/aec/echo_cancellation.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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 size_t num_bands, 117 size_t num_bands,
118 float* const* out, 118 float* const* out,
119 size_t num_samples, 119 size_t num_samples,
120 int16_t reported_delay_ms, 120 int16_t reported_delay_ms,
121 int32_t skew); 121 int32_t skew);
122 122
123 void* WebRtcAec_Create() { 123 void* WebRtcAec_Create() {
124 Aec* aecpc = new Aec(); 124 Aec* aecpc = new Aec();
125 125
126 if (!aecpc) { 126 if (!aecpc) {
127 return NULL; 127 return nullptr;
128 } 128 }
129 aecpc->data_dumper.reset(new ApmDataDumper(aecpc->instance_count)); 129 aecpc->data_dumper.reset(new ApmDataDumper(aecpc->instance_count));
130 130
131 aecpc->aec = WebRtcAec_CreateAec(aecpc->instance_count); 131 aecpc->aec = WebRtcAec_CreateAec(aecpc->instance_count);
132 if (!aecpc->aec) { 132 if (!aecpc->aec) {
133 WebRtcAec_Free(aecpc); 133 WebRtcAec_Free(aecpc);
134 return NULL; 134 return nullptr;
135 } 135 }
136 aecpc->resampler = WebRtcAec_CreateResampler(); 136 aecpc->resampler = WebRtcAec_CreateResampler();
137 if (!aecpc->resampler) { 137 if (!aecpc->resampler) {
138 WebRtcAec_Free(aecpc); 138 WebRtcAec_Free(aecpc);
139 return NULL; 139 return nullptr;
140 } 140 }
141 // Create far-end pre-buffer. The buffer size has to be large enough for 141 // Create far-end pre-buffer. The buffer size has to be large enough for
142 // largest possible drift compensation (kResamplerBufferSize) + "almost" an 142 // largest possible drift compensation (kResamplerBufferSize) + "almost" an
143 // FFT buffer (PART_LEN2 - 1). 143 // FFT buffer (PART_LEN2 - 1).
144 aecpc->far_pre_buf = 144 aecpc->far_pre_buf =
145 WebRtc_CreateBuffer(PART_LEN2 + kResamplerBufferSize, sizeof(float)); 145 WebRtc_CreateBuffer(PART_LEN2 + kResamplerBufferSize, sizeof(float));
146 if (!aecpc->far_pre_buf) { 146 if (!aecpc->far_pre_buf) {
147 WebRtcAec_Free(aecpc); 147 WebRtcAec_Free(aecpc);
148 return NULL; 148 return nullptr;
149 } 149 }
150 150
151 aecpc->initFlag = 0; 151 aecpc->initFlag = 0;
152 152
153 aecpc->instance_count++; 153 aecpc->instance_count++;
154 return aecpc; 154 return aecpc;
155 } 155 }
156 156
157 void WebRtcAec_Free(void* aecInst) { 157 void WebRtcAec_Free(void* aecInst) {
158 Aec* aecpc = reinterpret_cast<Aec*>(aecInst); 158 Aec* aecpc = reinterpret_cast<Aec*>(aecInst);
159 159
160 if (aecpc == NULL) { 160 if (aecpc == nullptr) {
161 return; 161 return;
162 } 162 }
163 163
164 WebRtc_FreeBuffer(aecpc->far_pre_buf); 164 WebRtc_FreeBuffer(aecpc->far_pre_buf);
165 165
166 WebRtcAec_FreeAec(aecpc->aec); 166 WebRtcAec_FreeAec(aecpc->aec);
167 WebRtcAec_FreeResampler(aecpc->resampler); 167 WebRtcAec_FreeResampler(aecpc->resampler);
168 delete aecpc; 168 delete aecpc;
169 } 169 }
170 170
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 WebRtcAec_SetSystemDelay(aecpc->aec, WebRtcAec_system_delay(aecpc->aec) + 293 WebRtcAec_SetSystemDelay(aecpc->aec, WebRtcAec_system_delay(aecpc->aec) +
294 static_cast<int>(newNrOfSamples)); 294 static_cast<int>(newNrOfSamples));
295 295
296 // Write the time-domain data to |far_pre_buf|. 296 // Write the time-domain data to |far_pre_buf|.
297 WebRtc_WriteBuffer(aecpc->far_pre_buf, farend_ptr, newNrOfSamples); 297 WebRtc_WriteBuffer(aecpc->far_pre_buf, farend_ptr, newNrOfSamples);
298 298
299 // TODO(minyue): reduce to |PART_LEN| samples for each buffering. 299 // TODO(minyue): reduce to |PART_LEN| samples for each buffering.
300 while (WebRtc_available_read(aecpc->far_pre_buf) >= PART_LEN2) { 300 while (WebRtc_available_read(aecpc->far_pre_buf) >= PART_LEN2) {
301 // We have enough data to pass to the FFT, hence read PART_LEN2 samples. 301 // We have enough data to pass to the FFT, hence read PART_LEN2 samples.
302 { 302 {
303 float* ptmp = NULL; 303 float* ptmp = nullptr;
304 float tmp[PART_LEN2]; 304 float tmp[PART_LEN2];
305 WebRtc_ReadBuffer(aecpc->far_pre_buf, 305 WebRtc_ReadBuffer(aecpc->far_pre_buf,
306 reinterpret_cast<void**>(&ptmp), tmp, PART_LEN2); 306 reinterpret_cast<void**>(&ptmp), tmp, PART_LEN2);
307 WebRtcAec_BufferFarendBlock(aecpc->aec, &ptmp[PART_LEN]); 307 WebRtcAec_BufferFarendBlock(aecpc->aec, &ptmp[PART_LEN]);
308 } 308 }
309 309
310 // Rewind |far_pre_buf| PART_LEN samples for overlap before continuing. 310 // Rewind |far_pre_buf| PART_LEN samples for overlap before continuing.
311 WebRtc_MoveReadPtr(aecpc->far_pre_buf, -PART_LEN); 311 WebRtc_MoveReadPtr(aecpc->far_pre_buf, -PART_LEN);
312 } 312 }
313 313
314 return 0; 314 return 0;
315 } 315 }
316 316
317 int32_t WebRtcAec_Process(void* aecInst, 317 int32_t WebRtcAec_Process(void* aecInst,
318 const float* const* nearend, 318 const float* const* nearend,
319 size_t num_bands, 319 size_t num_bands,
320 float* const* out, 320 float* const* out,
321 size_t nrOfSamples, 321 size_t nrOfSamples,
322 int16_t msInSndCardBuf, 322 int16_t msInSndCardBuf,
323 int32_t skew) { 323 int32_t skew) {
324 Aec* aecpc = reinterpret_cast<Aec*>(aecInst); 324 Aec* aecpc = reinterpret_cast<Aec*>(aecInst);
325 int32_t retVal = 0; 325 int32_t retVal = 0;
326 326
327 if (out == NULL) { 327 if (out == nullptr) {
328 return AEC_NULL_POINTER_ERROR; 328 return AEC_NULL_POINTER_ERROR;
329 } 329 }
330 330
331 if (aecpc->initFlag != initCheck) { 331 if (aecpc->initFlag != initCheck) {
332 return AEC_UNINITIALIZED_ERROR; 332 return AEC_UNINITIALIZED_ERROR;
333 } 333 }
334 334
335 // number of samples == 160 for SWB input 335 // number of samples == 160 for SWB input
336 if (nrOfSamples != 80 && nrOfSamples != 160) { 336 if (nrOfSamples != 80 && nrOfSamples != 160) {
337 return AEC_BAD_PARAMETER_ERROR; 337 return AEC_BAD_PARAMETER_ERROR;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 return AEC_BAD_PARAMETER_ERROR; 386 return AEC_BAD_PARAMETER_ERROR;
387 } 387 }
388 388
389 WebRtcAec_SetConfigCore(self->aec, config.nlpMode, config.metricsMode, 389 WebRtcAec_SetConfigCore(self->aec, config.nlpMode, config.metricsMode,
390 config.delay_logging); 390 config.delay_logging);
391 return 0; 391 return 0;
392 } 392 }
393 393
394 int WebRtcAec_get_echo_status(void* handle, int* status) { 394 int WebRtcAec_get_echo_status(void* handle, int* status) {
395 Aec* self = reinterpret_cast<Aec*>(handle); 395 Aec* self = reinterpret_cast<Aec*>(handle);
396 if (status == NULL) { 396 if (status == nullptr) {
397 return AEC_NULL_POINTER_ERROR; 397 return AEC_NULL_POINTER_ERROR;
398 } 398 }
399 if (self->initFlag != initCheck) { 399 if (self->initFlag != initCheck) {
400 return AEC_UNINITIALIZED_ERROR; 400 return AEC_UNINITIALIZED_ERROR;
401 } 401 }
402 402
403 *status = WebRtcAec_echo_state(self->aec); 403 *status = WebRtcAec_echo_state(self->aec);
404 404
405 return 0; 405 return 0;
406 } 406 }
407 407
408 int WebRtcAec_GetMetrics(void* handle, AecMetrics* metrics) { 408 int WebRtcAec_GetMetrics(void* handle, AecMetrics* metrics) {
409 const float kUpWeight = 0.7f; 409 const float kUpWeight = 0.7f;
410 float dtmp; 410 float dtmp;
411 int stmp; 411 int stmp;
412 Aec* self = reinterpret_cast<Aec*>(handle); 412 Aec* self = reinterpret_cast<Aec*>(handle);
413 Stats erl; 413 Stats erl;
414 Stats erle; 414 Stats erle;
415 Stats a_nlp; 415 Stats a_nlp;
416 416
417 if (handle == NULL) { 417 if (handle == nullptr) {
418 return -1; 418 return -1;
419 } 419 }
420 if (metrics == NULL) { 420 if (metrics == nullptr) {
421 return AEC_NULL_POINTER_ERROR; 421 return AEC_NULL_POINTER_ERROR;
422 } 422 }
423 if (self->initFlag != initCheck) { 423 if (self->initFlag != initCheck) {
424 return AEC_UNINITIALIZED_ERROR; 424 return AEC_UNINITIALIZED_ERROR;
425 } 425 }
426 426
427 WebRtcAec_GetEchoStats(self->aec, &erl, &erle, &a_nlp, 427 WebRtcAec_GetEchoStats(self->aec, &erl, &erle, &a_nlp,
428 &metrics->divergent_filter_fraction); 428 &metrics->divergent_filter_fraction);
429 429
430 // ERL 430 // ERL
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 499 }
500 500
501 return 0; 501 return 0;
502 } 502 }
503 503
504 int WebRtcAec_GetDelayMetrics(void* handle, 504 int WebRtcAec_GetDelayMetrics(void* handle,
505 int* median, 505 int* median,
506 int* std, 506 int* std,
507 float* fraction_poor_delays) { 507 float* fraction_poor_delays) {
508 Aec* self = reinterpret_cast<Aec*>(handle); 508 Aec* self = reinterpret_cast<Aec*>(handle);
509 if (median == NULL) { 509 if (median == nullptr) {
510 return AEC_NULL_POINTER_ERROR; 510 return AEC_NULL_POINTER_ERROR;
511 } 511 }
512 if (std == NULL) { 512 if (std == nullptr) {
513 return AEC_NULL_POINTER_ERROR; 513 return AEC_NULL_POINTER_ERROR;
514 } 514 }
515 if (self->initFlag != initCheck) { 515 if (self->initFlag != initCheck) {
516 return AEC_UNINITIALIZED_ERROR; 516 return AEC_UNINITIALIZED_ERROR;
517 } 517 }
518 if (WebRtcAec_GetDelayMetricsCore(self->aec, median, std, 518 if (WebRtcAec_GetDelayMetricsCore(self->aec, median, std,
519 fraction_poor_delays) == -1) { 519 fraction_poor_delays) == -1) {
520 // Logging disabled. 520 // Logging disabled.
521 return AEC_UNSUPPORTED_FUNCTION_ERROR; 521 return AEC_UNSUPPORTED_FUNCTION_ERROR;
522 } 522 }
523 523
524 return 0; 524 return 0;
525 } 525 }
526 526
527 AecCore* WebRtcAec_aec_core(void* handle) { 527 AecCore* WebRtcAec_aec_core(void* handle) {
528 if (!handle) { 528 if (!handle) {
529 return NULL; 529 return nullptr;
530 } 530 }
531 return reinterpret_cast<Aec*>(handle)->aec; 531 return reinterpret_cast<Aec*>(handle)->aec;
532 } 532 }
533 533
534 static int ProcessNormal(Aec* aecpc, 534 static int ProcessNormal(Aec* aecpc,
535 const float* const* nearend, 535 const float* const* nearend,
536 size_t num_bands, 536 size_t num_bands,
537 float* const* out, 537 float* const* out,
538 size_t nrOfSamples, 538 size_t nrOfSamples,
539 int16_t msInSndCardBuf, 539 int16_t msInSndCardBuf,
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 } else { 854 } else {
855 self->timeForDelayChange = 0; 855 self->timeForDelayChange = 0;
856 } 856 }
857 self->lastDelayDiff = delay_difference; 857 self->lastDelayDiff = delay_difference;
858 858
859 if (self->timeForDelayChange > 25) { 859 if (self->timeForDelayChange > 25) {
860 self->knownDelay = WEBRTC_SPL_MAX((int)self->filtDelay - 256, 0); 860 self->knownDelay = WEBRTC_SPL_MAX((int)self->filtDelay - 256, 0);
861 } 861 }
862 } 862 }
863 } // namespace webrtc 863 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698