Improve NetEq simulation frame size estimation.
This fixes an edge case where the frame size changes for a DTX packet. We should avoid having the frame size larger than the timestamp gap. Bug: None Change-Id: I0a384cfb06f5aebc1654c1e3d127541fd24e05c7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/360722 Reviewed-by: Tomas Lundqvist <tomasl@google.com> Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42873}
This commit is contained in:
parent
b6046aece2
commit
32dd2ed745
@ -101,21 +101,23 @@ void NetEqReplacementInput::ReplacePacket() {
|
||||
absl::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_;
|
||||
constexpr uint32_t kMaxFrameSize = 120 * 48;
|
||||
const uint32_t timestamp_diff =
|
||||
next_hdr->timestamp - packet_->header.timestamp;
|
||||
uint32_t frame_size = last_frame_size_timestamps_;
|
||||
if (timestamp_diff > 0) {
|
||||
frame_size = std::min(frame_size, timestamp_diff);
|
||||
}
|
||||
const bool opus_dtx = packet_->payload.size() <= 2;
|
||||
if (next_hdr->sequenceNumber == packet_->header.sequenceNumber + 1 &&
|
||||
timestamp_diff <= 120 * 48 && timestamp_diff > 0 && !opus_dtx) {
|
||||
// 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;
|
||||
timestamp_diff <= kMaxFrameSize && timestamp_diff > 0 && !opus_dtx) {
|
||||
// Packets are in order and the timestamp diff is valid.
|
||||
frame_size = timestamp_diff;
|
||||
last_frame_size_timestamps_ = frame_size;
|
||||
}
|
||||
RTC_DCHECK_LE(input_frame_size_timestamps, 120 * 48);
|
||||
FakeDecodeFromFile::PrepareEncoded(packet_->header.timestamp,
|
||||
input_frame_size_timestamps,
|
||||
RTC_DCHECK_LE(frame_size, kMaxFrameSize);
|
||||
RTC_DCHECK_GT(frame_size, 0);
|
||||
FakeDecodeFromFile::PrepareEncoded(packet_->header.timestamp, frame_size,
|
||||
packet_->payload.size(), payload);
|
||||
packet_->payload.SetData(payload);
|
||||
packet_->header.payloadType = replacement_payload_type_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user