NetEq: Fix bug in PLC for multi-channel audio
There is currently a bug in NetEq that causes audio to leak from the
first channel to all others during loss concealment. This CL fixes the
problem and also adds a unit test to verify.
Bug: webrtc:11145
Change-Id: Ia6c4a234ff7f78e9a6080f1cb17eb80af671c3dc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161091
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29974}
diff --git a/modules/audio_coding/neteq/expand.cc b/modules/audio_coding/neteq/expand.cc
index bf9cfbf..8df2c7a 100644
--- a/modules/audio_coding/neteq/expand.cc
+++ b/modules/audio_coding/neteq/expand.cc
@@ -469,6 +469,14 @@
for (size_t channel_ix = 0; channel_ix < num_channels_; ++channel_ix) {
ChannelParameters& parameters = channel_parameters_[channel_ix];
+ if (channel_ix > 0) {
+ // When channel_ix == 0, audio_history contains the correct audio. For the
+ // other cases, we will have to copy the correct channel into
+ // audio_history.
+ (*sync_buffer_)[channel_ix].CopyTo(signal_length, audio_history_position,
+ audio_history.get());
+ }
+
// Calculate suitable scaling.
int16_t signal_max = WebRtcSpl_MaxAbsValueW16(
&audio_history[signal_length - correlation_length - start_index -