[FFmpeg-cvslog] pca: get rid of VLA

Michael Niedermayer git at videolan.org
Sat Oct 6 14:07:16 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Oct  6 14:03:15 2012 +0200| [24702a91e4f0455030d03b0489a3149ee6db01a4] | committer: Michael Niedermayer

pca: get rid of VLA

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=24702a91e4f0455030d03b0489a3149ee6db01a4
---

 libavutil/pca.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavutil/pca.c b/libavutil/pca.c
index 0839d68..54927a2 100644
--- a/libavutil/pca.c
+++ b/libavutil/pca.c
@@ -32,6 +32,7 @@ typedef struct PCA{
     int n;
     double *covariance;
     double *mean;
+    double *z;
 }PCA;
 
 PCA *ff_pca_init(int n){
@@ -41,6 +42,7 @@ PCA *ff_pca_init(int n){
 
     pca= av_mallocz(sizeof(PCA));
     pca->n= n;
+    pca->z = av_malloc(sizeof(*pca->z) * n);
     pca->count=0;
     pca->covariance= av_mallocz(sizeof(double)*n*n);
     pca->mean= av_mallocz(sizeof(double)*n);
@@ -51,6 +53,7 @@ PCA *ff_pca_init(int n){
 void ff_pca_free(PCA *pca){
     av_freep(&pca->covariance);
     av_freep(&pca->mean);
+    av_freep(&pca->z);
     av_free(pca);
 }
 
@@ -70,7 +73,7 @@ int ff_pca(PCA *pca, double *eigenvector, double *eigenvalue){
     int i, j, pass;
     int k=0;
     const int n= pca->n;
-    double z[n];
+    double *z = pca->z;
 
     memset(eigenvector, 0, sizeof(double)*n*n);
 



More information about the ffmpeg-cvslog mailing list