From 048b10a9ec00bef34537d253b8eeee7d69782713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85hgren?= Date: Wed, 13 Nov 2019 15:44:57 +0100 Subject: [PATCH] Correcting the ACM upmixing from mono/stereo to surround MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL corrects the upmixing from mono/stereo to surround in the audio coding module. Bug: webrtc:11083 Change-Id: Ic529107d59ff54a8e48b0424cbdf2b49b7a65c12 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/159705 Commit-Queue: Per Ã…hgren Reviewed-by: Sam Zackrisson Reviewed-by: Henrik Lundin Cr-Commit-Position: refs/heads/master@{#29792} --- modules/audio_coding/acm2/audio_coding_module.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc index 314afd7dcd..0232f2722d 100644 --- a/modules/audio_coding/acm2/audio_coding_module.cc +++ b/modules/audio_coding/acm2/audio_coding_module.cc @@ -246,18 +246,22 @@ void ReMix(const AudioFrame& input, size_t in_index = 0; size_t out_index = 0; - // When upmixing is needed, duplicate the last channel of the input. + // When upmixing is needed, copy the available channels directly, and set the + // remaining channels to zero. if (input.num_channels_ < num_output_channels) { for (size_t k = 0; k < input.samples_per_channel_; ++k) { for (size_t j = 0; j < input.num_channels_; ++j) { (*output)[out_index++] = input_data[in_index++]; } - RTC_DCHECK_GT(in_index, 0); - const int16_t value_last_channel = input_data[in_index - 1]; for (size_t j = input.num_channels_; j < num_output_channels; ++j) { - (*output)[out_index++] = value_last_channel; + (*output)[out_index++] = 0; } + RTC_DCHECK_EQ(in_index, (k + 1) * input.num_channels_); + RTC_DCHECK_EQ(out_index, (k + 1) * num_output_channels); } + RTC_DCHECK_EQ(in_index, input.samples_per_channel_ * input.num_channels_); + RTC_DCHECK_EQ(out_index, input.samples_per_channel_ * num_output_channels); + return; }