[SCM] libav/experimental: Avoid variable-length array use in ff_acelp_lspd2lpc()

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:54:18 UTC 2013


The following commit has been merged in the experimental branch:
commit 00fa73f052c1c0c0185ee4d2accb8fba065132f1
Author: Vitor Sessak <vitor1001 at gmail.com>
Date:   Tue Nov 10 04:17:18 2009 +0000

    Avoid variable-length array use in ff_acelp_lspd2lpc()
    
    Originally committed as revision 20496 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
index 4209216..ffd2410 100644
--- a/libavcodec/lsp.c
+++ b/libavcodec/lsp.c
@@ -157,9 +157,11 @@ static void lsp2polyf(const double *lsp, double *f, int lp_half_order)
 
 void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order)
 {
-    double pa[lp_half_order+1], qa[lp_half_order+1];
+    double pa[MAX_LP_HALF_ORDER+1], qa[MAX_LP_HALF_ORDER+1];
     float *lpc2 = lpc + (lp_half_order << 1) - 1;
 
+    assert(lp_half_order <= MAX_LP_HALF_ORDER);
+
     lsp2polyf(lsp,     pa, lp_half_order);
     lsp2polyf(lsp + 1, qa, lp_half_order);
 
diff --git a/libavcodec/lsp.h b/libavcodec/lsp.h
index 7201d50..18d9772 100644
--- a/libavcodec/lsp.h
+++ b/libavcodec/lsp.h
@@ -80,11 +80,16 @@ void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order);
  */
 void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order);
 
+
+#define MAX_LP_HALF_ORDER 8
+
 /**
  * Reconstructs LPC coefficients from the line spectral pair frequencies.
  *
  * @param lsp line spectral pairs in cosine domain
  * @param lpc linear predictive coding coefficients
+ * @param lp_half_order half the number of the amount of LPCs to be
+ *        reconstructed, need to be smaller or equal to MAX_LP_HALF_ORDER
  *
  * @note buffers should have a minimux size of 2*lp_half_order elements.
  *

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list