Clean up old field trial options in NetEq decision logic.
Bug: webrtc:10736 Change-Id: I6cb30db450a281f922c9ddf5ec85fc08dbcc7ed1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256969 Reviewed-by: Minyue Li <minyue@webrtc.org> Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36373}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
ea4cefa3a7
commit
e6aabd0ef0
@ -56,21 +56,14 @@ DecisionLogic::DecisionLogic(
|
|||||||
disallow_time_stretching_(!config.allow_time_stretching),
|
disallow_time_stretching_(!config.allow_time_stretching),
|
||||||
timescale_countdown_(
|
timescale_countdown_(
|
||||||
tick_timer_->GetNewCountdown(kMinTimescaleInterval + 1)),
|
tick_timer_->GetNewCountdown(kMinTimescaleInterval + 1)),
|
||||||
estimate_dtx_delay_("estimate_dtx_delay", true),
|
|
||||||
time_stretch_cn_("time_stretch_cn", true),
|
|
||||||
target_level_window_ms_("target_level_window",
|
target_level_window_ms_("target_level_window",
|
||||||
kDefaultTargetLevelWindowMs,
|
kDefaultTargetLevelWindowMs,
|
||||||
0,
|
0,
|
||||||
absl::nullopt) {
|
absl::nullopt) {
|
||||||
const std::string field_trial_name =
|
const std::string field_trial_name =
|
||||||
field_trial::FindFullName("WebRTC-Audio-NetEqDecisionLogicSettings");
|
field_trial::FindFullName("WebRTC-Audio-NetEqDecisionLogicSettings");
|
||||||
ParseFieldTrial(
|
ParseFieldTrial({&target_level_window_ms_}, field_trial_name);
|
||||||
{&estimate_dtx_delay_, &time_stretch_cn_, &target_level_window_ms_},
|
|
||||||
field_trial_name);
|
|
||||||
RTC_LOG(LS_INFO) << "NetEq decision logic settings:"
|
RTC_LOG(LS_INFO) << "NetEq decision logic settings:"
|
||||||
" estimate_dtx_delay="
|
|
||||||
<< estimate_dtx_delay_
|
|
||||||
<< " time_stretch_cn=" << time_stretch_cn_
|
|
||||||
<< " target_level_window_ms=" << target_level_window_ms_;
|
<< " target_level_window_ms=" << target_level_window_ms_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,9 +112,6 @@ NetEq::Operation DecisionLogic::GetDecision(const NetEqStatus& status,
|
|||||||
cng_state_ = kCngInternalOn;
|
cng_state_ = kCngInternalOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t cur_size_samples = estimate_dtx_delay_
|
|
||||||
? status.packet_buffer_info.span_samples
|
|
||||||
: status.packet_buffer_info.num_samples;
|
|
||||||
prev_time_scale_ =
|
prev_time_scale_ =
|
||||||
prev_time_scale_ &&
|
prev_time_scale_ &&
|
||||||
(status.last_mode == NetEq::Mode::kAccelerateSuccess ||
|
(status.last_mode == NetEq::Mode::kAccelerateSuccess ||
|
||||||
@ -132,10 +122,8 @@ NetEq::Operation DecisionLogic::GetDecision(const NetEqStatus& status,
|
|||||||
// Do not update buffer history if currently playing CNG since it will bias
|
// Do not update buffer history if currently playing CNG since it will bias
|
||||||
// the filtered buffer level.
|
// the filtered buffer level.
|
||||||
if (status.last_mode != NetEq::Mode::kRfc3389Cng &&
|
if (status.last_mode != NetEq::Mode::kRfc3389Cng &&
|
||||||
status.last_mode != NetEq::Mode::kCodecInternalCng &&
|
status.last_mode != NetEq::Mode::kCodecInternalCng) {
|
||||||
!(status.next_packet && status.next_packet->is_dtx &&
|
FilterBufferLevel(status.packet_buffer_info.span_samples);
|
||||||
!estimate_dtx_delay_)) {
|
|
||||||
FilterBufferLevel(cur_size_samples);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Guard for errors, to avoid getting stuck in error mode.
|
// Guard for errors, to avoid getting stuck in error mode.
|
||||||
@ -173,16 +161,14 @@ NetEq::Operation DecisionLogic::GetDecision(const NetEqStatus& status,
|
|||||||
// if the mute factor is low enough (otherwise the expansion was short enough
|
// if the mute factor is low enough (otherwise the expansion was short enough
|
||||||
// to not be noticable).
|
// to not be noticable).
|
||||||
// Note that the MuteFactor is in Q14, so a value of 16384 corresponds to 1.
|
// Note that the MuteFactor is in Q14, so a value of 16384 corresponds to 1.
|
||||||
const size_t current_span =
|
|
||||||
estimate_dtx_delay_ ? status.packet_buffer_info.span_samples
|
|
||||||
: status.packet_buffer_info.span_samples_no_dtx;
|
|
||||||
const int target_level_samples =
|
const int target_level_samples =
|
||||||
delay_manager_->TargetDelayMs() * sample_rate_ / 1000;
|
delay_manager_->TargetDelayMs() * sample_rate_ / 1000;
|
||||||
if ((status.last_mode == NetEq::Mode::kExpand ||
|
if ((status.last_mode == NetEq::Mode::kExpand ||
|
||||||
status.last_mode == NetEq::Mode::kCodecPlc) &&
|
status.last_mode == NetEq::Mode::kCodecPlc) &&
|
||||||
status.expand_mutefactor < 16384 / 2 &&
|
status.expand_mutefactor < 16384 / 2 &&
|
||||||
current_span < static_cast<size_t>(target_level_samples *
|
status.packet_buffer_info.span_samples <
|
||||||
kPostponeDecodingLevel / 100) &&
|
static_cast<size_t>(target_level_samples * kPostponeDecodingLevel /
|
||||||
|
100) &&
|
||||||
!status.packet_buffer_info.dtx_or_cng) {
|
!status.packet_buffer_info.dtx_or_cng) {
|
||||||
return NetEq::Operation::kExpand;
|
return NetEq::Operation::kExpand;
|
||||||
}
|
}
|
||||||
@ -368,40 +354,26 @@ NetEq::Operation DecisionLogic::FuturePacketAvailable(
|
|||||||
// If previous was comfort noise, then no merge is needed.
|
// If previous was comfort noise, then no merge is needed.
|
||||||
if (prev_mode == NetEq::Mode::kRfc3389Cng ||
|
if (prev_mode == NetEq::Mode::kRfc3389Cng ||
|
||||||
prev_mode == NetEq::Mode::kCodecInternalCng) {
|
prev_mode == NetEq::Mode::kCodecInternalCng) {
|
||||||
size_t cur_size_samples =
|
|
||||||
estimate_dtx_delay_
|
|
||||||
? span_samples_in_packet_buffer
|
|
||||||
: num_packets_in_packet_buffer * decoder_frame_length;
|
|
||||||
// Target level is in number of packets in Q8.
|
|
||||||
const size_t target_level_samples =
|
const size_t target_level_samples =
|
||||||
delay_manager_->TargetDelayMs() * sample_rate_ / 1000;
|
delay_manager_->TargetDelayMs() * sample_rate_ / 1000;
|
||||||
const bool generated_enough_noise =
|
const bool generated_enough_noise =
|
||||||
static_cast<uint32_t>(generated_noise_samples + target_timestamp) >=
|
static_cast<uint32_t>(generated_noise_samples + target_timestamp) >=
|
||||||
available_timestamp;
|
available_timestamp;
|
||||||
|
const size_t target_threshold_samples =
|
||||||
if (time_stretch_cn_) {
|
target_level_window_ms_ / 2 * (sample_rate_ / 1000);
|
||||||
const size_t target_threshold_samples =
|
const bool above_target_window =
|
||||||
target_level_window_ms_ / 2 * (sample_rate_ / 1000);
|
span_samples_in_packet_buffer >
|
||||||
const bool above_target_window =
|
target_level_samples + target_threshold_samples;
|
||||||
cur_size_samples > target_level_samples + target_threshold_samples;
|
const bool below_target_window =
|
||||||
const bool below_target_window =
|
target_level_samples > target_threshold_samples &&
|
||||||
target_level_samples > target_threshold_samples &&
|
span_samples_in_packet_buffer <
|
||||||
cur_size_samples < target_level_samples - target_threshold_samples;
|
target_level_samples - target_threshold_samples;
|
||||||
// Keep the delay same as before CNG, but make sure that it is within the
|
// Keep the delay same as before CNG, but make sure that it is within the
|
||||||
// target window.
|
// target window.
|
||||||
if ((generated_enough_noise && !below_target_window) ||
|
if ((generated_enough_noise && !below_target_window) ||
|
||||||
above_target_window) {
|
above_target_window) {
|
||||||
time_stretched_cn_samples_ = timestamp_leap - generated_noise_samples;
|
time_stretched_cn_samples_ = timestamp_leap - generated_noise_samples;
|
||||||
return NetEq::Operation::kNormal;
|
return NetEq::Operation::kNormal;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Keep the same delay as before the CNG, but make sure that the number of
|
|
||||||
// samples in buffer is no higher than 4 times the optimal level.
|
|
||||||
if (generated_enough_noise ||
|
|
||||||
cur_size_samples > target_level_samples * 4) {
|
|
||||||
// Time to play this new packet.
|
|
||||||
return NetEq::Operation::kNormal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Too early to play this new packet; keep on playing comfort noise.
|
// Too early to play this new packet; keep on playing comfort noise.
|
||||||
|
|||||||
@ -191,8 +191,6 @@ class DecisionLogic : public NetEqController {
|
|||||||
int time_stretched_cn_samples_ = 0;
|
int time_stretched_cn_samples_ = 0;
|
||||||
bool last_pack_cng_or_dtmf_ = true;
|
bool last_pack_cng_or_dtmf_ = true;
|
||||||
bool buffer_flush_ = false;
|
bool buffer_flush_ = false;
|
||||||
FieldTrialParameter<bool> estimate_dtx_delay_;
|
|
||||||
FieldTrialParameter<bool> time_stretch_cn_;
|
|
||||||
FieldTrialConstrained<int> target_level_window_ms_;
|
FieldTrialConstrained<int> target_level_window_ms_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
#include "modules/audio_coding/neteq/delay_manager.h"
|
#include "modules/audio_coding/neteq/delay_manager.h"
|
||||||
#include "modules/audio_coding/neteq/mock/mock_buffer_level_filter.h"
|
#include "modules/audio_coding/neteq/mock/mock_buffer_level_filter.h"
|
||||||
#include "modules/audio_coding/neteq/mock/mock_delay_manager.h"
|
#include "modules/audio_coding/neteq/mock/mock_delay_manager.h"
|
||||||
#include "test/field_trial.h"
|
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -54,10 +53,6 @@ using ::testing::Return;
|
|||||||
class DecisionLogicTest : public ::testing::Test {
|
class DecisionLogicTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
DecisionLogicTest() {
|
DecisionLogicTest() {
|
||||||
test::ScopedFieldTrials field_trial(
|
|
||||||
"WebRTC-Audio-NetEqDecisionLogicSettings/"
|
|
||||||
"estimate_dtx_delay:true,time_stretch_cn:true/");
|
|
||||||
|
|
||||||
NetEqController::Config config;
|
NetEqController::Config config;
|
||||||
config.tick_timer = &tick_timer_;
|
config.tick_timer = &tick_timer_;
|
||||||
config.allow_time_stretching = true;
|
config.allow_time_stretching = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user