Make fake decode from file produce 10 ms comfort noise frames.

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 <minyue@webrtc.org>
Commit-Queue: Jakob Ivarsson‎ <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36913}
This commit is contained in:
Jakob Ivarsson
2022-05-16 18:15:53 +02:00
committed by WebRTC LUCI CQ
parent 4da317f0bb
commit a9f10c8189

View File

@ -132,12 +132,15 @@ int FakeDecodeFromFile::PacketDuration(const uint8_t* encoded,
encoded_len < 4 + sizeof(uint32_t)
? 0
: ByteReader<uint32_t>::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<int>(last_decoded_length_);