summaryrefslogtreecommitdiff
path: root/libavcodec/lpc.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-30 14:40:22 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-10-30 14:40:22 +0100
commite79c3858b35fcc77c68c33b627958e736686957e (patch)
tree5f933517c2909def4e2930a409b0a460eb4f41fd /libavcodec/lpc.h
parentcd37963684d8ee9819af15ccebe09d84839101dd (diff)
parent14f031d7ecfabba0ef02776d4516aa3dcb7c40d8 (diff)
Merge commit '14f031d7ecfabba0ef02776d4516aa3dcb7c40d8'
* commit '14f031d7ecfabba0ef02776d4516aa3dcb7c40d8': dv: use AVStream.index instead of abusing AVStream.id lavfi: add ashowinfo filter avcodec: Add a RFC 3389 comfort noise codec lpc: Add a function for calculating reflection coefficients from samples lpc: Add a function for calculating reflection coefficients from autocorrelation coefficients lavr: document upper bound on number of output samples. lavr: add general API usage doxy indeo3: remove duplicate capabilities line. fate: ac3: Add dependencies Conflicts: Changelog doc/filters.texi libavcodec/Makefile libavcodec/allcodecs.c libavcodec/avcodec.h libavcodec/codec_desc.c libavcodec/version.h libavfilter/Makefile libavfilter/af_ashowinfo.c libavfilter/allfilters.c libavfilter/version.h libavutil/avutil.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/lpc.h')
-rw-r--r--libavcodec/lpc.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h
index b9c35bd303..24f776a244 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.
*/
@@ -112,6 +115,37 @@ void ff_lpc_end(LPCContext *s);
#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.
*/