X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flpc.h;h=24f776a244faf098779b3d5133940b9a60a852a0;hb=78e08fd340e03b49f75e1ac31c20cc21434794bd;hp=b9c35bd30369f797133d611707ab90df613a9871;hpb=c079da5073167b5e7e959af12ef157e71bde0015;p=ffmpeg diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h index b9c35bd3036..24f776a244f 100644 --- a/libavcodec/lpc.h +++ b/libavcodec/lpc.h @@ -93,6 +93,9 @@ int ff_lpc_calc_coefs(LPCContext *s, enum FFLPCType lpc_type, int lpc_passes, int omethod, int max_shift, int zero_shift); +int ff_lpc_calc_ref_coefs(LPCContext *s, + const int32_t *samples, int order, double *ref); + /** * Initialize LPCContext. */ @@ -111,6 +114,37 @@ void ff_lpc_end(LPCContext *s); #define LPC_TYPE float #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. * Produce LPC coefficients from autocorrelation data.