diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-02-29 18:55:13 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-03-04 02:11:38 +0100 |
commit | aaf26cffbac108cc3a4916e3284590e68b816865 (patch) | |
tree | 7b5cbf0140c69e81c9cb5f0bfe9564572d624ecb /libavcodec/lpc.c | |
parent | 08aa791d203869b8f490a9482aba753fc25184e6 (diff) | |
download | ffmpeg-aaf26cffbac108cc3a4916e3284590e68b816865.tar.gz |
avcodec/lpc: Split inline functions into a header of their own
And move compute_ref_coefs() to its only user: lpc.c
There is no overlap between the users of compute_lpc_coefs()
and lpc proper.
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/lpc.c')
-rw-r--r-- | libavcodec/lpc.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c index 9e2fd0f128..53f5c3d379 100644 --- a/libavcodec/lpc.c +++ b/libavcodec/lpc.c @@ -25,8 +25,39 @@ #define LPC_USE_DOUBLE #include "lpc.h" +#include "lpc_functions.h" #include "libavutil/avassert.h" +/** + * 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) +{ + LPC_TYPE err; + LPC_TYPE gen0[MAX_LPC_ORDER], gen1[MAX_LPC_ORDER]; + + for (int i = 0; i < max_order; i++) + gen0[i] = gen1[i] = autoc[i + 1]; + + err = autoc[0]; + ref[0] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1); + err += gen1[0] * ref[0]; + if (error) + error[0] = err; + for (int i = 1; i < max_order; i++) { + for (int 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] / ((LPC_USE_FIXED || err) ? err : 1); + err += gen1[0] * ref[i]; + if (error) + error[i] = err; + } +} + /** * Apply Welch window function to audio block |