Simplification of histogram normalization in delay estimator.
- Replaces a for loop with a single element update to save complexity. No regression in performance seen on set of recordings. - Removes UpdatesMadeUponChange() and put code straight into ProcessBinarySpectrum(). BUG=None TESTED=module_unittest, trybots, verified manually on set of recordings. R=aluebs@webrtc.org, andrew@webrtc.org Review URL: https://webrtc-codereview.appspot.com/5929004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5298 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
5ab756703e
commit
1e7d61270c
@ -258,36 +258,6 @@ static int RobustValidation(const BinaryDelayEstimator* self,
|
||||
return is_robust;
|
||||
}
|
||||
|
||||
// UpdatesMadeUponChange() makes two parameter updates only done when we have a
|
||||
// change/jump in delay. For further description, see commented code.
|
||||
//
|
||||
// Inputs:
|
||||
// - candidate_delay : The delay to validate.
|
||||
static void UpdatesMadeUponChange(BinaryDelayEstimator* self,
|
||||
int candidate_delay) {
|
||||
int i = 0;
|
||||
|
||||
self->last_delay_histogram =
|
||||
(self->histogram[candidate_delay] > kLastHistogramMax ?
|
||||
kLastHistogramMax : self->histogram[candidate_delay]);
|
||||
// TODO(bjornv): Investigate if we can simplify to only change
|
||||
// self->histogram[self->last_delay] instead of looping through all histogram
|
||||
// bins. Looping through all bins is to ensure
|
||||
// self->histogram[candidate_delay] is currently the most likely bin.
|
||||
// Otherwise we might jump back too easy to a neighbor even for spurious
|
||||
// changes.
|
||||
// Since we may jump to a new delay even if it is not the most likely
|
||||
// according to the histogram, we here adjust the histogram to make sure the
|
||||
// |candidate_delay| now is the most likely one.
|
||||
if (self->histogram[candidate_delay] < self->histogram[self->compare_delay]) {
|
||||
for (i = 0; i < self->farend->history_size; ++i) {
|
||||
if (self->histogram[i] > self->histogram[candidate_delay]) {
|
||||
self->histogram[i] = self->histogram[candidate_delay];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebRtc_FreeBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self) {
|
||||
|
||||
if (self == NULL) {
|
||||
@ -552,7 +522,15 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self,
|
||||
}
|
||||
if (valid_candidate) {
|
||||
if (candidate_delay != self->last_delay) {
|
||||
UpdatesMadeUponChange(self, candidate_delay);
|
||||
self->last_delay_histogram =
|
||||
(self->histogram[candidate_delay] > kLastHistogramMax ?
|
||||
kLastHistogramMax : self->histogram[candidate_delay]);
|
||||
// Adjust the histogram if we made a change to |last_delay|, though it was
|
||||
// not the most likely one according to the histogram.
|
||||
if (self->histogram[candidate_delay] <
|
||||
self->histogram[self->compare_delay]) {
|
||||
self->histogram[self->compare_delay] = self->histogram[candidate_delay];
|
||||
}
|
||||
}
|
||||
self->last_delay = candidate_delay;
|
||||
if (value_best_candidate < self->last_delay_probability) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user