/* * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// Inserts `feature_value` into `low_value_vector`, if it is one of the 16 // smallest values the last 100 frames. Then calculates and returns the median // of the five smallest values.
int16_t WebRtcVad_FindMinimum(VadInstT* self,
int16_t feature_value, int channel) { int i = 0, j = 0; int position = -1; // Offset to beginning of the 16 minimum values in memory. constint offset = (channel << 4);
int16_t current_median = 1600;
int16_t alpha = 0;
int32_t tmp32 = 0; // Pointer to memory for the 16 minimum values and the age of each value of // the `channel`.
int16_t* age = &self->index_vector[offset];
int16_t* smallest_values = &self->low_value_vector[offset];
RTC_DCHECK_LT(channel, kNumChannels);
// Each value in `smallest_values` is getting 1 loop older. Update `age`, and // remove old values. for (i = 0; i < 16; i++) { if (age[i] != 100) {
age[i]++;
} else { // Too old value. Remove from memory and shift larger values downwards. for (j = i; j < 15; j++) {
smallest_values[j] = smallest_values[j + 1];
age[j] = age[j + 1];
}
age[15] = 101;
smallest_values[15] = 10000;
}
}
// Check if `feature_value` is smaller than any of the values in // `smallest_values`. If so, find the `position` where to insert the new value // (`feature_value`). if (feature_value < smallest_values[7]) { if (feature_value < smallest_values[3]) { if (feature_value < smallest_values[1]) { if (feature_value < smallest_values[0]) {
position = 0;
} else {
position = 1;
}
} elseif (feature_value < smallest_values[2]) {
position = 2;
} else {
position = 3;
}
} elseif (feature_value < smallest_values[5]) { if (feature_value < smallest_values[4]) {
position = 4;
} else {
position = 5;
}
} elseif (feature_value < smallest_values[6]) {
position = 6;
} else {
position = 7;
}
} elseif (feature_value < smallest_values[15]) { if (feature_value < smallest_values[11]) { if (feature_value < smallest_values[9]) { if (feature_value < smallest_values[8]) {
position = 8;
} else {
position = 9;
}
} elseif (feature_value < smallest_values[10]) {
position = 10;
} else {
position = 11;
}
} elseif (feature_value < smallest_values[13]) { if (feature_value < smallest_values[12]) {
position = 12;
} else {
position = 13;
}
} elseif (feature_value < smallest_values[14]) {
position = 14;
} else {
position = 15;
}
}
// If we have detected a new small value, insert it at the correct position // and shift larger values up. if (position > -1) { for (i = 15; i > position; i--) {
smallest_values[i] = smallest_values[i - 1];
age[i] = age[i - 1];
}
smallest_values[position] = feature_value;
age[position] = 1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.