[FFmpeg-cvslog] r20485 - in trunk/libavcodec: lsp.c lsp.h qcelpdec.c
vitor
subversion
Mon Nov 9 13:06:19 CET 2009
Author: vitor
Date: Mon Nov 9 13:06:19 2009
New Revision: 20485
Log:
Do not hardcode filter order in ff_acelp_lspd2lpc()
Modified:
trunk/libavcodec/lsp.c
trunk/libavcodec/lsp.h
trunk/libavcodec/qcelpdec.c
Modified: trunk/libavcodec/lsp.c
==============================================================================
--- trunk/libavcodec/lsp.c Mon Nov 9 10:11:35 2009 (r20484)
+++ trunk/libavcodec/lsp.c Mon Nov 9 13:06:19 2009 (r20485)
@@ -155,20 +155,19 @@ static void lsp2polyf(const double *lsp,
}
}
-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);
}
}
Modified: trunk/libavcodec/lsp.h
==============================================================================
--- trunk/libavcodec/lsp.h Mon Nov 9 10:11:35 2009 (r20484)
+++ trunk/libavcodec/lsp.h Mon Nov 9 13:06:19 2009 (r20485)
@@ -86,8 +86,10 @@ void ff_acelp_lp_decode(int16_t* lp_1st,
* @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 */
Modified: trunk/libavcodec/qcelpdec.c
==============================================================================
--- trunk/libavcodec/qcelpdec.c Mon Nov 9 10:11:35 2009 (r20484)
+++ trunk/libavcodec/qcelpdec.c Mon Nov 9 13:06:19 2009 (r20485)
@@ -578,7 +578,7 @@ static void lspf2lpc(const float *lspf,
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++)
{
More information about the ffmpeg-cvslog
mailing list