[FFmpeg-cvslog] ratecontrol: replace VLAs with malloc/free

Mans Rullgard git at videolan.org
Sat Oct 22 20:47:46 CEST 2011


ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Sun Jul  4 01:58:13 2010 +0100| [9c48a7cc525130e4a6426a10a697de8c3b1c5cbc] | committer: Michael Niedermayer

ratecontrol: replace VLAs with malloc/free
(cherry picked from commit 2c6bd7d1f992989d1cc108534e0896771b86824f)

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

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

 libavcodec/ratecontrol.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index 41b7d97..5919ea2 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -537,8 +537,8 @@ static void adaptive_quantization(MpegEncContext *s, double q){
     const float border_masking = s->avctx->border_masking;
     float bits_sum= 0.0;
     float cplx_sum= 0.0;
-    float cplx_tab[s->mb_num];
-    float bits_tab[s->mb_num];
+    float *cplx_tab = av_malloc(s->mb_num * sizeof(*cplx_tab));
+    float *bits_tab = av_malloc(s->mb_num * sizeof(*bits_tab));
     const int qmin= s->avctx->mb_lmin;
     const int qmax= s->avctx->mb_lmax;
     Picture * const pic= &s->current_picture;
@@ -639,6 +639,9 @@ static void adaptive_quantization(MpegEncContext *s, double q){
 //printf("%2d%3d ", intq, ff_sqrt(s->mc_mb_var[i]));
         s->lambda_table[mb_xy]= intq;
     }
+
+    av_free(cplx_tab);
+    av_free(bits_tab);
 }
 
 void ff_get_2pass_fcode(MpegEncContext *s){



More information about the ffmpeg-cvslog mailing list