summaryrefslogtreecommitdiffstats
path: root/libavcodec/lpc.c
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2015-09-01 06:34:50 +0100
committerRostislav Pehlivanov <atomnuker@gmail.com>2015-09-01 06:34:50 +0100
commit0fc3a51353509df107a8da192d8377f0121f7ab9 (patch)
tree9ba9700350fad07505ffdd1349b002f6aa7fade3 /libavcodec/lpc.c
parenta70ee2bdcd88e34ab9c82cb78262248b95757122 (diff)
downloadffmpeg-streaming-0fc3a51353509df107a8da192d8377f0121f7ab9.zip
ffmpeg-streaming-0fc3a51353509df107a8da192d8377f0121f7ab9.tar.gz
lpc: add ff_lpc_calc_ref_coefs_f() function
This commit adds a function to get the reflection coefficients on floating point samples. It's functionally identical to ff_lpc_calc_ref_coefs() except it works on float samples and will return the global prediction gain. The Welch window implementation which is more optimized works only on int32_t samples so a slower generic expression was used. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/lpc.c')
-rw-r--r--libavcodec/lpc.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index 07fc292..315997c 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -167,6 +167,26 @@ int ff_lpc_calc_ref_coefs(LPCContext *s,
return order;
}
+double ff_lpc_calc_ref_coefs_f(LPCContext *s, const float *samples, int len,
+ int order, double *ref)
+{
+ int i;
+ double signal = 0.0f, avg_err = 0.0f;
+ double autoc[MAX_LPC_ORDER+1] = {0}, error[MAX_LPC_ORDER] = {0};
+ const double c = (len - 1)/2.0f;
+
+ /* Welch window */
+ for (i = 0; i < len; i++)
+ s->windowed_samples[i] = 1.0f - ((samples[i]-c)/c)*((samples[i]-c)/c);
+
+ s->lpc_compute_autocorr(s->windowed_samples, len, order, autoc);
+ signal = autoc[0];
+ compute_ref_coefs(autoc, order, ref, error);
+ for (i = 0; i < order; i++)
+ avg_err = (avg_err + error[i])/2.0f;
+ return signal/avg_err;
+}
+
/**
* Calculate LPC coefficients for multiple orders
*
OpenPOWER on IntegriCloud