Bugfix for histogram scaling function in NetEq's DelayManager.
If the previous value of the histogram is unknown, no scaling should be performed. Without this check a crash would occur. This issue was introduced in https://webrtc-review.googlesource.com/c/src/+/8101, and can only be triggered if the corresponding field trial is set.
Bug: webrtc:8381
Change-Id: I6e7cd8e14f6f4cc972fc094f010ecdf5091b2017
Reviewed-on: https://webrtc-review.googlesource.com/12380
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20336}
diff --git a/modules/audio_coding/neteq/delay_manager.cc b/modules/audio_coding/neteq/delay_manager.cc
index 77a41fd..44acf81 100644
--- a/modules/audio_coding/neteq/delay_manager.cc
+++ b/modules/audio_coding/neteq/delay_manager.cc
@@ -389,6 +389,11 @@
DelayManager::IATVector DelayManager::ScaleHistogram(const IATVector& histogram,
int old_packet_length,
int new_packet_length) {
+ if (old_packet_length == 0) {
+ // If we don't know the previous frame length, don't make any changes to the
+ // histogram.
+ return histogram;
+ }
RTC_DCHECK_GT(new_packet_length, 0);
RTC_DCHECK_EQ(old_packet_length % 10, 0);
RTC_DCHECK_EQ(new_packet_length % 10, 0);