Commit 9b888fb1 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/roqvideoenc: use av_malloc(z)_array()

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 591c0c26
...@@ -249,7 +249,7 @@ static void create_cel_evals(RoqContext *enc, RoqTempdata *tempData) ...@@ -249,7 +249,7 @@ static void create_cel_evals(RoqContext *enc, RoqTempdata *tempData)
{ {
int n=0, x, y, i; int n=0, x, y, i;
tempData->cel_evals = av_malloc(enc->width*enc->height/64 * sizeof(CelEvaluation)); tempData->cel_evals = av_malloc_array(enc->width*enc->height/64, sizeof(CelEvaluation));
/* Map to the ROQ quadtree order */ /* Map to the ROQ quadtree order */
for (y=0; y<enc->height; y+=16) for (y=0; y<enc->height; y+=16)
...@@ -799,11 +799,11 @@ static void generate_codebook(RoqContext *enc, RoqTempdata *tempdata, ...@@ -799,11 +799,11 @@ static void generate_codebook(RoqContext *enc, RoqTempdata *tempdata,
int i, j, k; int i, j, k;
int c_size = size*size/4; int c_size = size*size/4;
int *buf; int *buf;
int *codebook = av_malloc(6*c_size*cbsize*sizeof(int)); int *codebook = av_malloc_array(6*c_size, cbsize*sizeof(int));
int *closest_cb; int *closest_cb;
if (size == 4) if (size == 4)
closest_cb = av_malloc(6*c_size*inputCount*sizeof(int)); closest_cb = av_malloc_array(6*c_size, inputCount*sizeof(int));
else else
closest_cb = tempdata->closest_cb2; closest_cb = tempdata->closest_cb2;
...@@ -834,8 +834,8 @@ static void generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData) ...@@ -834,8 +834,8 @@ static void generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData)
int max = enc->width*enc->height/16; int max = enc->width*enc->height/16;
uint8_t mb2[3*4]; uint8_t mb2[3*4];
roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4); roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);
uint8_t *yuvClusters=av_malloc(sizeof(int)*max*6*4); uint8_t *yuvClusters=av_malloc_array(max, sizeof(int)*6*4);
int *points = av_malloc(max*6*4*sizeof(int)); int *points = av_malloc_array(max, 6*4*sizeof(int));
int bias; int bias;
/* Subsample YUV data */ /* Subsample YUV data */
...@@ -852,7 +852,7 @@ static void generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData) ...@@ -852,7 +852,7 @@ static void generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData)
codebooks->numCB4 = (enc->quake3_compat ? MAX_CBS_4x4-1 : MAX_CBS_4x4); codebooks->numCB4 = (enc->quake3_compat ? MAX_CBS_4x4-1 : MAX_CBS_4x4);
tempData->closest_cb2 = av_malloc(max*4*sizeof(int)); tempData->closest_cb2 = av_malloc_array(max, 4*sizeof(int));
/* Create 2x2 codebooks */ /* Create 2x2 codebooks */
generate_codebook(enc, tempData, points, max*4, enc->cb2x2, 2, MAX_CBS_2x2); generate_codebook(enc, tempData, points, max*4, enc->cb2x2, 2, MAX_CBS_2x2);
...@@ -985,16 +985,16 @@ static av_cold int roq_encode_init(AVCodecContext *avctx) ...@@ -985,16 +985,16 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
enc->tmpData = av_malloc(sizeof(RoqTempdata)); enc->tmpData = av_malloc(sizeof(RoqTempdata));
enc->this_motion4 = enc->this_motion4 =
av_mallocz((enc->width*enc->height/16)*sizeof(motion_vect)); av_mallocz_array((enc->width*enc->height/16), sizeof(motion_vect));
enc->last_motion4 = enc->last_motion4 =
av_malloc ((enc->width*enc->height/16)*sizeof(motion_vect)); av_malloc_array ((enc->width*enc->height/16), sizeof(motion_vect));
enc->this_motion8 = enc->this_motion8 =
av_mallocz((enc->width*enc->height/64)*sizeof(motion_vect)); av_mallocz_array((enc->width*enc->height/64), sizeof(motion_vect));
enc->last_motion8 = enc->last_motion8 =
av_malloc ((enc->width*enc->height/64)*sizeof(motion_vect)); av_malloc_array ((enc->width*enc->height/64), sizeof(motion_vect));
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment