Mercurial > libavcodec.hg
diff mpegvideo.c @ 2370:26560d4fdb1f libavcodec
Memory leak fix patch by (Burkhard Plaum <plaum >at< ipf.uni-stuttgart )dot( de>)
author | michael |
---|---|
date | Sat, 27 Nov 2004 18:10:06 +0000 |
parents | f8a229dfa2e8 |
children | 949f84ce470a |
line wrap: on
line diff
--- a/mpegvideo.c Sat Nov 27 03:54:18 2004 +0000 +++ b/mpegvideo.c Sat Nov 27 18:10:06 2004 +0000 @@ -1267,12 +1267,16 @@ #endif //CONFIG_ENCODERS -void init_rl(RLTable *rl) +void init_rl(RLTable *rl, int use_static) { int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1]; uint8_t index_run[MAX_RUN+1]; int last, run, level, start, end, i; + /* If table is static, we can quit if rl->max_level[0] is not NULL */ + if(use_static && rl->max_level[0]) + return; + /* compute max_level[], max_run[] and index_run[] */ for(last=0;last<2;last++) { if (last == 0) { @@ -1296,11 +1300,20 @@ if (run > max_run[level]) max_run[level] = run; } - rl->max_level[last] = av_malloc(MAX_RUN + 1); + if(use_static) + rl->max_level[last] = av_mallocz_static(MAX_RUN + 1); + else + rl->max_level[last] = av_malloc(MAX_RUN + 1); memcpy(rl->max_level[last], max_level, MAX_RUN + 1); - rl->max_run[last] = av_malloc(MAX_LEVEL + 1); + if(use_static) + rl->max_run[last] = av_mallocz_static(MAX_LEVEL + 1); + else + rl->max_run[last] = av_malloc(MAX_LEVEL + 1); memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1); - rl->index_run[last] = av_malloc(MAX_RUN + 1); + if(use_static) + rl->index_run[last] = av_mallocz_static(MAX_RUN + 1); + else + rl->index_run[last] = av_malloc(MAX_RUN + 1); memcpy(rl->index_run[last], index_run, MAX_RUN + 1); } }