| 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..f99b3f200f4ff4fe0c81f28421ec26bc7db1d612 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);
|
| @@ -63,24 +62,26 @@ int Normal::Process(const int16_t* input,
|
| expand_->Process(&expanded);
|
| expand_->Reset();
|
|
|
| + size_t length_per_channel = length / output->Channels();
|
| + std::unique_ptr<int16_t[]> signal(new int16_t[length_per_channel]);
|
| for (size_t channel_ix = 0; channel_ix < output->Channels(); ++channel_ix) {
|
| // Adjust muting factor (main muting factor times expand muting factor).
|
| external_mute_factor_array[channel_ix] = static_cast<int16_t>(
|
| (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();
|
| + (*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 +160,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 +170,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) {
|
|
|