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

Side by Side Diff: webrtc/modules/audio_processing/transient/transient_suppressor.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: google::int32 Created 5 years, 3 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // Attenuates by a certain factor every peak in the |fft_buffer_| that exceeds 366 // Attenuates by a certain factor every peak in the |fft_buffer_| that exceeds
367 // the spectral mean. The attenuation depends on |detector_smoothed_|. 367 // the spectral mean. The attenuation depends on |detector_smoothed_|.
368 // If a restoration takes place, the |magnitudes_| are updated to the new value. 368 // If a restoration takes place, the |magnitudes_| are updated to the new value.
369 void TransientSuppressor::HardRestoration(float* spectral_mean) { 369 void TransientSuppressor::HardRestoration(float* spectral_mean) {
370 const float detector_result = 370 const float detector_result =
371 1.f - pow(1.f - detector_smoothed_, using_reference_ ? 200.f : 50.f); 371 1.f - pow(1.f - detector_smoothed_, using_reference_ ? 200.f : 50.f);
372 // To restore, we get the peaks in the spectrum. If higher than the previous 372 // To restore, we get the peaks in the spectrum. If higher than the previous
373 // spectral mean we adjust them. 373 // spectral mean we adjust them.
374 for (size_t i = 0; i < complex_analysis_length_; ++i) { 374 for (size_t i = 0; i < complex_analysis_length_; ++i) {
375 if (magnitudes_[i] > spectral_mean[i] && magnitudes_[i] > 0) { 375 if (magnitudes_[i] > spectral_mean[i] && magnitudes_[i] > 0) {
376 // RandU() generates values on [0, int16::max()] 376 // RandU() generates values on [0, int16_t::max()]
377 const float phase = 2 * ts::kPi * WebRtcSpl_RandU(&seed_) / 377 const float phase = 2 * ts::kPi * WebRtcSpl_RandU(&seed_) /
378 std::numeric_limits<int16_t>::max(); 378 std::numeric_limits<int16_t>::max();
379 const float scaled_mean = detector_result * spectral_mean[i]; 379 const float scaled_mean = detector_result * spectral_mean[i];
380 380
381 fft_buffer_[i * 2] = (1 - detector_result) * fft_buffer_[i * 2] + 381 fft_buffer_[i * 2] = (1 - detector_result) * fft_buffer_[i * 2] +
382 scaled_mean * cosf(phase); 382 scaled_mean * cosf(phase);
383 fft_buffer_[i * 2 + 1] = (1 - detector_result) * fft_buffer_[i * 2 + 1] + 383 fft_buffer_[i * 2 + 1] = (1 - detector_result) * fft_buffer_[i * 2 + 1] +
384 scaled_mean * sinf(phase); 384 scaled_mean * sinf(phase);
385 magnitudes_[i] = magnitudes_[i] - 385 magnitudes_[i] = magnitudes_[i] -
386 detector_result * (magnitudes_[i] - spectral_mean[i]); 386 detector_result * (magnitudes_[i] - spectral_mean[i]);
(...skipping 28 matching lines...) Expand all
415 const float magnitude_ratio = new_magnitude / magnitudes_[i]; 415 const float magnitude_ratio = new_magnitude / magnitudes_[i];
416 416
417 fft_buffer_[i * 2] *= magnitude_ratio; 417 fft_buffer_[i * 2] *= magnitude_ratio;
418 fft_buffer_[i * 2 + 1] *= magnitude_ratio; 418 fft_buffer_[i * 2 + 1] *= magnitude_ratio;
419 magnitudes_[i] = new_magnitude; 419 magnitudes_[i] = new_magnitude;
420 } 420 }
421 } 421 }
422 } 422 }
423 423
424 } // namespace webrtc 424 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698