[FFmpeg-devel] [PATCH] huffyuv: make VLAs fixed size

Måns Rullgård mans
Fri Jun 25 20:33:21 CEST 2010


Michael Niedermayer <michaelni at gmx.at> writes:

> On Fri, Jun 25, 2010 at 02:54:43AM +0100, Mans Rullgard wrote:
>> ---
>>  libavcodec/huffyuv.c |    6 +++---
>>  1 files changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
>> index 7764c35..f5125b6 100644
>> --- a/libavcodec/huffyuv.c
>> +++ b/libavcodec/huffyuv.c
>> @@ -232,9 +232,9 @@ static void heap_sift(HeapElem *h, int root, int size)
>>  }
>>  
>>  static void generate_len_table(uint8_t *dst, const uint64_t *stats, int size){
>> -    HeapElem h[size];
>> -    int up[2*size];
>> -    int len[2*size];
>> +    HeapElem h[256];
>> +    int up[2*256];
>> +    int len[2*256];
>
> ok

Applied.

> and the int size probably should be removed as its always 256 and
> this will likely not work if its >256

Like this?

diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index f5125b6..7541785 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -231,11 +231,12 @@ static void heap_sift(HeapElem *h, int root, int size)
     }
 }
 
-static void generate_len_table(uint8_t *dst, const uint64_t *stats, int size){
+static void generate_len_table(uint8_t *dst, const uint64_t *stats){
     HeapElem h[256];
     int up[2*256];
     int len[2*256];
     int offset, i, next;
+    int size = 256;
 
     for(offset=1; ; offset<<=1){
         for(i=0; i<size; i++){
@@ -646,7 +647,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
     }
 
     for(i=0; i<3; i++){
-        generate_len_table(s->len[i], s->stats[i], 256);
+        generate_len_table(s->len[i], s->stats[i]);
 
         if(generate_bits_table(s->bits[i], s->len[i])<0){
             return -1;
@@ -1224,7 +1225,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
 
     if(s->context){
         for(i=0; i<3; i++){
-            generate_len_table(s->len[i], s->stats[i], 256);
+            generate_len_table(s->len[i], s->stats[i]);
             if(generate_bits_table(s->bits[i], s->len[i])<0)
                 return -1;
             size+= store_table(s, s->len[i], &buf[size]);


-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list