Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Unified Diff: webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc

Issue 2838353002: NetEq: Limit payload size for replacement audio input (Closed)
Patch Set: One more DCHECK Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698