Check current buffer time span instead of number of samples in postpone decoding after expand.
Bug: webrtc:10392 Change-Id: I2ad4d8c7a3f87cab32e2ea097b2e05aa179e0bc0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126761 Reviewed-by: Minyue Li <minyue@webrtc.org> Reviewed-by: Ivo Creusen <ivoc@webrtc.org> Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27080}
This commit is contained in:
committed by
Commit Bot
parent
075e7fdd00
commit
1b4254ada5
@ -116,6 +116,7 @@ Operations DecisionLogic::GetDecision(const SyncBuffer& sync_buffer,
|
||||
|
||||
const size_t samples_left =
|
||||
sync_buffer.FutureLength() - expand.overlap_length();
|
||||
// TODO(jakobi): Use buffer span instead of num samples.
|
||||
const size_t cur_size_samples =
|
||||
samples_left + packet_buffer_.NumSamplesInBuffer(decoder_frame_length);
|
||||
|
||||
@ -169,11 +170,13 @@ Operations DecisionLogic::GetDecision(const SyncBuffer& sync_buffer,
|
||||
// if the mute factor is low enough (otherwise the expansion was short enough
|
||||
// to not be noticable).
|
||||
// Note that the MuteFactor is in Q14, so a value of 16384 corresponds to 1.
|
||||
size_t current_span =
|
||||
samples_left + packet_buffer_.GetSpanSamples(decoder_frame_length);
|
||||
if ((prev_mode == kModeExpand || prev_mode == kModeCodecPlc) &&
|
||||
expand.MuteFactor(0) < 16384 / 2 &&
|
||||
cur_size_samples < static_cast<size_t>(
|
||||
delay_manager_->TargetLevel() * packet_length_samples_ *
|
||||
kPostponeDecodingLevel / 100) >> 8 &&
|
||||
current_span < static_cast<size_t>(delay_manager_->TargetLevel() *
|
||||
packet_length_samples_ *
|
||||
kPostponeDecodingLevel / 100)>> 8 &&
|
||||
!packet_buffer_.ContainsDtxOrCngPacket(decoder_database_)) {
|
||||
return kExpand;
|
||||
}
|
||||
|
||||
@ -287,6 +287,20 @@ size_t PacketBuffer::NumSamplesInBuffer(size_t last_decoded_length) const {
|
||||
return num_samples;
|
||||
}
|
||||
|
||||
size_t PacketBuffer::GetSpanSamples(size_t last_decoded_length) const {
|
||||
if (buffer_.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t span = buffer_.back().timestamp - buffer_.front().timestamp;
|
||||
if (buffer_.back().frame && buffer_.back().frame->Duration() > 0) {
|
||||
span += buffer_.back().frame->Duration();
|
||||
} else {
|
||||
span += last_decoded_length;
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
bool PacketBuffer::ContainsDtxOrCngPacket(
|
||||
const DecoderDatabase* decoder_database) const {
|
||||
RTC_DCHECK(decoder_database);
|
||||
|
||||
@ -121,6 +121,10 @@ class PacketBuffer {
|
||||
// duplicate and redundant packets.
|
||||
virtual size_t NumSamplesInBuffer(size_t last_decoded_length) const;
|
||||
|
||||
// Returns the total duration in samples that the packets in the buffer spans
|
||||
// across.
|
||||
virtual size_t GetSpanSamples(size_t last_decoded_length) const;
|
||||
|
||||
// Returns true if the packet buffer contains any DTX or CNG packets.
|
||||
virtual bool ContainsDtxOrCngPacket(
|
||||
const DecoderDatabase* decoder_database) const;
|
||||
|
||||
Reference in New Issue
Block a user