Index: webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc |
diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc |
index 9b550cbb2bf015ae58510fe59e52488cb2068f7d..b2c3eef9f083109a2fe08a6d11b4734224f25d87 100644 |
--- a/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc |
+++ b/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc |
@@ -85,13 +85,18 @@ void NetEqReplacementInput::ReplacePacket() { |
rtc::Optional<RTPHeader> next_hdr = source_->NextHeader(); |
RTC_DCHECK(next_hdr); |
uint8_t payload[12]; |
+ RTC_DCHECK_LE(last_frame_size_timestamps_, 120 * 48); |
uint32_t input_frame_size_timestamps = last_frame_size_timestamps_; |
- if (next_hdr->sequenceNumber == packet_->header.sequenceNumber + 1) { |
- // Packets are in order. |
- input_frame_size_timestamps = |
- next_hdr->timestamp - packet_->header.timestamp; |
+ const uint32_t timestamp_diff = |
+ next_hdr->timestamp - packet_->header.timestamp; |
+ if (next_hdr->sequenceNumber == packet_->header.sequenceNumber + 1 && |
+ timestamp_diff <= 120 * 48) { |
+ // Packets are in order and the timestamp diff is less than 5760 samples. |
+ // Accept the timestamp diff as a valid frame size. |
+ input_frame_size_timestamps = timestamp_diff; |
last_frame_size_timestamps_ = input_frame_size_timestamps; |
} |
+ RTC_DCHECK_LE(input_frame_size_timestamps, 120 * 48); |
FakeDecodeFromFile::PrepareEncoded(packet_->header.timestamp, |
input_frame_size_timestamps, |
packet_->payload.size(), payload); |