[FFmpeg-devel] [PATCH] add num arg to ff_acelp_lspd2lpc()

Ronald S. Bultje rsbultje
Mon Nov 9 16:31:50 CET 2009


Hi,

$attached. WMA Voice needs 16 instead of 10.

Ronald
-------------- next part --------------
Index: qcelpdec.c
===================================================================
--- qcelpdec.c	(revision 19703)
+++ qcelpdec.c	(working copy)
@@ -590,6 +590,7 @@
  *
  * @param lspf line spectral pair frequencies
  * @param lpc linear predictive coding coefficients
+ * @param num number of LSPs to convert (max. 16)
  *
  * @note: bandwidth_expansion_coeff could be precalculated into a table
  *        but it seems to be slower on x86
@@ -605,7 +606,7 @@
     for (i=0; i<10; i++)
         lsp[i] = cos(M_PI * lspf[i]);
 
-    ff_acelp_lspd2lpc(lsp, lpc);
+    ff_acelp_lspd2lpc(lsp, lpc, 10);
 
     for (i=0; i<10; i++)
     {
Index: lsp.c
===================================================================
--- lsp.c	(revision 19703)
+++ lsp.c	(working copy)
@@ -147,20 +147,22 @@
     }
 }
 
-void ff_acelp_lspd2lpc(const double *lsp, float *lpc)
+void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int num)
 {
-    double pa[6], qa[6];
-    int   i;
+    double pa[9], qa[9];
+    int   i, hnum = num / 2;
 
-    lsp2polyf(lsp,     pa, 5);
-    lsp2polyf(lsp + 1, qa, 5);
+    assert(num <= 16);
 
-    for (i=4; i>=0; i--)
+    lsp2polyf(lsp,     pa, hnum);
+    lsp2polyf(lsp + 1, qa, hnum);
+
+    for (i=hnum - 1; i>=0; i--)
     {
         double paf = pa[i+1] + pa[i];
         double qaf = qa[i+1] - qa[i];
 
-        lpc[i  ] = 0.5*(paf+qaf);
-        lpc[9-i] = 0.5*(paf-qaf);
+        lpc[i          ] = 0.5*(paf+qaf);
+        lpc[num - 1 - i] = 0.5*(paf-qaf);
     }
 }
Index: lsp.h
===================================================================
--- lsp.h	(revision 19703)
+++ lsp.h	(working copy)
@@ -72,9 +72,10 @@
  *
  * @param lsp line spectral pairs in cosine domain
  * @param lpc linear predictive coding coefficients
+ * @param num amount of LPCs to be reconstructed
  *
  * 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 num);
 
 #endif /* AVCODEC_LSP_H */



More information about the ffmpeg-devel mailing list