1b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org/* 2b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org * 4b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org * Use of this source code is governed by a BSD-style license 5b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org * that can be found in the LICENSE file in the root of the source 6b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org * tree. An additional intellectual property rights grant can be found 7b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org * in the file PATENTS. All contributing project authors may 8b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org * be found in the AUTHORS file in the root of the source tree. 9b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org */ 10b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org 11b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Performs delay estimation on block by block basis. 12b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// The return value is 0 - OK and -1 - Error, unless otherwise stated. 13b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org 14b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_WRAPPER_H_ 15b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_WRAPPER_H_ 16b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org 17c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org#include "webrtc/typedefs.h" 18c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org 19c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// Releases the memory allocated by WebRtc_CreateDelayEstimatorFarend(...) 20c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.orgvoid WebRtc_FreeDelayEstimatorFarend(void* handle); 21c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org 22c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// Allocates the memory needed by the far-end part of the delay estimation. The 23c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// memory needs to be initialized separately through 24c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// WebRtc_InitDelayEstimatorFarend(...). 25c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// 26c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// Inputs: 27bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - spectrum_size : Size of the spectrum used both in far-end and 28c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// near-end. Used to allocate memory for spectrum 29c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// specific buffers. 30bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - history_size : The far-end history buffer size. A change in buffer 31bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// size can be forced with WebRtc_set_history_size(). 32bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// Note that the maximum delay which can be estimated is 33bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// determined together with WebRtc_set_lookahead(). 34c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// 35c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// Return value: 36bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - void* : Created |handle|. If the memory can't be allocated or 37c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// if any of the input parameters are invalid NULL is 38c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// returned. 39c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.orgvoid* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size); 40c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org 41c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// Initializes the far-end part of the delay estimation instance returned by 42c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// WebRtc_CreateDelayEstimatorFarend(...) 43c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.orgint WebRtc_InitDelayEstimatorFarend(void* handle); 44c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org 451df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// Soft resets the far-end part of the delay estimation instance returned by 461df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// WebRtc_CreateDelayEstimatorFarend(...). 471df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// Input: 481df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// - delay_shift : The amount of blocks to shift history buffers. 491df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.orgvoid WebRtc_SoftResetDelayEstimatorFarend(void* handle, int delay_shift); 501df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org 51c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// Adds the far-end spectrum to the far-end history buffer. This spectrum is 52c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// used as reference when calculating the delay using 53c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// WebRtc_ProcessSpectrum(). 54c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// 55c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// Inputs: 56c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// - far_spectrum : Far-end spectrum. 57c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// - spectrum_size : The size of the data arrays (same for both far- and 58c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// near-end). 59c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// - far_q : The Q-domain of the far-end data. 60138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.org// 61138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.org// Output: 62138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.org// - handle : Updated far-end instance. 63138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.org// 64138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.orgint WebRtc_AddFarSpectrumFix(void* handle, 65138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.org const uint16_t* far_spectrum, 66138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.org int spectrum_size, 67138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.org int far_q); 68c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org 69c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// See WebRtc_AddFarSpectrumFix() for description. 70138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.orgint WebRtc_AddFarSpectrumFloat(void* handle, 71138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.org const float* far_spectrum, 72c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org int spectrum_size); 73b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org 74b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Releases the memory allocated by WebRtc_CreateDelayEstimator(...) 75b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgvoid WebRtc_FreeDelayEstimator(void* handle); 76b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org 77b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Allocates the memory needed by the delay estimation. The memory needs to be 78b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// initialized separately through WebRtc_InitDelayEstimator(...). 79b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// 80b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Inputs: 81c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// - farend_handle : Pointer to the far-end part of the delay estimation 82c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// instance created prior to this call using 83c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// WebRtc_CreateDelayEstimatorFarend(). 84c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// 85c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// Note that WebRtc_CreateDelayEstimator does not take 86c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// ownership of |farend_handle|, which has to be torn 87c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// down properly after this instance. 88c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// 89b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// - max_lookahead : Maximum amount of non-causal lookahead allowed. The 90b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// actual amount of lookahead used can be controlled by 91b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// WebRtc_set_lookahead(...). The default |lookahead| is 92b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// set to |max_lookahead| at create time. Use 93b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// WebRtc_set_lookahead(...) before start if a different 94b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// value is desired. 95b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// 96b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// Using lookahead can detect cases in which a near-end 97b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// signal occurs before the corresponding far-end signal. 98b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// It will delay the estimate for the current block by an 99b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// equal amount, and the returned values will be offset 100b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// by it. 101b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// 102b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// A value of zero is the typical no-lookahead case. 103b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// This also represents the minimum delay which can be 104b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// estimated. 105b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// 106c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// Note that the effective range of delay estimates is 107c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// [-|lookahead|,... ,|history_size|-|lookahead|) 108bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// where |history_size| is set through 109bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// WebRtc_set_history_size(). 110c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// 111b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Return value: 112b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// - void* : Created |handle|. If the memory can't be allocated or 113b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// if any of the input parameters are invalid NULL is 114b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// returned. 115b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.orgvoid* WebRtc_CreateDelayEstimator(void* farend_handle, int max_lookahead); 116b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org 117b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Initializes the delay estimation instance returned by 118b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// WebRtc_CreateDelayEstimator(...) 119b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgint WebRtc_InitDelayEstimator(void* handle); 120b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org 1211df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// Soft resets the delay estimation instance returned by 1221df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// WebRtc_CreateDelayEstimator(...) 1231df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// Input: 1241df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// - delay_shift : The amount of blocks to shift history buffers. 1251df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// 1261df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// Return value: 1271df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// - actual_shifts : The actual number of shifts performed. 1281df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.orgint WebRtc_SoftResetDelayEstimator(void* handle, int delay_shift); 1291df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org 130bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// Sets the effective |history_size| used. Valid values from 2. We simply need 131bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// at least two delays to compare to perform an estimate. If |history_size| is 132bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// changed, buffers are reallocated filling in with zeros if necessary. 133bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// Note that changing the |history_size| affects both buffers in far-end and 134bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// near-end. Hence it is important to change all DelayEstimators that use the 135bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// same reference far-end, to the same |history_size| value. 136bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// Inputs: 137bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - handle : Pointer to the delay estimation instance. 138bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - history_size : Effective history size to be used. 139bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// Return value: 140bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - new_history_size : The new history size used. If the memory was not able 141bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// to be allocated 0 is returned. 142bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.orgint WebRtc_set_history_size(void* handle, int history_size); 143bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org 144bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// Returns the history_size currently used. 145bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// Input: 146bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - handle : Pointer to the delay estimation instance. 147bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.orgint WebRtc_history_size(const void* handle); 148bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org 149b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// Sets the amount of |lookahead| to use. Valid values are [0, max_lookahead] 150b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// where |max_lookahead| was set at create time through 151b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// WebRtc_CreateDelayEstimator(...). 152b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// 153b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// Input: 154bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - handle : Pointer to the delay estimation instance. 155bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - lookahead : The amount of lookahead to be used. 156b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// 157b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// Return value: 158bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - new_lookahead : The actual amount of lookahead set, unless |handle| is 159bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// a NULL pointer or |lookahead| is invalid, for which an 160bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// error is returned. 161b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.orgint WebRtc_set_lookahead(void* handle, int lookahead); 162b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org 1631df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// Returns the amount of lookahead we currently use. 164bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// Input: 165bf79df39800b97d29662f6c0ab14203045ed4ca7bjornv@webrtc.org// - handle : Pointer to the delay estimation instance. 1661df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.orgint WebRtc_lookahead(void* handle); 1671df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org 1689b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// Sets the |allowed_offset| used in the robust validation scheme. If the 1699b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// delay estimator is used in an echo control component, this parameter is 1709b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// related to the filter length. In principle |allowed_offset| should be set to 1719b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// the echo control filter length minus the expected echo duration, i.e., the 1729b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// delay offset the echo control can handle without quality regression. The 1739b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// default value, used if not set manually, is zero. Note that |allowed_offset| 1749b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// has to be non-negative. 1759b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// Inputs: 1769b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// - handle : Pointer to the delay estimation instance. 1779b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// - allowed_offset : The amount of delay offset, measured in partitions, 1789b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// the echo control filter can handle. 1799b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.orgint WebRtc_set_allowed_offset(void* handle, int allowed_offset); 1809b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org 1819b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// Returns the |allowed_offset| in number of partitions. 1829b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.orgint WebRtc_get_allowed_offset(const void* handle); 1839b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org 184cd8c2b1046b70c4cae288fc548c9787c6875a2d4bjornv@webrtc.org// Enables/Disables a robust validation functionality in the delay estimation. 1859b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// This is by default set to disabled at create time. The state is preserved 1869b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.org// over a reset. 187cd8c2b1046b70c4cae288fc548c9787c6875a2d4bjornv@webrtc.org// Inputs: 188cd8c2b1046b70c4cae288fc548c9787c6875a2d4bjornv@webrtc.org// - handle : Pointer to the delay estimation instance. 189cd8c2b1046b70c4cae288fc548c9787c6875a2d4bjornv@webrtc.org// - enable : Enable (1) or disable (0) this feature. 190cd8c2b1046b70c4cae288fc548c9787c6875a2d4bjornv@webrtc.orgint WebRtc_enable_robust_validation(void* handle, int enable); 191cd8c2b1046b70c4cae288fc548c9787c6875a2d4bjornv@webrtc.org 192cd8c2b1046b70c4cae288fc548c9787c6875a2d4bjornv@webrtc.org// Returns 1 if robust validation is enabled and 0 if disabled. 1939b125e1b0d1bf2cc646ab5f42ba650f62250eb4dbjornv@webrtc.orgint WebRtc_is_robust_validation_enabled(const void* handle); 194cd8c2b1046b70c4cae288fc548c9787c6875a2d4bjornv@webrtc.org 195b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Estimates and returns the delay between the far-end and near-end blocks. The 196b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// value will be offset by the lookahead (i.e. the lookahead should be 197b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// subtracted from the returned value). 198b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Inputs: 199b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// - handle : Pointer to the delay estimation instance. 200b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// - near_spectrum : Pointer to the near-end spectrum data of the current 201b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// block. 202b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// - spectrum_size : The size of the data arrays (same for both far- and 203b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// near-end). 204b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// - near_q : The Q-domain of the near-end data. 205b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// 206b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Output: 207b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// - handle : Updated instance. 208b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// 209b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Return value: 210b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// - delay : >= 0 - Calculated delay value. 211b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// -1 - Error. 212b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// -2 - Insufficient data for estimation. 213b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgint WebRtc_DelayEstimatorProcessFix(void* handle, 214138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.org const uint16_t* near_spectrum, 215b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org int spectrum_size, 216b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org int near_q); 217b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org 218b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// See WebRtc_DelayEstimatorProcessFix() for description. 219b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgint WebRtc_DelayEstimatorProcessFloat(void* handle, 220138adbb0bcdab60afda25a8727e5a071abc4ae36bjornv@webrtc.org const float* near_spectrum, 221b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org int spectrum_size); 222b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org 223b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Returns the last calculated delay updated by the function 224b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// WebRtc_DelayEstimatorProcess(...). 225b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// 226b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Input: 227b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// - handle : Pointer to the delay estimation instance. 228b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// 229b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Return value: 230c7beae5a7f10192712a5d1a901f41a90f42daaffbjornv@webrtc.org// - delay : >= 0 - Last calculated delay value. 231b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// -1 - Error. 232b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// -2 - Insufficient data for estimation. 233b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgint WebRtc_last_delay(void* handle); 234b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org 235d9e4516726c76e3a570c12cd159527c31ce1b563bjornv@webrtc.org// Returns the estimation quality/probability of the last calculated delay 236d9e4516726c76e3a570c12cd159527c31ce1b563bjornv@webrtc.org// updated by the function WebRtc_DelayEstimatorProcess(...). The estimation 2371df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// quality is a value in the interval [0, 1]. The higher the value, the better 238b5a182a9321ff847a24620c5e991e1749362549abjornv@webrtc.org// the quality. 239d9e4516726c76e3a570c12cd159527c31ce1b563bjornv@webrtc.org// 240d9e4516726c76e3a570c12cd159527c31ce1b563bjornv@webrtc.org// Return value: 2411df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.org// - delay_quality : >= 0 - Estimation quality of last calculated delay. 2421df7a5a60c35863a609155f931580a7367fff900bjornv@webrtc.orgfloat WebRtc_last_delay_quality(void* handle); 243d9e4516726c76e3a570c12cd159527c31ce1b563bjornv@webrtc.org 244b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#endif // WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_DELAY_ESTIMATOR_WRAPPER_H_ 245