aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorVitor Sessak <vitor1001@gmail.com>2009-11-09 12:06:19 +0000
committerVitor Sessak <vitor1001@gmail.com>2009-11-09 12:06:19 +0000
commite26d1318458e598bbea796508b812917d983cef6 (patch)
treed2b8f05a95678945a3b760d1b3df8dcd66d2697f /libavcodec
parent91cc5d37679b112d03c20d053905c3941c0a8992 (diff)
downloadffmpeg-e26d1318458e598bbea796508b812917d983cef6.tar.gz
Do not hardcode filter order in ff_acelp_lspd2lpc()
Originally committed as revision 20485 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/lsp.c21
-rw-r--r--libavcodec/lsp.h4
-rw-r--r--libavcodec/qcelpdec.c2
3 files changed, 14 insertions, 13 deletions
diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
index 09c9259c70..420921639f 100644
--- a/libavcodec/lsp.c
+++ b/libavcodec/lsp.c
@@ -155,20 +155,19 @@ static void lsp2polyf(const double *lsp, double *f, int lp_half_order)
}
}
-void ff_acelp_lspd2lpc(const double *lsp, float *lpc)
+void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order)
{
- double pa[6], qa[6];
- int i;
+ double pa[lp_half_order+1], qa[lp_half_order+1];
+ float *lpc2 = lpc + (lp_half_order << 1) - 1;
- lsp2polyf(lsp, pa, 5);
- lsp2polyf(lsp + 1, qa, 5);
+ lsp2polyf(lsp, pa, lp_half_order);
+ lsp2polyf(lsp + 1, qa, lp_half_order);
- for (i=4; i>=0; i--)
- {
- double paf = pa[i+1] + pa[i];
- double qaf = qa[i+1] - qa[i];
+ while (lp_half_order--) {
+ double paf = pa[lp_half_order+1] + pa[lp_half_order];
+ double qaf = qa[lp_half_order+1] - qa[lp_half_order];
- lpc[i ] = 0.5*(paf+qaf);
- lpc[9-i] = 0.5*(paf-qaf);
+ lpc [ lp_half_order] = 0.5*(paf+qaf);
+ lpc2[-lp_half_order] = 0.5*(paf-qaf);
}
}
diff --git a/libavcodec/lsp.h b/libavcodec/lsp.h
index 9aee5fad7d..7201d5015b 100644
--- a/libavcodec/lsp.h
+++ b/libavcodec/lsp.h
@@ -86,8 +86,10 @@ void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd
* @param lsp line spectral pairs in cosine domain
* @param lpc linear predictive coding coefficients
*
+ * @note buffers should have a minimux size of 2*lp_half_order elements.
+ *
* TIA/EIA/IS-733 2.4.3.3.5
*/
-void ff_acelp_lspd2lpc(const double *lsp, float *lpc);
+void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order);
#endif /* AVCODEC_LSP_H */
diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c
index d655529c16..16f9ae0be9 100644
--- a/libavcodec/qcelpdec.c
+++ b/libavcodec/qcelpdec.c
@@ -578,7 +578,7 @@ static void lspf2lpc(const float *lspf, float *lpc)
for (i=0; i<10; i++)
lsp[i] = cos(M_PI * lspf[i]);
- ff_acelp_lspd2lpc(lsp, lpc);
+ ff_acelp_lspd2lpc(lsp, lpc, 5);
for (i=0; i<10; i++)
{