summaryrefslogtreecommitdiff
path: root/libavcodec/flacdsp_lpc_template.c
diff options
context:
space:
mode:
authorJames Darnley <james.darnley@gmail.com>2014-02-14 12:40:10 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-15 20:48:25 +0100
commit91126dc481a48400dd00cc45e98fb25520344874 (patch)
treebba48a897f8402c44a285237ee0c53dddc0acf20 /libavcodec/flacdsp_lpc_template.c
parent9ae8e23188fc2e533eea74757c9060557941d3d9 (diff)
downloadffmpeg-91126dc481a48400dd00cc45e98fb25520344874.tar.gz
flacdsp_lpc_template: add comment to explain the CONFIG_SMALL code
I found the optimisation of 2 samples per iteration obscured the underlying algorithm. I had to write it out on paper and translate into a mathematical sum to see that the two samples are unconnected. I hope that if anyone else is struggling to understand the code that this will be useful. Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/flacdsp_lpc_template.c')
-rw-r--r--libavcodec/flacdsp_lpc_template.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/flacdsp_lpc_template.c b/libavcodec/flacdsp_lpc_template.c
index 0c453aee8e..acdac042b6 100644
--- a/libavcodec/flacdsp_lpc_template.c
+++ b/libavcodec/flacdsp_lpc_template.c
@@ -139,3 +139,21 @@ static void FUNC(flac_lpc_encode_c)(int32_t *res, const int32_t *smp, int len,
}
#endif
}
+
+/* Comment for clarity/de-obfuscation.
+ *
+ * for (int i = order; i < len; i++) {
+ * int32_t p = 0;
+ * for (int j = 0; j < order; j++) {
+ * int c = coefs[j];
+ * int s = smp[(i-1)-j];
+ * p += c*s;
+ * }
+ * res[i] = smp[i] - (p >> shift);
+ * }
+ *
+ * The CONFIG_SMALL code above simplifies to this, in the case of SAMPLE_SIZE
+ * not being equal to 32 (at the present time that means for 16-bit audio). The
+ * code above does 2 samples per iteration. Commit bfdd5bc ( made all the way
+ * back in 2007) says that way is faster.
+ */