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

Side by Side Diff: webrtc/modules/audio_coding/neteq/dsp_helper.cc

Issue 1948483002: Using ring buffer for AudioVector in NetEq. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: refinements Created 4 years, 7 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return factor; 73 return factor;
74 } 74 }
75 75
76 int DspHelper::RampSignal(int16_t* signal, 76 int DspHelper::RampSignal(int16_t* signal,
77 size_t length, 77 size_t length,
78 int factor, 78 int factor,
79 int increment) { 79 int increment) {
80 return RampSignal(signal, length, factor, increment, signal); 80 return RampSignal(signal, length, factor, increment, signal);
81 } 81 }
82 82
83 int DspHelper::RampSignal(AudioVector* signal,
84 size_t start_index,
85 size_t length,
86 int factor,
87 int increment) {
88 int factor_q20 = (factor << 6) + 32;
89 // TODO(hlundin): Add 32 to factor_q20 when converting back to Q14?
90 for (size_t i = start_index; i < start_index + length; ++i) {
91 (*signal)[i] = (factor * (*signal)[i] + 8192) >> 14;
92 factor_q20 += increment;
93 factor_q20 = std::max(factor_q20, 0); // Never go negative.
94 factor = std::min(factor_q20 >> 6, 16384);
95 }
96 return factor;
97 }
98
83 int DspHelper::RampSignal(AudioMultiVector* signal, 99 int DspHelper::RampSignal(AudioMultiVector* signal,
84 size_t start_index, 100 size_t start_index,
85 size_t length, 101 size_t length,
86 int factor, 102 int factor,
87 int increment) { 103 int increment) {
88 assert(start_index + length <= signal->Size()); 104 assert(start_index + length <= signal->Size());
89 if (start_index + length > signal->Size()) { 105 if (start_index + length > signal->Size()) {
90 // Wrong parameters. Do nothing and return the scale factor unaltered. 106 // Wrong parameters. Do nothing and return the scale factor unaltered.
91 return factor; 107 return factor;
92 } 108 }
93 int end_factor = 0; 109 int end_factor = 0;
94 // Loop over the channels, starting at the same |factor| each time. 110 // Loop over the channels, starting at the same |factor| each time.
95 for (size_t channel = 0; channel < signal->Channels(); ++channel) { 111 for (size_t channel = 0; channel < signal->Channels(); ++channel) {
96 end_factor = 112 end_factor =
97 RampSignal(&(*signal)[channel][start_index], length, factor, increment); 113 RampSignal(&(*signal)[channel], start_index, length, factor, increment);
98 } 114 }
99 return end_factor; 115 return end_factor;
100 } 116 }
101 117
102 void DspHelper::PeakDetection(int16_t* data, size_t data_length, 118 void DspHelper::PeakDetection(int16_t* data, size_t data_length,
103 size_t num_peaks, int fs_mult, 119 size_t num_peaks, int fs_mult,
104 size_t* peak_index, int16_t* peak_value) { 120 size_t* peak_index, int16_t* peak_value) {
105 size_t min_index = 0; 121 size_t min_index = 0;
106 size_t max_index = 0; 122 size_t max_index = 0;
107 123
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 filter_delay = 0; 359 filter_delay = 0;
344 } 360 }
345 361
346 // Returns -1 if input signal is too short; 0 otherwise. 362 // Returns -1 if input signal is too short; 0 otherwise.
347 return WebRtcSpl_DownsampleFast( 363 return WebRtcSpl_DownsampleFast(
348 &input[filter_length - 1], input_length - filter_length + 1, output, 364 &input[filter_length - 1], input_length - filter_length + 1, output,
349 output_length, filter_coefficients, filter_length, factor, filter_delay); 365 output_length, filter_coefficients, filter_length, factor, filter_delay);
350 } 366 }
351 367
352 } // namespace webrtc 368 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698