Remove minimum bucket returned by histogram quantile function.

This fixes a bug in delay manager relative arrival delay mode that caused the effective minimum target level to be 2 packets instead of 1.

Bug: webrtc:10333
Change-Id: I33d32c8da692a3db22179edb923873d307f740fd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150785
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29002}
This commit is contained in:
Jakob Ivarsson
2019-08-29 10:33:06 +02:00
committed by Commit Bot
parent b4a6128e28
commit a2479f7dc4
2 changed files with 4 additions and 4 deletions

View File

@ -395,7 +395,7 @@ int DelayManager::CalculateTargetLevel(int iat_packets, bool reordered) {
break;
}
case INTER_ARRIVAL_TIME: {
target_level = bucket_index;
target_level = std::max(bucket_index, 1);
base_target_level_ = target_level;
// Update detector for delay peaks.
bool delay_peak_found =

View File

@ -116,14 +116,14 @@ int Histogram::Quantile(int probability) {
int inverse_probability = (1 << 30) - probability;
size_t index = 0; // Start from the beginning of |buckets_|.
int sum = 1 << 30; // Assign to 1 in Q30.
sum -= buckets_[index]; // Ensure that target level is >= 1.
sum -= buckets_[index];
do {
while ((sum > inverse_probability) && (index < buckets_.size() - 1)) {
// Subtract the probabilities one by one until the sum is no longer greater
// than |inverse_probability|.
++index;
sum -= buckets_[index];
} while ((sum > inverse_probability) && (index < buckets_.size() - 1));
}
return static_cast<int>(index);
}