From a9f10c8189c196abbe3d72ba815d3b1b21cb16c6 Mon Sep 17 00:00:00 2001 From: Jakob Ivarsson Date: Mon, 16 May 2022 18:15:53 +0200 Subject: [PATCH] Make fake decode from file produce 10 ms comfort noise frames. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is to more accurately simulate Opus CNG. Bug: None Change-Id: I3244d88e1f7410190551b6fa24cdd08599b5771e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262661 Reviewed-by: Minyue Li Commit-Queue: Jakob Ivarsson‎ Cr-Commit-Position: refs/heads/main@{#36913} --- .../neteq/tools/fake_decode_from_file.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/audio_coding/neteq/tools/fake_decode_from_file.cc b/modules/audio_coding/neteq/tools/fake_decode_from_file.cc index 82f5460b96..6c5e5ac2e4 100644 --- a/modules/audio_coding/neteq/tools/fake_decode_from_file.cc +++ b/modules/audio_coding/neteq/tools/fake_decode_from_file.cc @@ -132,12 +132,15 @@ int FakeDecodeFromFile::PacketDuration(const uint8_t* encoded, encoded_len < 4 + sizeof(uint32_t) ? 0 : ByteReader::ReadLittleEndian(&encoded[4]); - if ( // Decoder is asked to produce codec-internal comfort noise - encoded_len == 0 || - // Comfort noise payload - original_payload_size_bytes <= 2 || samples_to_decode == 0 || - // Erroneous duration since it is not a multiple of 10ms - samples_to_decode % rtc::CheckedDivExact(SampleRateHz(), 100) != 0) { + if (encoded_len == 0) { + // Decoder is asked to produce codec-internal comfort noise. + return rtc::CheckedDivExact(SampleRateHz(), 100); + } + bool is_dtx_payload = + original_payload_size_bytes <= 2 || samples_to_decode == 0; + bool has_error_duration = + samples_to_decode % rtc::CheckedDivExact(SampleRateHz(), 100) != 0; + if (is_dtx_payload || has_error_duration) { if (last_decoded_length_ > 0) { // Use length of last decoded packet. return rtc::dchecked_cast(last_decoded_length_);