NetEq: Fold GetDecisionSpecialized into GetDecision

Now that there is only one implementation of the decision logic, there
is no longer any need to have GetDecisionSpecialized being separate.

Bug: webrtc:9421
Change-Id: Id364ce09ac05d106652d749502058056f11bba27
Reviewed-on: https://webrtc-review.googlesource.com/86604
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23804}
This commit is contained in:
Henrik Lundin
2018-07-02 14:53:24 +02:00
committed by Commit Bot
parent 9f2e624024
commit 5afa61cf15
2 changed files with 34 additions and 68 deletions

View File

@ -122,53 +122,6 @@ Operations DecisionLogic::GetDecision(const SyncBuffer& sync_buffer,
FilterBufferLevel(cur_size_samples, prev_mode);
return GetDecisionSpecialized(
sync_buffer, expand, decoder_frame_length, next_packet, prev_mode,
play_dtmf, reset_decoder, generated_noise_samples, cur_size_samples);
}
void DecisionLogic::ExpandDecision(Operations operation) {
if (operation == kExpand) {
num_consecutive_expands_++;
} else {
num_consecutive_expands_ = 0;
}
}
void DecisionLogic::FilterBufferLevel(size_t buffer_size_samples,
Modes prev_mode) {
// Do not update buffer history if currently playing CNG since it will bias
// the filtered buffer level.
if ((prev_mode != kModeRfc3389Cng) && (prev_mode != kModeCodecInternalCng)) {
buffer_level_filter_->SetTargetBufferLevel(
delay_manager_->base_target_level());
size_t buffer_size_packets = 0;
if (packet_length_samples_ > 0) {
// Calculate size in packets.
buffer_size_packets = buffer_size_samples / packet_length_samples_;
}
int sample_memory_local = 0;
if (prev_time_scale_) {
sample_memory_local = sample_memory_;
timescale_countdown_ =
tick_timer_->GetNewCountdown(kMinTimescaleInterval);
}
buffer_level_filter_->Update(buffer_size_packets, sample_memory_local,
packet_length_samples_);
prev_time_scale_ = false;
}
}
Operations DecisionLogic::GetDecisionSpecialized(const SyncBuffer& sync_buffer,
const Expand& expand,
size_t decoder_frame_length,
const Packet* next_packet,
Modes prev_mode,
bool play_dtmf,
bool* reset_decoder,
size_t generated_noise_samples,
size_t cur_size_samples) {
// Guard for errors, to avoid getting stuck in error mode.
if (prev_mode == kModeError) {
if (!next_packet) {
@ -236,6 +189,39 @@ Operations DecisionLogic::GetDecisionSpecialized(const SyncBuffer& sync_buffer,
}
}
void DecisionLogic::ExpandDecision(Operations operation) {
if (operation == kExpand) {
num_consecutive_expands_++;
} else {
num_consecutive_expands_ = 0;
}
}
void DecisionLogic::FilterBufferLevel(size_t buffer_size_samples,
Modes prev_mode) {
// Do not update buffer history if currently playing CNG since it will bias
// the filtered buffer level.
if ((prev_mode != kModeRfc3389Cng) && (prev_mode != kModeCodecInternalCng)) {
buffer_level_filter_->SetTargetBufferLevel(
delay_manager_->base_target_level());
size_t buffer_size_packets = 0;
if (packet_length_samples_ > 0) {
// Calculate size in packets.
buffer_size_packets = buffer_size_samples / packet_length_samples_;
}
int sample_memory_local = 0;
if (prev_time_scale_) {
sample_memory_local = sample_memory_;
timescale_countdown_ =
tick_timer_->GetNewCountdown(kMinTimescaleInterval);
}
buffer_level_filter_->Update(buffer_size_packets, sample_memory_local,
packet_length_samples_);
prev_time_scale_ = false;
}
}
Operations DecisionLogic::CngOperation(Modes prev_mode,
uint32_t target_timestamp,
uint32_t available_timestamp,

View File

@ -29,7 +29,7 @@ class SyncBuffer;
struct Packet;
// This is the class for the decision tree implementation.
class DecisionLogic {
class DecisionLogic final {
public:
// Static factory function which creates different types of objects depending
// on the |playout_mode|.
@ -120,26 +120,6 @@ class DecisionLogic {
// |buffer_size_packets|.
void FilterBufferLevel(size_t buffer_size_packets, Modes prev_mode);
// Returns the operation that should be done next. |sync_buffer| and |expand|
// are provided for reference. |decoder_frame_length| is the number of samples
// obtained from the last decoded frame. If there is a packet available, it
// should be supplied in |next_packet|; otherwise it should be NULL. The mode
// resulting from the last call to NetEqImpl::GetAudio is supplied in
// |prev_mode|. If there is a DTMF event to play, |play_dtmf| should be set to
// true. The output variable |reset_decoder| will be set to true if a reset is
// required; otherwise it is left unchanged (i.e., it can remain true if it
// was true before the call).
// TODO(henrik.lundin) Fold this method into GetDecision.
Operations GetDecisionSpecialized(const SyncBuffer& sync_buffer,
const Expand& expand,
size_t decoder_frame_length,
const Packet* next_packet,
Modes prev_mode,
bool play_dtmf,
bool* reset_decoder,
size_t generated_noise_samples,
size_t cur_size_samples);
// Returns the operation given that the next available packet is a comfort
// noise payload (RFC 3389 only, not codec-internal).
Operations CngOperation(Modes prev_mode,