mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
lpc: Add a function for calculating reflection coefficients from autocorrelation coefficients
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
dc5793062e
commit
39ef66f530
@ -110,6 +110,37 @@ void ff_lpc_end(LPCContext *s);
|
|||||||
#define LPC_TYPE float
|
#define LPC_TYPE float
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schur recursion.
|
||||||
|
* Produces reflection coefficients from autocorrelation data.
|
||||||
|
*/
|
||||||
|
static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
|
||||||
|
LPC_TYPE *ref, LPC_TYPE *error)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
LPC_TYPE err;
|
||||||
|
LPC_TYPE gen0[MAX_LPC_ORDER], gen1[MAX_LPC_ORDER];
|
||||||
|
|
||||||
|
for (i = 0; i < max_order; i++)
|
||||||
|
gen0[i] = gen1[i] = autoc[i + 1];
|
||||||
|
|
||||||
|
err = autoc[0];
|
||||||
|
ref[0] = -gen1[0] / err;
|
||||||
|
err += gen1[0] * ref[0];
|
||||||
|
if (error)
|
||||||
|
error[0] = err;
|
||||||
|
for (i = 1; i < max_order; i++) {
|
||||||
|
for (j = 0; j < max_order - i; j++) {
|
||||||
|
gen1[j] = gen1[j + 1] + ref[i - 1] * gen0[j];
|
||||||
|
gen0[j] = gen1[j + 1] * ref[i - 1] + gen0[j];
|
||||||
|
}
|
||||||
|
ref[i] = -gen1[0] / err;
|
||||||
|
err += gen1[0] * ref[i];
|
||||||
|
if (error)
|
||||||
|
error[i] = err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Levinson-Durbin recursion.
|
* Levinson-Durbin recursion.
|
||||||
* Produce LPC coefficients from autocorrelation data.
|
* Produce LPC coefficients from autocorrelation data.
|
||||||
|
Loading…
Reference in New Issue
Block a user