Lines Matching refs:handle

62 int WebRtc_FreeBinaryDelayEstimator(BinaryDelayEstimator* handle) {
63 assert(handle != NULL);
65 if (handle->mean_bit_counts != NULL) {
66 free(handle->mean_bit_counts);
67 handle->mean_bit_counts = NULL;
69 if (handle->bit_counts != NULL) {
70 free(handle->bit_counts);
71 handle->bit_counts = NULL;
73 if (handle->binary_far_history != NULL) {
74 free(handle->binary_far_history);
75 handle->binary_far_history = NULL;
77 if (handle->binary_near_history != NULL) {
78 free(handle->binary_near_history);
79 handle->binary_near_history = NULL;
81 if (handle->far_bit_counts != NULL) {
82 free(handle->far_bit_counts);
83 handle->far_bit_counts = NULL;
86 free(handle);
91 int WebRtc_CreateBinaryDelayEstimator(BinaryDelayEstimator** handle,
97 if (handle == NULL) {
112 *handle = self;
162 int WebRtc_InitBinaryDelayEstimator(BinaryDelayEstimator* handle) {
164 assert(handle != NULL);
166 memset(handle->bit_counts, 0, sizeof(int32_t) * handle->history_size);
167 memset(handle->binary_far_history, 0,
168 sizeof(uint32_t) * handle->history_size);
169 memset(handle->binary_near_history, 0,
170 sizeof(uint32_t) * handle->near_history_size);
171 memset(handle->far_bit_counts, 0, sizeof(int) * handle->history_size);
172 for (i = 0; i < handle->history_size; ++i) {
173 handle->mean_bit_counts[i] = (20 << 9); // 20 in Q9.
175 handle->minimum_probability = (32 << 9); // 32 in Q9.
176 handle->last_delay_probability = (32 << 9); // 32 in Q9.
179 handle->last_delay = -2;
184 int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* handle,
193 assert(handle != NULL);
195 memmove(&(handle->binary_far_history[1]), &(handle->binary_far_history[0]),
196 (handle->history_size - 1) * sizeof(uint32_t));
197 handle->binary_far_history[0] = binary_far_spectrum;
201 memmove(&(handle->far_bit_counts[1]), &(handle->far_bit_counts[0]),
202 (handle->history_size - 1) * sizeof(int));
203 handle->far_bit_counts[0] = BitCount(binary_far_spectrum);
205 if (handle->near_history_size > 1) {
208 memmove(&(handle->binary_near_history[1]),
209 &(handle->binary_near_history[0]),
210 (handle->near_history_size - 1) * sizeof(uint32_t));
211 handle->binary_near_history[0] = binary_near_spectrum;
213 handle->binary_near_history[handle->near_history_size - 1];
218 handle->binary_far_history,
219 handle->history_size,
220 handle->bit_counts);
223 for (i = 0; i < handle->history_size; i++) {
226 int32_t bit_count = (handle->bit_counts[i] << 9); // Q9.
231 if (handle->far_bit_counts[i] > 0) {
234 shifts -= (kShiftsLinearSlope * handle->far_bit_counts[i]) >> 4;
235 WebRtc_MeanEstimatorFix(bit_count, shifts, &(handle->mean_bit_counts[i]));
241 for (i = 0; i < handle->history_size; i++) {
242 if (handle->mean_bit_counts[i] < value_best_candidate) {
243 value_best_candidate = handle->mean_bit_counts[i];
246 if (handle->mean_bit_counts[i] > value_worst_candidate) {
247 value_worst_candidate = handle->mean_bit_counts[i];
265 if ((handle->minimum_probability > kProbabilityLowerLimit) &&
275 if (handle->minimum_probability > threshold) {
276 handle->minimum_probability = threshold;
281 handle->last_delay_probability++;
284 if (value_best_candidate < handle->minimum_probability) {
285 handle->last_delay = candidate_delay;
287 if (value_best_candidate < handle->last_delay_probability) {
288 handle->last_delay = candidate_delay;
290 handle->last_delay_probability = value_best_candidate;
294 return handle->last_delay;
297 int WebRtc_binary_last_delay(BinaryDelayEstimator* handle) {
298 assert(handle != NULL);
299 return handle->last_delay;
302 int WebRtc_history_size(BinaryDelayEstimator* handle) {
303 assert(handle != NULL);
304 return handle->history_size;