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

Unified Diff: webrtc/modules/audio_coding/neteq/normal.cc

Issue 1948483002: Using ring buffer for AudioVector in NetEq. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/neteq/normal.cc
diff --git a/webrtc/modules/audio_coding/neteq/normal.cc b/webrtc/modules/audio_coding/neteq/normal.cc
index 4400afb3b01517f8b43441e762fc48c1522d9d16..72990b3c9d6add9711fd89573000a21926788c8a 100644
--- a/webrtc/modules/audio_coding/neteq/normal.cc
+++ b/webrtc/modules/audio_coding/neteq/normal.cc
@@ -42,7 +42,6 @@ int Normal::Process(const int16_t* input,
return 0;
}
output->PushBackInterleaved(input, length);
- int16_t* signal = &(*output)[0][0];
const int fs_mult = fs_hz_ / 8000;
assert(fs_mult > 0);
@@ -69,18 +68,21 @@ int Normal::Process(const int16_t* input,
(external_mute_factor_array[channel_ix] *
expand_->MuteFactor(channel_ix)) >> 14);
- int16_t* signal = &(*output)[channel_ix][0];
size_t length_per_channel = length / output->Channels();
+
+ std::unique_ptr<int16_t[]> signal(new int16_t[length_per_channel]);
minyue-webrtc 2016/05/08 06:13:53 will remove definition out of loop.
+ (*output)[channel_ix].CopyTo(length_per_channel, 0, signal.get());
+
// Find largest absolute value in new data.
int16_t decoded_max =
- WebRtcSpl_MaxAbsValueW16(signal, length_per_channel);
+ WebRtcSpl_MaxAbsValueW16(signal.get(), length_per_channel);
// Adjust muting factor if needed (to BGN level).
size_t energy_length =
std::min(static_cast<size_t>(fs_mult * 64), length_per_channel);
int scaling = 6 + fs_shift
- WebRtcSpl_NormW32(decoded_max * decoded_max);
scaling = std::max(scaling, 0); // |scaling| should always be >= 0.
- int32_t energy = WebRtcSpl_DotProductWithScale(signal, signal,
+ int32_t energy = WebRtcSpl_DotProductWithScale(signal.get(), signal.get(),
energy_length, scaling);
int32_t scaled_energy_length =
static_cast<int32_t>(energy_length >> scaling);
@@ -159,7 +161,7 @@ int Normal::Process(const int16_t* input,
} else {
// If no CNG instance is defined, just copy from the decoded data.
// (This will result in interpolating the decoded with itself.)
- memcpy(cng_output, signal, fs_mult * 8 * sizeof(int16_t));
+ (*output)[0].CopyTo(fs_mult * 8, 0, cng_output);
}
// Interpolate the CNG into the new vector.
// (NB/WB/SWB32/SWB48 8/16/32/48 samples.)
@@ -169,8 +171,8 @@ int Normal::Process(const int16_t* input,
for (size_t i = 0; i < static_cast<size_t>(8 * fs_mult); i++) {
// TODO(hlundin): Add 16 instead of 8 for correct rounding. Keeping 8 now
// for legacy bit-exactness.
- signal[i] =
- (fraction * signal[i] + (32 - fraction) * cng_output[i] + 8) >> 5;
+ (*output)[0][i] = (fraction * (*output)[0][i] +
+ (32 - fraction) * cng_output[i] + 8) >> 5;
fraction += increment;
}
} else if (external_mute_factor_array[0] < 16384) {
« webrtc/modules/audio_coding/neteq/merge.cc ('K') | « webrtc/modules/audio_coding/neteq/merge.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698