The existing function ff_lpc_calc_coefs does this, but doesn't
return the reflection coefficients, only the lpc coefficients.
---
 libavcodec/lpc.c |   18 ++++++++++++++++++
 libavcodec/lpc.h |    3 +++
 2 files changed, 21 insertions(+)

diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index 126dbc1..a4e4121 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -148,6 +148,24 @@ static int estimate_best_order(double *ref, int min_order, 
int max_order)
     return est;
 }
 
+int ff_lpc_calc_refl_coefs(LPCContext *s,
+                           const int32_t *samples, int order, float *refl)
+{
+    double autoc[MAX_LPC_ORDER+1];
+    double lpc[MAX_LPC_ORDER][MAX_LPC_ORDER];
+    int i;
+
+    s->lpc_apply_welch_window(samples, s->blocksize, s->windowed_samples);
+
+    s->lpc_compute_autocorr(s->windowed_samples, s->blocksize, order, autoc);
+
+    compute_lpc_coefs(autoc, order, &lpc[0][0], MAX_LPC_ORDER, 0, 1);
+
+    for (i = 0; i < order; i++)
+        refl[i] = lpc[i][i];
+    return order;
+}
+
 /**
  * Calculate LPC coefficients for multiple orders
  *
diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h
index cbee46f..6174c48 100644
--- a/libavcodec/lpc.h
+++ b/libavcodec/lpc.h
@@ -92,6 +92,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_refl_coefs(LPCContext *s,
+                           const int32_t *samples, int order, float *refl);
+
 /**
  * Initialize LPCContext.
  */
-- 
1.7.9.4

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to