comparison 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
comparison
equal deleted inserted replaced
2369:ce47b1d51cb1 2370:26560d4fdb1f
1265 return 0; 1265 return 0;
1266 } 1266 }
1267 1267
1268 #endif //CONFIG_ENCODERS 1268 #endif //CONFIG_ENCODERS
1269 1269
1270 void init_rl(RLTable *rl) 1270 void init_rl(RLTable *rl, int use_static)
1271 { 1271 {
1272 int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1]; 1272 int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1];
1273 uint8_t index_run[MAX_RUN+1]; 1273 uint8_t index_run[MAX_RUN+1];
1274 int last, run, level, start, end, i; 1274 int last, run, level, start, end, i;
1275
1276 /* If table is static, we can quit if rl->max_level[0] is not NULL */
1277 if(use_static && rl->max_level[0])
1278 return;
1275 1279
1276 /* compute max_level[], max_run[] and index_run[] */ 1280 /* compute max_level[], max_run[] and index_run[] */
1277 for(last=0;last<2;last++) { 1281 for(last=0;last<2;last++) {
1278 if (last == 0) { 1282 if (last == 0) {
1279 start = 0; 1283 start = 0;
1294 if (level > max_level[run]) 1298 if (level > max_level[run])
1295 max_level[run] = level; 1299 max_level[run] = level;
1296 if (run > max_run[level]) 1300 if (run > max_run[level])
1297 max_run[level] = run; 1301 max_run[level] = run;
1298 } 1302 }
1299 rl->max_level[last] = av_malloc(MAX_RUN + 1); 1303 if(use_static)
1304 rl->max_level[last] = av_mallocz_static(MAX_RUN + 1);
1305 else
1306 rl->max_level[last] = av_malloc(MAX_RUN + 1);
1300 memcpy(rl->max_level[last], max_level, MAX_RUN + 1); 1307 memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
1301 rl->max_run[last] = av_malloc(MAX_LEVEL + 1); 1308 if(use_static)
1309 rl->max_run[last] = av_mallocz_static(MAX_LEVEL + 1);
1310 else
1311 rl->max_run[last] = av_malloc(MAX_LEVEL + 1);
1302 memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1); 1312 memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
1303 rl->index_run[last] = av_malloc(MAX_RUN + 1); 1313 if(use_static)
1314 rl->index_run[last] = av_mallocz_static(MAX_RUN + 1);
1315 else
1316 rl->index_run[last] = av_malloc(MAX_RUN + 1);
1304 memcpy(rl->index_run[last], index_run, MAX_RUN + 1); 1317 memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
1305 } 1318 }
1306 } 1319 }
1307 1320
1308 /* draw the edges of width 'w' of an image of size width, height */ 1321 /* draw the edges of width 'w' of an image of size width, height */