Audio coding: Don't choke when RTP timestamp rate > sample rate

Bug: webrtc:10631
Change-Id: If0422786172502f039acc2cac5e8c13b637af54c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137048
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27998}
This commit is contained in:
Karl Wiberg
2019-05-16 15:24:17 +02:00
committed by Commit Bot
parent d9f02f64e8
commit 053c371552

View File

@ -328,13 +328,13 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
// Scale the timestamp to the codec's RTP timestamp rate.
uint32_t rtp_timestamp =
first_frame_ ? input_data.input_timestamp
: last_rtp_timestamp_ +
rtc::CheckedDivExact(
input_data.input_timestamp - last_timestamp_,
static_cast<uint32_t>(rtc::CheckedDivExact(
encoder_stack_->SampleRateHz(),
encoder_stack_->RtpTimestampRateHz())));
first_frame_
? input_data.input_timestamp
: last_rtp_timestamp_ +
rtc::dchecked_cast<uint32_t>(rtc::CheckedDivExact(
int64_t{input_data.input_timestamp - last_timestamp_} *
encoder_stack_->RtpTimestampRateHz(),
int64_t{encoder_stack_->SampleRateHz()}));
last_timestamp_ = input_data.input_timestamp;
last_rtp_timestamp_ = rtp_timestamp;
first_frame_ = false;