1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Replace all occurences of av_mallocz_array() by av_calloc()

They do the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2021-09-14 21:31:53 +02:00
parent 4b15474316
commit 1ea3650823
131 changed files with 302 additions and 301 deletions

View File

@ -42,7 +42,7 @@ static inline HMODULE win32_dlopen(const char *name)
DWORD pathlen;
if (utf8towchar(name, &name_w))
goto exit;
path = (wchar_t *)av_mallocz_array(MAX_PATH, sizeof(wchar_t));
path = (wchar_t *)av_calloc(MAX_PATH, sizeof(wchar_t));
// Try local directory first
pathlen = GetModuleFileNameW(NULL, path, MAX_PATH);
pathlen = wcsrchr(path, '\\') - path;

View File

@ -85,7 +85,7 @@ int main(int argc, char **argv)
}
stream_mapping_size = ifmt_ctx->nb_streams;
stream_mapping = av_mallocz_array(stream_mapping_size, sizeof(*stream_mapping));
stream_mapping = av_calloc(stream_mapping_size, sizeof(*stream_mapping));
if (!stream_mapping) {
ret = AVERROR(ENOMEM);
goto end;

View File

@ -72,7 +72,7 @@ static int open_input_file(const char *filename)
return ret;
}
stream_ctx = av_mallocz_array(ifmt_ctx->nb_streams, sizeof(*stream_ctx));
stream_ctx = av_calloc(ifmt_ctx->nb_streams, sizeof(*stream_ctx));
if (!stream_ctx)
return AVERROR(ENOMEM);

View File

@ -689,7 +689,7 @@ static void init_parse_context(OptionParseContext *octx,
memset(octx, 0, sizeof(*octx));
octx->nb_groups = nb_groups;
octx->groups = av_mallocz_array(octx->nb_groups, sizeof(*octx->groups));
octx->groups = av_calloc(octx->nb_groups, sizeof(*octx->groups));
if (!octx->groups)
exit_program(1);
@ -2168,7 +2168,7 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
if (!s->nb_streams)
return NULL;
opts = av_mallocz_array(s->nb_streams, sizeof(*opts));
opts = av_calloc(s->nb_streams, sizeof(*opts));
if (!opts) {
av_log(NULL, AV_LOG_ERROR,
"Could not alloc memory for stream options.\n");

View File

@ -2591,7 +2591,7 @@ loop_end:
count = 0;
while (ost->enc->pix_fmts[count] != AV_PIX_FMT_NONE)
count++;
f->formats = av_mallocz_array(count + 1, sizeof(*f->formats));
f->formats = av_calloc(count + 1, sizeof(*f->formats));
if (!f->formats)
exit_program(1);
memcpy(f->formats, ost->enc->pix_fmts, (count + 1) * sizeof(*f->formats));
@ -2604,7 +2604,7 @@ loop_end:
count = 0;
while (ost->enc->sample_fmts[count] != AV_SAMPLE_FMT_NONE)
count++;
f->formats = av_mallocz_array(count + 1, sizeof(*f->formats));
f->formats = av_calloc(count + 1, sizeof(*f->formats));
if (!f->formats)
exit_program(1);
memcpy(f->formats, ost->enc->sample_fmts, (count + 1) * sizeof(*f->formats));
@ -2615,7 +2615,7 @@ loop_end:
count = 0;
while (ost->enc->supported_samplerates[count])
count++;
f->sample_rates = av_mallocz_array(count + 1, sizeof(*f->sample_rates));
f->sample_rates = av_calloc(count + 1, sizeof(*f->sample_rates));
if (!f->sample_rates)
exit_program(1);
memcpy(f->sample_rates, ost->enc->supported_samplerates,
@ -2627,7 +2627,7 @@ loop_end:
count = 0;
while (ost->enc->channel_layouts[count])
count++;
f->channel_layouts = av_mallocz_array(count + 1, sizeof(*f->channel_layouts));
f->channel_layouts = av_calloc(count + 1, sizeof(*f->channel_layouts));
if (!f->channel_layouts)
exit_program(1);
memcpy(f->channel_layouts, ost->enc->channel_layouts,

View File

@ -3003,8 +3003,7 @@ static int open_input_file(InputFile *ifile, const char *filename,
av_dump_format(fmt_ctx, 0, filename, 0);
ifile->streams = av_mallocz_array(fmt_ctx->nb_streams,
sizeof(*ifile->streams));
ifile->streams = av_calloc(fmt_ctx->nb_streams, sizeof(*ifile->streams));
if (!ifile->streams)
exit(1);
ifile->nb_streams = fmt_ctx->nb_streams;

View File

@ -227,9 +227,9 @@ static av_cold int a64multi_encode_init(AVCodecContext *avctx)
a64_palette[mc_colors[a]][2] * 0.11;
}
if (!(c->mc_meta_charset = av_mallocz_array(c->mc_lifetime, 32000 * sizeof(int))) ||
if (!(c->mc_meta_charset = av_calloc(c->mc_lifetime, 32000 * sizeof(int))) ||
!(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) ||
!(c->mc_charmap = av_mallocz_array(c->mc_lifetime, 1000 * sizeof(int))) ||
!(c->mc_charmap = av_calloc(c->mc_lifetime, 1000 * sizeof(int))) ||
!(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t)))) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n");
return AVERROR(ENOMEM);

View File

@ -370,7 +370,7 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
}
}
pctx->ch = av_mallocz_array(ctx->avctx->channels, sizeof(AacPsyChannel));
pctx->ch = av_calloc(ctx->avctx->channels, sizeof(*pctx->ch));
if (!pctx->ch) {
av_freep(&ctx->model_priv_data);
return AVERROR(ENOMEM);

View File

@ -2059,7 +2059,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
ctx->shift_lsbs = av_malloc_array(num_buffers, sizeof(*ctx->shift_lsbs));
ctx->opt_order = av_malloc_array(num_buffers, sizeof(*ctx->opt_order));
ctx->store_prev_samples = av_malloc_array(num_buffers, sizeof(*ctx->store_prev_samples));
ctx->use_ltp = av_mallocz_array(num_buffers, sizeof(*ctx->use_ltp));
ctx->use_ltp = av_calloc(num_buffers, sizeof(*ctx->use_ltp));
ctx->ltp_lag = av_malloc_array(num_buffers, sizeof(*ctx->ltp_lag));
ctx->ltp_gain = av_malloc_array(num_buffers, sizeof(*ctx->ltp_gain));
ctx->ltp_gain_buffer = av_malloc_array(num_buffers * 5, sizeof(*ctx->ltp_gain_buffer));
@ -2078,10 +2078,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
// allocate and assign channel data buffer for mcc mode
if (sconf->mc_coding) {
ctx->chan_data_buffer = av_mallocz_array(num_buffers * num_buffers,
sizeof(*ctx->chan_data_buffer));
ctx->chan_data = av_mallocz_array(num_buffers,
sizeof(*ctx->chan_data));
ctx->chan_data_buffer = av_calloc(num_buffers * num_buffers,
sizeof(*ctx->chan_data_buffer));
ctx->chan_data = av_calloc(num_buffers, sizeof(*ctx->chan_data));
ctx->reverted_channels = av_malloc_array(num_buffers,
sizeof(*ctx->reverted_channels));
@ -2102,7 +2101,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
channel_size = sconf->frame_length + sconf->max_order;
ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples));
ctx->raw_buffer = av_mallocz_array(avctx->channels * channel_size, sizeof(*ctx->raw_buffer));
ctx->raw_buffer = av_calloc(avctx->channels * channel_size, sizeof(*ctx->raw_buffer));
ctx->raw_samples = av_malloc_array(avctx->channels, sizeof(*ctx->raw_samples));
if (sconf->floating) {
@ -2110,7 +2109,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
ctx->shift_value = av_malloc_array(avctx->channels, sizeof(*ctx->shift_value));
ctx->last_shift_value = av_malloc_array(avctx->channels, sizeof(*ctx->last_shift_value));
ctx->last_acf_mantissa = av_malloc_array(avctx->channels, sizeof(*ctx->last_acf_mantissa));
ctx->raw_mantissa = av_mallocz_array(avctx->channels, sizeof(*ctx->raw_mantissa));
ctx->raw_mantissa = av_calloc(avctx->channels, sizeof(*ctx->raw_mantissa));
ctx->larray = av_malloc_array(ctx->cur_frame_length * 4, sizeof(*ctx->larray));
ctx->nbits = av_malloc_array(ctx->cur_frame_length, sizeof(*ctx->nbits));
@ -2127,7 +2126,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
ff_mlz_flush_dict(ctx->mlz);
for (c = 0; c < avctx->channels; ++c) {
ctx->raw_mantissa[c] = av_mallocz_array(ctx->cur_frame_length, sizeof(**ctx->raw_mantissa));
ctx->raw_mantissa[c] = av_calloc(ctx->cur_frame_length, sizeof(**ctx->raw_mantissa));
}
}

View File

@ -1004,7 +1004,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
q->vector_fmul = fdsp->vector_fmul;
av_free(fdsp);
q->units = av_mallocz_array(avctx->channels, sizeof(*q->units));
q->units = av_calloc(avctx->channels, sizeof(*q->units));
if (!q->units)
return AVERROR(ENOMEM);

View File

@ -175,7 +175,7 @@ static av_cold int atrac3p_decode_init(AVCodecContext *avctx)
ctx->my_channel_layout = avctx->channel_layout;
ctx->ch_units = av_mallocz_array(ctx->num_channel_blocks, sizeof(*ctx->ch_units));
ctx->ch_units = av_calloc(ctx->num_channel_blocks, sizeof(*ctx->ch_units));
ctx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
if (!ctx->ch_units || !ctx->fdsp) {

View File

@ -762,16 +762,16 @@ int ff_cavs_init_top_lines(AVSContext *h)
{
/* alloc top line of predictors */
h->top_qp = av_mallocz(h->mb_width);
h->top_mv[0] = av_mallocz_array(h->mb_width * 2 + 1, sizeof(cavs_vector));
h->top_mv[1] = av_mallocz_array(h->mb_width * 2 + 1, sizeof(cavs_vector));
h->top_pred_Y = av_mallocz_array(h->mb_width * 2, sizeof(*h->top_pred_Y));
h->top_border_y = av_mallocz_array(h->mb_width + 1, 16);
h->top_border_u = av_mallocz_array(h->mb_width, 10);
h->top_border_v = av_mallocz_array(h->mb_width, 10);
h->top_mv[0] = av_calloc(h->mb_width * 2 + 1, sizeof(cavs_vector));
h->top_mv[1] = av_calloc(h->mb_width * 2 + 1, sizeof(cavs_vector));
h->top_pred_Y = av_calloc(h->mb_width * 2, sizeof(*h->top_pred_Y));
h->top_border_y = av_calloc(h->mb_width + 1, 16);
h->top_border_u = av_calloc(h->mb_width, 10);
h->top_border_v = av_calloc(h->mb_width, 10);
/* alloc space for co-located MVs and types */
h->col_mv = av_mallocz_array(h->mb_width * h->mb_height,
4 * sizeof(cavs_vector));
h->col_mv = av_calloc(h->mb_width * h->mb_height,
4 * sizeof(*h->col_mv));
h->col_type_base = av_mallocz(h->mb_width * h->mb_height);
h->block = av_mallocz(64 * sizeof(int16_t));

View File

@ -290,13 +290,13 @@ static int alloc_buffers(AVCodecContext *avctx)
if (s->transform_type == 0) {
s->plane[i].idwt_size = FFALIGN(height, 8) * stride;
s->plane[i].idwt_buf =
av_mallocz_array(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_buf));
av_calloc(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_buf));
s->plane[i].idwt_tmp =
av_malloc_array(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_tmp));
} else {
s->plane[i].idwt_size = FFALIGN(height, 8) * stride * 2;
s->plane[i].idwt_buf =
av_mallocz_array(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_buf));
av_calloc(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_buf));
s->plane[i].idwt_tmp =
av_malloc_array(s->plane[i].idwt_size, sizeof(*s->plane[i].idwt_tmp));
}

View File

@ -280,7 +280,7 @@ static av_cold int cfhd_encode_init(AVCodecContext *avctx)
h2 = h4 * 2;
s->plane[i].dwt_buf =
av_mallocz_array(height * stride, sizeof(*s->plane[i].dwt_buf));
av_calloc(height * stride, sizeof(*s->plane[i].dwt_buf));
s->plane[i].dwt_tmp =
av_malloc_array(height * stride, sizeof(*s->plane[i].dwt_tmp));
if (!s->plane[i].dwt_buf || !s->plane[i].dwt_tmp)

View File

@ -61,12 +61,12 @@ static av_cold int cng_decode_init(AVCodecContext *avctx)
p->order = 12;
avctx->frame_size = 640;
p->refl_coef = av_mallocz_array(p->order, sizeof(*p->refl_coef));
p->target_refl_coef = av_mallocz_array(p->order, sizeof(*p->target_refl_coef));
p->lpc_coef = av_mallocz_array(p->order, sizeof(*p->lpc_coef));
p->filter_out = av_mallocz_array(avctx->frame_size + p->order,
p->refl_coef = av_calloc(p->order, sizeof(*p->refl_coef));
p->target_refl_coef = av_calloc(p->order, sizeof(*p->target_refl_coef));
p->lpc_coef = av_calloc(p->order, sizeof(*p->lpc_coef));
p->filter_out = av_calloc(avctx->frame_size + p->order,
sizeof(*p->filter_out));
p->excitation = av_mallocz_array(avctx->frame_size, sizeof(*p->excitation));
p->excitation = av_calloc(avctx->frame_size, sizeof(*p->excitation));
if (!p->refl_coef || !p->target_refl_coef || !p->lpc_coef ||
!p->filter_out || !p->excitation) {
return AVERROR(ENOMEM);

View File

@ -1370,9 +1370,9 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
frame->linesize[0] = pool->linesize[0];
if (planes > AV_NUM_DATA_POINTERS) {
frame->extended_data = av_mallocz_array(planes, sizeof(*frame->extended_data));
frame->extended_data = av_calloc(planes, sizeof(*frame->extended_data));
frame->nb_extended_buf = planes - AV_NUM_DATA_POINTERS;
frame->extended_buf = av_mallocz_array(frame->nb_extended_buf,
frame->extended_buf = av_calloc(frame->nb_extended_buf,
sizeof(*frame->extended_buf));
if (!frame->extended_data || !frame->extended_buf) {
av_freep(&frame->extended_data);

View File

@ -304,7 +304,7 @@ static int alloc_sequence_buffers(DiracContext *s)
w = FFALIGN(CALC_PADDING(w, MAX_DWT_LEVELS), 8); /* FIXME: Should this be 16 for SSE??? */
h = top_padding + CALC_PADDING(h, MAX_DWT_LEVELS) + max_yblen/2;
s->plane[i].idwt.buf_base = av_mallocz_array((w+max_xblen), h * (2 << s->pshift));
s->plane[i].idwt.buf_base = av_calloc(w + max_xblen, h * (2 << s->pshift));
s->plane[i].idwt.tmp = av_malloc_array((w+16), 2 << s->pshift);
s->plane[i].idwt.buf = s->plane[i].idwt.buf_base + (top_padding*w)*(2 << s->pshift);
if (!s->plane[i].idwt.buf_base || !s->plane[i].idwt.tmp)

View File

@ -103,7 +103,7 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
avctx->coded_width = FFALIGN(avctx->width, 16);
avctx->coded_height = FFALIGN(avctx->height, 16);
ctx->rows = av_mallocz_array(avctx->thread_count, sizeof(RowContext));
ctx->rows = av_calloc(avctx->thread_count, sizeof(*ctx->rows));
if (!ctx->rows)
return AVERROR(ENOMEM);

View File

@ -764,7 +764,7 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou
}
if (sub->num_rects > 0) {
sub->rects = av_mallocz_array(sizeof(*sub->rects), sub->num_rects);
sub->rects = av_calloc(sub->num_rects, sizeof(*sub->rects));
if (!sub->rects) {
ret = AVERROR(ENOMEM);
goto fail;

View File

@ -515,7 +515,7 @@ static int d3d11va_create_decoder(AVCodecContext *avctx)
if (ret < 0)
return AVERROR(EINVAL);
sctx->d3d11_views = av_mallocz_array(texdesc.ArraySize, sizeof(sctx->d3d11_views[0]));
sctx->d3d11_views = av_calloc(texdesc.ArraySize, sizeof(sctx->d3d11_views[0]));
if (!sctx->d3d11_views)
return AVERROR(ENOMEM);
sctx->nb_d3d11_views = texdesc.ArraySize;

View File

@ -2253,7 +2253,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
}
// allocate thread data, used for non EXR_RAW compression types
s->thread_data = av_mallocz_array(avctx->thread_count, sizeof(EXRThreadData));
s->thread_data = av_calloc(avctx->thread_count, sizeof(*s->thread_data));
if (!s->thread_data)
return AVERROR(ENOMEM);

View File

@ -80,7 +80,7 @@ av_cold int ff_ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
return AVERROR(ENOMEM);
} else {
if (!p->vlc_state) {
p->vlc_state = av_mallocz_array(p->context_count, sizeof(VlcState));
p->vlc_state = av_calloc(p->context_count, sizeof(*p->vlc_state));
if (!p->vlc_state)
return AVERROR(ENOMEM);
for (i = 0; i < p->context_count; i++) {

View File

@ -1164,7 +1164,7 @@ static int g2m_init_buffers(G2MContext *c)
c->framebuf_stride = FFALIGN(c->width + 15, 16) * 3;
aligned_height = c->height + 15;
av_free(c->framebuf);
c->framebuf = av_mallocz_array(c->framebuf_stride, aligned_height);
c->framebuf = av_calloc(c->framebuf_stride, aligned_height);
if (!c->framebuf)
return AVERROR(ENOMEM);
}

View File

@ -314,7 +314,7 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
ff_h264_sei_uninit(&h->sei);
h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? avctx->thread_count : 1;
h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));
h->slice_ctx = av_calloc(h->nb_slice_ctx, sizeof(*h->slice_ctx));
if (!h->slice_ctx) {
h->nb_slice_ctx = 0;
return AVERROR(ENOMEM);

View File

@ -99,8 +99,8 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
s->bs_width = (width >> 2) + 1;
s->bs_height = (height >> 2) + 1;
s->sao = av_mallocz_array(ctb_count, sizeof(*s->sao));
s->deblock = av_mallocz_array(ctb_count, sizeof(*s->deblock));
s->sao = av_calloc(ctb_count, sizeof(*s->sao));
s->deblock = av_calloc(ctb_count, sizeof(*s->deblock));
if (!s->sao || !s->deblock)
goto fail;
@ -123,8 +123,8 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
if (!s->qp_y_tab || !s->filter_slice_edges || !s->tab_slice_address)
goto fail;
s->horizontal_bs = av_mallocz_array(s->bs_width, s->bs_height);
s->vertical_bs = av_mallocz_array(s->bs_width, s->bs_height);
s->horizontal_bs = av_calloc(s->bs_width, s->bs_height);
s->vertical_bs = av_calloc(s->bs_width, s->bs_height);
if (!s->horizontal_bs || !s->vertical_bs)
goto fail;

View File

@ -313,7 +313,7 @@ av_cold int ff_ivi_init_planes(AVCodecContext *avctx, IVIPlaneDesc *planes, cons
planes[1].num_bands = planes[2].num_bands = cfg->chroma_bands;
for (p = 0; p < 3; p++) {
planes[p].bands = av_mallocz_array(planes[p].num_bands, sizeof(IVIBandDesc));
planes[p].bands = av_calloc(planes[p].num_bands, sizeof(*planes[p].bands));
if (!planes[p].bands)
return AVERROR(ENOMEM);
@ -372,7 +372,7 @@ static int ivi_init_tiles(const IVIBandDesc *band, IVITile *ref_tile,
band->mb_size);
av_freep(&tile->mbs);
tile->mbs = av_mallocz_array(tile->num_MBs, sizeof(IVIMbInfo));
tile->mbs = av_calloc(tile->num_MBs, sizeof(*tile->mbs));
if (!tile->mbs)
return AVERROR(ENOMEM);
@ -428,7 +428,7 @@ av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes,
band->num_tiles = x_tiles * y_tiles;
av_freep(&band->tiles);
band->tiles = av_mallocz_array(band->num_tiles, sizeof(IVITile));
band->tiles = av_calloc(band->num_tiles, sizeof(*band->tiles));
if (!band->tiles) {
band->num_tiles = 0;
return AVERROR(ENOMEM);

View File

@ -468,11 +468,11 @@ static int init_tiles(Jpeg2000EncoderContext *s)
for (tilex = 0; tilex < s->numXtiles; tilex++, tileno++){
Jpeg2000Tile *tile = s->tile + tileno;
tile->comp = av_mallocz_array(s->ncomponents, sizeof(Jpeg2000Component));
tile->comp = av_calloc(s->ncomponents, sizeof(*tile->comp));
if (!tile->comp)
return AVERROR(ENOMEM);
tile->layer_rates = av_mallocz_array(s->nlayers, sizeof(*tile->layer_rates));
tile->layer_rates = av_calloc(s->nlayers, sizeof(*tile->layer_rates));
if (!tile->layer_rates)
return AVERROR(ENOMEM);

View File

@ -60,7 +60,7 @@ static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int h)
tt_size = tag_tree_size(w, h);
t = res = av_mallocz_array(tt_size, sizeof(*t));
t = res = av_calloc(tt_size, sizeof(*t));
if (!res)
return NULL;
@ -333,7 +333,7 @@ static int init_prec(AVCodecContext *avctx,
return AVERROR(ENOMEM);
}
nb_codeblocks = prec->nb_codeblocks_width * prec->nb_codeblocks_height;
prec->cblk = av_mallocz_array(nb_codeblocks, sizeof(*prec->cblk));
prec->cblk = av_calloc(nb_codeblocks, sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < nb_codeblocks; cblkno++) {
@ -376,7 +376,7 @@ static int init_prec(AVCodecContext *avctx,
cblk->length = 0;
cblk->npasses = 0;
if (av_codec_is_encoder(avctx->codec)) {
cblk->layers = av_mallocz_array(codsty->nlayers, sizeof(*cblk->layers));
cblk->layers = av_calloc(codsty->nlayers, sizeof(*cblk->layers));
if (!cblk->layers)
return AVERROR(ENOMEM);
}
@ -448,7 +448,7 @@ static int init_band(AVCodecContext *avctx,
return AVERROR(ENOMEM);
}
nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
band->prec = av_mallocz_array(nb_precincts, sizeof(*band->prec));
band->prec = av_calloc(nb_precincts, sizeof(*band->prec));
if (!band->prec)
return AVERROR(ENOMEM);
@ -496,17 +496,17 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
if (codsty->transform == FF_DWT97) {
csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->f_data);
comp->i_data = NULL;
comp->f_data = av_mallocz_array(csize, sizeof(*comp->f_data));
comp->f_data = av_calloc(csize, sizeof(*comp->f_data));
if (!comp->f_data)
return AVERROR(ENOMEM);
} else {
csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->i_data);
comp->f_data = NULL;
comp->i_data = av_mallocz_array(csize, sizeof(*comp->i_data));
comp->i_data = av_calloc(csize, sizeof(*comp->i_data));
if (!comp->i_data)
return AVERROR(ENOMEM);
}
comp->reslevel = av_mallocz_array(codsty->nreslevels, sizeof(*comp->reslevel));
comp->reslevel = av_calloc(codsty->nreslevels, sizeof(*comp->reslevel));
if (!comp->reslevel)
return AVERROR(ENOMEM);
/* LOOP on resolution levels */
@ -554,7 +554,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
reslevel->log2_prec_height) -
(reslevel->coord[1][0] >> reslevel->log2_prec_height);
reslevel->band = av_mallocz_array(reslevel->nbands, sizeof(*reslevel->band));
reslevel->band = av_calloc(reslevel->nbands, sizeof(*reslevel->band));
if (!reslevel->band)
return AVERROR(ENOMEM);

View File

@ -361,7 +361,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
return AVERROR(EINVAL);
}
s->tile = av_mallocz_array(s->numXtiles * s->numYtiles, sizeof(*s->tile));
s->tile = av_calloc(s->numXtiles * s->numYtiles, sizeof(*s->tile));
if (!s->tile) {
s->numXtiles = s->numYtiles = 0;
return AVERROR(ENOMEM);
@ -1176,7 +1176,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
cblk->nb_lengthinc = 0;
cblk->nb_terminationsinc = 0;
av_free(cblk->lengthinc);
cblk->lengthinc = av_mallocz_array(newpasses , sizeof(*cblk->lengthinc));
cblk->lengthinc = av_calloc(newpasses, sizeof(*cblk->lengthinc));
if (!cblk->lengthinc)
return AVERROR(ENOMEM);
tmp = av_realloc_array(cblk->data_start, cblk->nb_terminations + newpasses + 1, sizeof(*cblk->data_start));

View File

@ -249,7 +249,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
if (frame) {
if (frame->nb_samples < avctx->frame_size) {
flush_buf = av_mallocz_array(avctx->frame_size, sizeof(*flush_buf));
flush_buf = av_calloc(avctx->frame_size, sizeof(*flush_buf));
if (!flush_buf)
return AVERROR(ENOMEM);
memcpy(flush_buf, samples, frame->nb_samples * sizeof(*flush_buf));
@ -264,7 +264,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
} else {
if (s->enc_last_frame < 0)
return 0;
flush_buf = av_mallocz_array(avctx->frame_size, sizeof(*flush_buf));
flush_buf = av_calloc(avctx->frame_size, sizeof(*flush_buf));
if (!flush_buf)
return AVERROR(ENOMEM);
samples = flush_buf;

View File

@ -409,7 +409,7 @@ static av_cold int libopus_encode_init(AVCodecContext *avctx)
}
avctx->extradata_size = header_size;
opus->samples = av_mallocz_array(frame_size, avctx->channels *
opus->samples = av_calloc(frame_size, avctx->channels *
av_get_bytes_per_sample(avctx->sample_fmt));
if (!opus->samples) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate samples buffer.\n");

View File

@ -1492,7 +1492,7 @@ static int set_roi_map(AVCodecContext *avctx, const AVFrameSideData *sd, int fra
roi_map->rows = (frame_height + block_size - 1) / block_size;
roi_map->cols = (frame_width + block_size - 1) / block_size;
roi_map->roi_map = av_mallocz_array(roi_map->rows * roi_map->cols, sizeof(*roi_map->roi_map));
roi_map->roi_map = av_calloc(roi_map->rows * roi_map->cols, sizeof(*roi_map->roi_map));
if (!roi_map->roi_map) {
av_log(avctx, AV_LOG_ERROR, "roi_map alloc failed.\n");
return AVERROR(ENOMEM);

View File

@ -397,7 +397,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
}
nb_rois = sd->size / roi_size;
qoffsets = av_mallocz_array(mbx * mby, sizeof(*qoffsets));
qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets));
if (!qoffsets)
return AVERROR(ENOMEM);

View File

@ -460,7 +460,7 @@ static av_cold int libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr
}
nb_rois = sd->size / roi_size;
qoffsets = av_mallocz_array(mbx * mby, sizeof(*qoffsets));
qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets));
if (!qoffsets)
return AVERROR(ENOMEM);

View File

@ -347,7 +347,7 @@ static av_cold int XAVS_init(AVCodecContext *avctx)
if (!x4->enc)
return AVERROR_EXTERNAL;
if (!(x4->pts_buffer = av_mallocz_array((avctx->max_b_frames+1), sizeof(*x4->pts_buffer))))
if (!FF_ALLOCZ_TYPED_ARRAY(x4->pts_buffer, avctx->max_b_frames + 1))
return AVERROR(ENOMEM);
/* TAG: Do we have GLOBAL HEADER in AVS */

View File

@ -762,8 +762,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
int size = bw * bh * s->h_count[i] * s->v_count[i];
av_freep(&s->blocks[i]);
av_freep(&s->last_nnz[i]);
s->blocks[i] = av_mallocz_array(size, sizeof(**s->blocks));
s->last_nnz[i] = av_mallocz_array(size, sizeof(**s->last_nnz));
s->blocks[i] = av_calloc(size, sizeof(**s->blocks));
s->last_nnz[i] = av_calloc(size, sizeof(**s->last_nnz));
if (!s->blocks[i] || !s->last_nnz[i])
return AVERROR(ENOMEM);
s->block_stride[i] = bw * s->h_count[i];

View File

@ -21,7 +21,7 @@
#include "mlz.h"
av_cold void ff_mlz_init_dict(void* context, MLZ *mlz) {
mlz->dict = av_mallocz_array(TABLE_SIZE, sizeof(*mlz->dict));
mlz->dict = av_mallocz(TABLE_SIZE * sizeof(*mlz->dict));
mlz->flush_code = FLUSH_CODE;
mlz->current_dic_index_max = DIC_INDEX_INIT;

View File

@ -80,10 +80,10 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
mp->avctx = avctx;
ff_bswapdsp_init(&mp->bdsp);
mp->changes_map = av_mallocz_array(avctx->width, h4);
mp->changes_map = av_calloc(avctx->width, h4);
mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1;
mp->vpt = av_mallocz_array(avctx->height, sizeof(YuvPixel));
mp->hpt = av_mallocz_array(h4 / 4, w4 / 4 * sizeof(YuvPixel));
mp->vpt = av_calloc(avctx->height, sizeof(*mp->vpt));
mp->hpt = av_calloc(h4 / 4, w4 / 4 * sizeof(*mp->hpt));
if (!mp->changes_map || !mp->vpt || !mp->hpt)
return AVERROR(ENOMEM);
avctx->pix_fmt = AV_PIX_FMT_RGB555;

View File

@ -1578,7 +1578,7 @@ static av_cold int nvenc_setup_surfaces(AVCodecContext *avctx)
NvencContext *ctx = avctx->priv_data;
int i, res = 0, res2;
ctx->surfaces = av_mallocz_array(ctx->nb_surfaces, sizeof(*ctx->surfaces));
ctx->surfaces = av_calloc(ctx->nb_surfaces, sizeof(*ctx->surfaces));
if (!ctx->surfaces)
return AVERROR(ENOMEM);

View File

@ -360,7 +360,7 @@ static av_cold int find_component(OMXContext *omx_context, void *logctx,
av_log(logctx, AV_LOG_WARNING, "No component for role %s found\n", role);
return AVERROR_ENCODER_NOT_FOUND;
}
components = av_mallocz_array(num, sizeof(*components));
components = av_calloc(num, sizeof(*components));
if (!components)
return AVERROR(ENOMEM);
for (i = 0; i < num; i++) {

View File

@ -400,7 +400,7 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
return AVERROR_PATCHWELCOME;
}
s->channel_maps = av_mallocz_array(channels, sizeof(*s->channel_maps));
s->channel_maps = av_calloc(channels, sizeof(*s->channel_maps));
if (!s->channel_maps)
return AVERROR(ENOMEM);

View File

@ -634,7 +634,7 @@ static av_cold int opus_decode_init(AVCodecContext *avctx)
return ret;
/* allocate and init each independent decoder */
c->streams = av_mallocz_array(c->nb_streams, sizeof(*c->streams));
c->streams = av_calloc(c->nb_streams, sizeof(*c->streams));
if (!c->streams) {
c->nb_streams = 0;
return AVERROR(ENOMEM);

View File

@ -518,7 +518,7 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
// Blank if last object_count was 0.
if (!ctx->presentation.object_count)
return 1;
sub->rects = av_mallocz_array(ctx->presentation.object_count, sizeof(*sub->rects));
sub->rects = av_calloc(ctx->presentation.object_count, sizeof(*sub->rects));
if (!sub->rects) {
return AVERROR(ENOMEM);
}

View File

@ -40,7 +40,7 @@ static const uint8_t ff_png_pass_xshift[NB_PASSES] = {
void *ff_png_zalloc(void *opaque, unsigned int items, unsigned int size)
{
return av_mallocz_array(items, size);
return av_calloc(items, size);
}
void ff_png_zfree(void *opaque, void *ptr)

View File

@ -340,7 +340,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons
if (ctx->slice_count != slice_count || !ctx->slices) {
av_freep(&ctx->slices);
ctx->slice_count = 0;
ctx->slices = av_mallocz_array(slice_count, sizeof(*ctx->slices));
ctx->slices = av_calloc(slice_count, sizeof(*ctx->slices));
if (!ctx->slices)
return AVERROR(ENOMEM);
ctx->slice_count = slice_count;

View File

@ -35,8 +35,8 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
int i, j, k = 0;
ctx->avctx = avctx;
ctx->ch = av_mallocz_array(sizeof(ctx->ch[0]), avctx->channels * 2);
ctx->group = av_mallocz_array(sizeof(ctx->group[0]), num_groups);
ctx->ch = av_calloc(avctx->channels, 2 * sizeof(ctx->ch[0]));
ctx->group = av_calloc(num_groups, sizeof(ctx->group[0]));
ctx->bands = av_malloc_array (sizeof(ctx->bands[0]), num_lens);
ctx->num_bands = av_malloc_array (sizeof(ctx->num_bands[0]), num_lens);
ctx->cutoff = avctx->cutoff;
@ -120,7 +120,7 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av
FF_FILTER_MODE_LOWPASS, FILT_ORDER,
cutoff_coeff, 0.0, 0.0);
if (ctx->fcoeffs) {
ctx->fstate = av_mallocz_array(sizeof(ctx->fstate[0]), avctx->channels);
ctx->fstate = av_calloc(avctx->channels, sizeof(ctx->fstate[0]));
if (!ctx->fstate) {
av_free(ctx->fcoeffs);
av_free(ctx);

View File

@ -878,7 +878,7 @@ int ff_frame_thread_init(AVCodecContext *avctx)
if (codec->type == AVMEDIA_TYPE_VIDEO)
avctx->delay = src->thread_count - 1;
fctx->threads = av_mallocz_array(thread_count, sizeof(PerThreadContext));
fctx->threads = av_calloc(thread_count, sizeof(*fctx->threads));
if (!fctx->threads) {
err = AVERROR(ENOMEM);
goto error;

View File

@ -211,7 +211,7 @@ int ff_alloc_entries(AVCodecContext *avctx, int count)
}
p->thread_count = avctx->thread_count;
p->entries = av_mallocz_array(count, sizeof(int));
p->entries = av_calloc(count, sizeof(*p->entries));
if (!p->progress_mutex) {
p->progress_mutex = av_malloc_array(p->thread_count, sizeof(pthread_mutex_t));

View File

@ -452,7 +452,7 @@ static AVBufferRef *qsv_create_mids(AVBufferRef *hw_frames_ref)
if (!hw_frames_ref1)
return NULL;
mids = av_mallocz_array(nb_surfaces, sizeof(*mids));
mids = av_calloc(nb_surfaces, sizeof(*mids));
if (!mids) {
av_buffer_unref(&hw_frames_ref1);
return NULL;
@ -487,7 +487,7 @@ static int qsv_setup_mids(mfxFrameAllocResponse *resp, AVBufferRef *hw_frames_re
// the allocated size of the array is two larger than the number of
// surfaces, we store the references to the frames context and the
// QSVMid array there
resp->mids = av_mallocz_array(nb_surfaces + 2, sizeof(*resp->mids));
resp->mids = av_calloc(nb_surfaces + 2, sizeof(*resp->mids));
if (!resp->mids)
return AVERROR(ENOMEM);

View File

@ -1181,8 +1181,8 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
AVQSVContext *qsv = avctx->hwaccel_context;
int i, j;
q->extparam = av_mallocz_array(qsv->nb_ext_buffers + q->nb_extparam_internal,
sizeof(*q->extparam));
q->extparam = av_calloc(qsv->nb_ext_buffers + q->nb_extparam_internal,
sizeof(*q->extparam));
if (!q->extparam)
return AVERROR(ENOMEM);

View File

@ -111,7 +111,7 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx)
s->rlecode_table = av_mallocz(s->logical_width);
s->skip_table = av_mallocz(s->logical_width);
s->length_table = av_mallocz_array(s->logical_width + 1, sizeof(int));
s->length_table = av_calloc(s->logical_width + 1, sizeof(*s->length_table));
if (!s->skip_table || !s->length_table || !s->rlecode_table) {
av_log(avctx, AV_LOG_ERROR, "Error allocating memory.\n");
return AVERROR(ENOMEM);

View File

@ -1003,13 +1003,13 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
enc->this_motion4 =
av_mallocz_array(roq->width * roq->height / 16, sizeof(motion_vect));
av_calloc(roq->width * roq->height / 16, sizeof(*enc->this_motion4));
enc->last_motion4 =
av_malloc_array (roq->width * roq->height / 16, sizeof(motion_vect));
enc->this_motion8 =
av_mallocz_array(roq->width * roq->height / 64, sizeof(motion_vect));
av_calloc(roq->width * roq->height / 64, sizeof(*enc->this_motion8));
enc->last_motion8 =
av_malloc_array (roq->width * roq->height / 64, sizeof(motion_vect));

View File

@ -116,7 +116,7 @@ int ff_snow_alloc_blocks(SnowContext *s){
s->b_height= h;
av_free(s->block);
s->block= av_mallocz_array(w * h, sizeof(BlockNode) << (s->block_max_depth*2));
s->block = av_calloc(w * h, sizeof(*s->block) << (s->block_max_depth*2));
if (!s->block)
return AVERROR(ENOMEM);
@ -567,7 +567,8 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) {
b->parent= &s->plane[plane_index].band[level-1][orientation];
//FIXME avoid this realloc
av_freep(&b->x_coeff);
b->x_coeff=av_mallocz_array(((b->width+1) * b->height+1), sizeof(x_and_coeff));
b->x_coeff = av_calloc((b->width + 1) * b->height + 1,
sizeof(*b->x_coeff));
if (!b->x_coeff)
return AVERROR(ENOMEM);
}

View File

@ -35,7 +35,7 @@ int ff_slice_buffer_init(slice_buffer *buf, int line_count,
buf->line_count = line_count;
buf->line_width = line_width;
buf->data_count = max_allocated_lines;
buf->line = av_mallocz_array(line_count, sizeof(IDWTELEM *));
buf->line = av_calloc(line_count, sizeof(*buf->line));
if (!buf->line)
return AVERROR(ENOMEM);
buf->data_stack = av_malloc_array(max_allocated_lines, sizeof(IDWTELEM *));

View File

@ -79,7 +79,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->m.mb_num = (avctx->width * avctx->height + 255) / 256; // For ratecontrol
s->m.me.temp =
s->m.me.scratchpad= av_mallocz_array((avctx->width+64), 2*16*2*sizeof(uint8_t));
s->m.me.scratchpad = av_calloc(avctx->width + 64, 2*16*2*sizeof(uint8_t));
s->m.me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.sc.obmc_scratchpad= av_mallocz(MB_SIZE*MB_SIZE*12*sizeof(uint32_t));
@ -145,8 +145,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
if(s->motion_est == FF_ME_ITER){
int size= s->b_width * s->b_height << 2*s->block_max_depth;
for(i=0; i<s->max_ref_frames; i++){
s->ref_mvs[i]= av_mallocz_array(size, sizeof(int16_t[2]));
s->ref_scores[i]= av_mallocz_array(size, sizeof(uint32_t));
s->ref_mvs[i] = av_calloc(size, sizeof(*s->ref_mvs[i]));
s->ref_scores[i] = av_calloc(size, sizeof(*s->ref_scores[i]));
if (!s->ref_mvs[i] || !s->ref_scores[i])
return AVERROR(ENOMEM);
}

View File

@ -1364,7 +1364,7 @@ static int get_buffer(AVCodecContext *avctx, SVQ3Frame *pic)
goto fail;
if (!s->edge_emu_buffer) {
s->edge_emu_buffer = av_mallocz_array(pic->f->linesize[0], 17);
s->edge_emu_buffer = av_calloc(pic->f->linesize[0], 17);
if (!s->edge_emu_buffer)
return AVERROR(ENOMEM);
}

View File

@ -37,8 +37,8 @@ int main(void){
s.spatial_decomposition_count=6;
s.spatial_decomposition_type=1;
s.temp_dwt_buffer = av_mallocz_array(width, sizeof(DWTELEM));
s.temp_idwt_buffer = av_mallocz_array(width, sizeof(IDWTELEM));
s.temp_dwt_buffer = av_calloc(width, sizeof(*s.temp_dwt_buffer));
s.temp_idwt_buffer = av_calloc(width, sizeof(*s.temp_idwt_buffer));
if (!s.temp_dwt_buffer || !s.temp_idwt_buffer) {
fprintf(stderr, "Failed to allocate memory\n");

View File

@ -1588,7 +1588,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
s->geotag_count = 0;
return -1;
}
s->geotags = av_mallocz_array(s->geotag_count, sizeof(TiffGeoTag));
s->geotags = av_calloc(s->geotag_count, sizeof(*s->geotags));
if (!s->geotags) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
s->geotag_count = 0;

View File

@ -107,7 +107,8 @@ static int allocate_buffers(AVCodecContext *avctx)
TTAContext *s = avctx->priv_data;
if (s->bps < 3) {
s->decode_buffer = av_mallocz_array(sizeof(int32_t)*s->frame_length, s->channels);
s->decode_buffer = av_calloc(s->frame_length,
sizeof(*s->decode_buffer) * s->channels);
if (!s->decode_buffer)
return AVERROR(ENOMEM);
} else

View File

@ -379,8 +379,7 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
planar = av_sample_fmt_is_planar(sample_fmt);
if (planar && nb_channels > AV_NUM_DATA_POINTERS) {
if (!(frame->extended_data = av_mallocz_array(nb_channels,
sizeof(*frame->extended_data))))
if (!FF_ALLOCZ_TYPED_ARRAY(frame->extended_data, nb_channels))
return AVERROR(ENOMEM);
} else {
frame->extended_data = frame->data;

View File

@ -429,7 +429,7 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
if (pic->nb_slices == 0)
pic->nb_slices = ctx->nb_slices;
if (pic->nb_slices > 0) {
pic->slices = av_mallocz_array(pic->nb_slices, sizeof(*pic->slices));
pic->slices = av_calloc(pic->nb_slices, sizeof(*pic->slices));
if (!pic->slices) {
err = AVERROR(ENOMEM);
goto fail;
@ -511,7 +511,7 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
nb_roi = ctx->roi_max_regions;
}
pic->roi = av_mallocz_array(nb_roi, sizeof(*pic->roi));
pic->roi = av_calloc(nb_roi, sizeof(*pic->roi));
if (!pic->roi) {
err = AVERROR(ENOMEM);
goto fail;

View File

@ -379,7 +379,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
// Weed out unused vlcs and build codevector vector
if (used_entries) {
codebook_setup->codevectors =
av_mallocz_array(used_entries, codebook_setup->dimensions *
av_calloc(used_entries, codebook_setup->dimensions *
sizeof(*codebook_setup->codevectors));
if (!codebook_setup->codevectors) {
ret = AVERROR(ENOMEM);
@ -567,7 +567,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
for (j = 0; j < floor_setup->data.t1.partitions; ++j)
floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];
floor_setup->data.t1.list = av_mallocz_array(floor_setup->data.t1.x_list_dim,
floor_setup->data.t1.list = av_calloc(floor_setup->data.t1.x_list_dim,
sizeof(*floor_setup->data.t1.list));
if (!floor_setup->data.t1.list)
return AVERROR(ENOMEM);
@ -823,7 +823,7 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
}
if (mapping_setup->submaps>1) {
mapping_setup->mux = av_mallocz_array(vc->audio_channels,
mapping_setup->mux = av_calloc(vc->audio_channels,
sizeof(*mapping_setup->mux));
if (!mapping_setup->mux)
return AVERROR(ENOMEM);
@ -1000,7 +1000,7 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
}
vc->channel_residues = av_malloc_array(vc->blocksize[1] / 2, vc->audio_channels * sizeof(*vc->channel_residues));
vc->saved = av_mallocz_array(vc->blocksize[1] / 4, vc->audio_channels * sizeof(*vc->saved));
vc->saved = av_calloc(vc->blocksize[1] / 4, vc->audio_channels * sizeof(*vc->saved));
if (!vc->channel_residues || !vc->saved)
return AVERROR(ENOMEM);

View File

@ -182,7 +182,7 @@ static int ready_codebook(vorbis_enc_codebook *cb)
} else {
int vals = cb_lookup_vals(cb->lookup, cb->ndimensions, cb->nentries);
cb->dimensions = av_malloc_array(cb->nentries, sizeof(float) * cb->ndimensions);
cb->pow2 = av_mallocz_array(cb->nentries, sizeof(float));
cb->pow2 = av_calloc(cb->nentries, sizeof(*cb->pow2));
if (!cb->dimensions || !cb->pow2)
return AVERROR(ENOMEM);
for (i = 0; i < cb->nentries; i++) {
@ -212,7 +212,7 @@ static int ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
{
int i;
av_assert0(rc->type == 2);
rc->maxes = av_mallocz_array(rc->classifications, sizeof(float[2]));
rc->maxes = av_calloc(rc->classifications, sizeof(*rc->maxes));
if (!rc->maxes)
return AVERROR(ENOMEM);
for (i = 0; i < rc->classifications; i++) {

View File

@ -2277,19 +2277,19 @@ static av_cold int allocate_tables(AVCodecContext *avctx)
/* superblock_coding is used by unpack_superblocks (VP3/Theora) and vp4_unpack_macroblocks (VP4) */
s->superblock_coding = av_mallocz(FFMAX(s->superblock_count, s->yuv_macroblock_count));
s->all_fragments = av_mallocz_array(s->fragment_count, sizeof(Vp3Fragment));
s->all_fragments = av_calloc(s->fragment_count, sizeof(*s->all_fragments));
s-> kf_coded_fragment_list = av_mallocz_array(s->fragment_count, sizeof(int));
s->nkf_coded_fragment_list = av_mallocz_array(s->fragment_count, sizeof(int));
s-> kf_coded_fragment_list = av_calloc(s->fragment_count, sizeof(int));
s->nkf_coded_fragment_list = av_calloc(s->fragment_count, sizeof(int));
memset(s-> num_kf_coded_fragment, -1, sizeof(s-> num_kf_coded_fragment));
s->dct_tokens_base = av_mallocz_array(s->fragment_count,
64 * sizeof(*s->dct_tokens_base));
s->motion_val[0] = av_mallocz_array(y_fragment_count, sizeof(*s->motion_val[0]));
s->motion_val[1] = av_mallocz_array(c_fragment_count, sizeof(*s->motion_val[1]));
s->dct_tokens_base = av_calloc(s->fragment_count,
64 * sizeof(*s->dct_tokens_base));
s->motion_val[0] = av_calloc(y_fragment_count, sizeof(*s->motion_val[0]));
s->motion_val[1] = av_calloc(c_fragment_count, sizeof(*s->motion_val[1]));
/* work out the block mapping tables */
s->superblock_fragments = av_mallocz_array(s->superblock_count, 16 * sizeof(int));
s->superblock_fragments = av_calloc(s->superblock_count, 16 * sizeof(int));
s->macroblock_coding = av_mallocz(s->macroblock_count + 1);
s->dc_pred_row = av_malloc_array(s->y_superblock_width * 4, sizeof(*s->dc_pred_row));

View File

@ -793,7 +793,7 @@ static int decode_frame_header(AVCodecContext *avctx,
} else {
n_range_coders = s->s.h.tiling.tile_cols;
}
s->td = av_mallocz_array(s->active_tile_cols, sizeof(VP9TileData) +
s->td = av_calloc(s->active_tile_cols, sizeof(VP9TileData) +
n_range_coders * sizeof(VP56RangeCoder));
if (!s->td)
return AVERROR(ENOMEM);

View File

@ -581,8 +581,8 @@ static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role,
img->color_cache_bits);
return AVERROR_INVALIDDATA;
}
img->color_cache = av_mallocz_array(1 << img->color_cache_bits,
sizeof(*img->color_cache));
img->color_cache = av_calloc(1 << img->color_cache_bits,
sizeof(*img->color_cache));
if (!img->color_cache)
return AVERROR(ENOMEM);
} else {
@ -596,9 +596,9 @@ static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role,
return ret;
img->nb_huffman_groups = s->nb_huffman_groups;
}
img->huffman_groups = av_mallocz_array(img->nb_huffman_groups *
HUFFMAN_CODES_PER_META_CODE,
sizeof(*img->huffman_groups));
img->huffman_groups = av_calloc(img->nb_huffman_groups,
HUFFMAN_CODES_PER_META_CODE *
sizeof(*img->huffman_groups));
if (!img->huffman_groups)
return AVERROR(ENOMEM);

View File

@ -257,7 +257,7 @@ static int config_output(AVFilterLink *outlink)
if (!s->frame_list)
return AVERROR(ENOMEM);
s->fifos = av_mallocz_array(s->nb_inputs, sizeof(*s->fifos));
s->fifos = av_calloc(s->nb_inputs, sizeof(*s->fifos));
if (!s->fifos)
return AVERROR(ENOMEM);
@ -274,8 +274,8 @@ static int config_output(AVFilterLink *outlink)
memset(s->input_state, INPUT_ON, s->nb_inputs);
s->active_inputs = s->nb_inputs;
s->input_scale = av_mallocz_array(s->nb_inputs, sizeof(*s->input_scale));
s->scale_norm = av_mallocz_array(s->nb_inputs, sizeof(*s->scale_norm));
s->input_scale = av_calloc(s->nb_inputs, sizeof(*s->input_scale));
s->scale_norm = av_calloc(s->nb_inputs, sizeof(*s->scale_norm));
if (!s->input_scale || !s->scale_norm)
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_inputs; i++)
@ -561,7 +561,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!s->fdsp)
return AVERROR(ENOMEM);
s->weights = av_mallocz_array(s->nb_inputs, sizeof(*s->weights));
s->weights = av_calloc(s->nb_inputs, sizeof(*s->weights));
if (!s->weights)
return AVERROR(ENOMEM);

View File

@ -310,7 +310,7 @@ static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)
if (nch_out > nch_in) {
if (nch_out > FF_ARRAY_ELEMS(buf->data)) {
uint8_t **new_extended_data =
av_mallocz_array(nch_out, sizeof(*buf->extended_data));
av_calloc(nch_out, sizeof(*buf->extended_data));
if (!new_extended_data) {
av_frame_free(&buf);
return AVERROR(ENOMEM);

View File

@ -344,9 +344,9 @@ static int config_output(AVFilterLink *outlink)
uninit(ctx);
s->channels = av_mallocz_array(channels, sizeof(*s->channels));
s->channels = av_calloc(channels, sizeof(*s->channels));
s->nb_segments = (nb_points + 4) * 2;
s->segments = av_mallocz_array(s->nb_segments, sizeof(*s->segments));
s->segments = av_calloc(s->nb_segments, sizeof(*s->segments));
if (!s->channels || !s->segments) {
uninit(ctx);

View File

@ -172,9 +172,9 @@ static av_cold int join_init(AVFilterContext *ctx)
}
s->nb_channels = av_get_channel_layout_nb_channels(s->channel_layout);
s->channels = av_mallocz_array(s->nb_channels, sizeof(*s->channels));
s->buffers = av_mallocz_array(s->nb_channels, sizeof(*s->buffers));
s->input_frames = av_mallocz_array(s->inputs, sizeof(*s->input_frames));
s->channels = av_calloc(s->nb_channels, sizeof(*s->channels));
s->buffers = av_calloc(s->nb_channels, sizeof(*s->buffers));
s->input_frames = av_calloc(s->inputs, sizeof(*s->input_frames));
if (!s->channels || !s->buffers|| !s->input_frames)
return AVERROR(ENOMEM);
@ -283,7 +283,7 @@ static int join_config_output(AVFilterLink *outlink)
int i, ret = 0;
/* initialize inputs to user-specified mappings */
if (!(inputs = av_mallocz_array(ctx->nb_inputs, sizeof(*inputs))))
if (!(inputs = av_calloc(ctx->nb_inputs, sizeof(*inputs))))
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_channels; i++) {
ChannelMap *ch = &s->channels[i];
@ -383,7 +383,7 @@ static int try_push_frame(AVFilterContext *ctx)
if (!frame)
return AVERROR(ENOMEM);
if (s->nb_channels > FF_ARRAY_ELEMS(frame->data)) {
frame->extended_data = av_mallocz_array(s->nb_channels,
frame->extended_data = av_calloc(s->nb_channels,
sizeof(*frame->extended_data));
if (!frame->extended_data) {
ret = AVERROR(ENOMEM);
@ -417,8 +417,8 @@ static int try_push_frame(AVFilterContext *ctx)
/* create references to the buffers we copied to output */
if (nb_buffers > FF_ARRAY_ELEMS(frame->buf)) {
frame->nb_extended_buf = nb_buffers - FF_ARRAY_ELEMS(frame->buf);
frame->extended_buf = av_mallocz_array(frame->nb_extended_buf,
sizeof(*frame->extended_buf));
frame->extended_buf = av_calloc(frame->nb_extended_buf,
sizeof(*frame->extended_buf));
if (!frame->extended_buf) {
frame->nb_extended_buf = 0;
ret = AVERROR(ENOMEM);

View File

@ -169,7 +169,8 @@ static int config_input(AVFilterLink *inlink)
s->channels = inlink->channels;
s->duration = av_rescale(s->duration, inlink->sample_rate, AV_TIME_BASE);
s->independent_channels = s->mono ? s->channels : 1;
s->nb_null_samples = av_mallocz_array(sizeof(*s->nb_null_samples), s->independent_channels);
s->nb_null_samples = av_calloc(s->independent_channels,
sizeof(*s->nb_null_samples));
if (!s->nb_null_samples)
return AVERROR(ENOMEM);
s->start = av_malloc_array(sizeof(*s->start), s->independent_channels);

View File

@ -427,7 +427,7 @@ static int config_output(AVFilterLink *outlink)
showwaves->n = FFMAX(1, av_rescale_q(inlink->sample_rate, av_make_q(1, showwaves->w), showwaves->rate));
showwaves->buf_idx = 0;
if (!(showwaves->buf_idy = av_mallocz_array(nb_channels, sizeof(*showwaves->buf_idy)))) {
if (!FF_ALLOCZ_TYPED_ARRAY(showwaves->buf_idy, nb_channels)) {
av_log(ctx, AV_LOG_ERROR, "Could not allocate showwaves buffer\n");
return AVERROR(ENOMEM);
}
@ -820,7 +820,7 @@ static int showwavespic_config_input(AVFilterLink *inlink)
ShowWavesContext *showwaves = ctx->priv;
if (showwaves->single_pic) {
showwaves->sum = av_mallocz_array(inlink->channels, sizeof(*showwaves->sum));
showwaves->sum = av_calloc(inlink->channels, sizeof(*showwaves->sum));
if (!showwaves->sum)
return AVERROR(ENOMEM);
}

View File

@ -702,7 +702,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
ret->input_pads = av_memdup(filter->inputs, ret->nb_inputs * sizeof(*filter->inputs));
if (!ret->input_pads)
goto err;
ret->inputs = av_mallocz_array(ret->nb_inputs, sizeof(AVFilterLink*));
ret->inputs = av_calloc(ret->nb_inputs, sizeof(*ret->inputs));
if (!ret->inputs)
goto err;
}
@ -712,7 +712,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
ret->output_pads = av_memdup(filter->outputs, ret->nb_outputs * sizeof(*filter->outputs));
if (!ret->output_pads)
goto err;
ret->outputs = av_mallocz_array(ret->nb_outputs, sizeof(AVFilterLink*));
ret->outputs = av_calloc(ret->nb_outputs, sizeof(*ret->outputs));
if (!ret->outputs)
goto err;
}

View File

@ -1006,7 +1006,7 @@ static DNNReturnType fill_model_input_tf(TFModel *tf_model, TFRequestItem *reque
goto err;
}
infer_request->output_tensors = av_mallocz_array(task->nb_output, sizeof(*infer_request->output_tensors));
infer_request->output_tensors = av_calloc(task->nb_output, sizeof(*infer_request->output_tensors));
if (!infer_request->output_tensors) {
av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for output tensor\n");
goto err;

View File

@ -29,7 +29,7 @@ static char **separate_output_names(const char *expr, const char *val_sep, int *
return NULL;
}
parsed_vals = av_mallocz_array(MAX_SUPPORTED_OUTPUTS_NB, sizeof(*parsed_vals));
parsed_vals = av_calloc(MAX_SUPPORTED_OUTPUTS_NB, sizeof(*parsed_vals));
if (!parsed_vals) {
return NULL;
}

View File

@ -232,7 +232,7 @@ FFEBUR128State *ff_ebur128_init(unsigned int channels,
CHECK_ERROR(errcode, 0, free_internal)
st->d->sample_peak =
(double *) av_mallocz_array(channels, sizeof(*st->d->sample_peak));
(double *) av_calloc(channels, sizeof(*st->d->sample_peak));
CHECK_ERROR(!st->d->sample_peak, 0, free_channel_map)
st->samplerate = samplerate;
@ -253,8 +253,8 @@ FFEBUR128State *ff_ebur128_init(unsigned int channels,
- (st->d->audio_data_frames % st->d->samples_in_100ms);
}
st->d->audio_data =
(double *) av_mallocz_array(st->d->audio_data_frames,
st->channels * sizeof(*st->d->audio_data));
(double *) av_calloc(st->d->audio_data_frames,
st->channels * sizeof(*st->d->audio_data));
CHECK_ERROR(!st->d->audio_data, 0, free_sample_peak)
ebur128_init_filter(st);

View File

@ -243,11 +243,11 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
frame->linesize[0] = pool->linesize[0];
if (pool->planes > AV_NUM_DATA_POINTERS) {
frame->extended_data = av_mallocz_array(pool->planes,
sizeof(*frame->extended_data));
frame->extended_data = av_calloc(pool->planes,
sizeof(*frame->extended_data));
frame->nb_extended_buf = pool->planes - AV_NUM_DATA_POINTERS;
frame->extended_buf = av_mallocz_array(frame->nb_extended_buf,
sizeof(*frame->extended_buf));
frame->extended_buf = av_calloc(frame->nb_extended_buf,
sizeof(*frame->extended_buf));
if (!frame->extended_data || !frame->extended_buf)
goto fail;
} else {

View File

@ -499,8 +499,8 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s)
s->in_mem_mode = in_frames_hwctx->frame_type;
s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs_in));
s->surface_ptrs_in = av_calloc(in_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs_in));
if (!s->surface_ptrs_in)
return AVERROR(ENOMEM);
@ -548,8 +548,8 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s)
return ret;
}
s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs_out));
s->surface_ptrs_out = av_calloc(out_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs_out));
if (!s->surface_ptrs_out) {
av_buffer_unref(&out_frames_ref);
return AVERROR(ENOMEM);
@ -672,7 +672,7 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p
if (ret < 0)
goto failed;
s->frame_infos = av_mallocz_array(avctx->nb_inputs, sizeof(*s->frame_infos));
s->frame_infos = av_calloc(avctx->nb_inputs, sizeof(*s->frame_infos));
if (!s->frame_infos) {
ret = AVERROR(ENOMEM);
goto failed;
@ -708,7 +708,7 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p
if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) {
s->nb_ext_buffers = param->num_ext_buf + 1;
s->ext_buffers = av_mallocz_array(s->nb_ext_buffers, sizeof(*s->ext_buffers));
s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers));
if (!s->ext_buffers) {
ret = AVERROR(ENOMEM);
goto failed;

View File

@ -54,8 +54,8 @@ int main(void)
const int ii_lz_32 = ((ii_w + 1) + 3) & ~3;
// "+1" is for the space of the top 0-line
uint32_t *ii = av_mallocz_array(ii_h + 1, ii_lz_32 * sizeof(*ii));
uint32_t *ii2 = av_mallocz_array(ii_h + 1, ii_lz_32 * sizeof(*ii2));
uint32_t *ii = av_calloc(ii_h + 1, ii_lz_32 * sizeof(*ii));
uint32_t *ii2 = av_calloc(ii_h + 1, ii_lz_32 * sizeof(*ii2));
if (!ii || !ii2)
return -1;

View File

@ -116,7 +116,7 @@ static int set_gauss(AVFilterContext *ctx)
int i;
for (i = 0; i <= difford; ++i) {
s->gauss[i] = av_mallocz_array(filtersize, sizeof(*s->gauss[i]));
s->gauss[i] = av_calloc(filtersize, sizeof(*s->gauss[i]));
if (!s->gauss[i]) {
for (; i >= 0; --i) {
av_freep(&s->gauss[i]);
@ -219,7 +219,8 @@ static int setup_derivative_buffers(AVFilterContext* ctx, ThreadData *td)
av_log(ctx, AV_LOG_TRACE, "Allocating %d buffer(s) for grey edge.\n", nb_buff);
for (b = 0; b <= nb_buff; ++b) { // We need difford + 1 buffers
for (p = 0; p < NUM_PLANES; ++p) {
td->data[b][p] = av_mallocz_array(s->planeheight[p] * s->planewidth[p], sizeof(*td->data[b][p]));
td->data[b][p] = av_calloc(s->planeheight[p] * s->planewidth[p],
sizeof(*td->data[b][p]));
if (!td->data[b][p]) {
cleanup_derivative_buffers(td, b + 1, p);
return AVERROR(ENOMEM);

View File

@ -461,7 +461,7 @@ static av_cold int init(AVFilterContext *fctx)
av_log(ctx, AV_LOG_DEBUG, "Filter count: %i\n", ctx->num_filters);
// allocate CIFilter array
ctx->filters = av_mallocz_array(ctx->num_filters, sizeof(CIFilter*));
ctx->filters = av_calloc(ctx->num_filters, sizeof(CIFilter*));
if (!ctx->filters) {
av_log(ctx, AV_LOG_ERROR, "Could not allocate filter array.\n");
return AVERROR(ENOMEM);

View File

@ -666,7 +666,7 @@ static int config_input(AVFilterLink *inlink)
for (i = 0; i < NB_COMP + 1; i++) {
if (!curves->graph[i])
curves->graph[i] = av_mallocz_array(curves->lut_size, sizeof(*curves->graph[0]));
curves->graph[i] = av_calloc(curves->lut_size, sizeof(*curves->graph[0]));
if (!curves->graph[i])
return AVERROR(ENOMEM);
ret = parse_points_str(ctx, comp_points + i, curves->comp_points_str[i], curves->lut_size);

View File

@ -233,8 +233,8 @@ static int init_out_session(AVFilterContext *ctx)
s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->deint_conf;
if (opaque) {
s->surface_ptrs = av_mallocz_array(hw_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs));
s->surface_ptrs = av_calloc(hw_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs));
if (!s->surface_ptrs)
return AVERROR(ENOMEM);
for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++)
@ -263,8 +263,8 @@ static int init_out_session(AVFilterContext *ctx)
.Free = frame_free,
};
s->mem_ids = av_mallocz_array(hw_frames_hwctx->nb_surfaces,
sizeof(*s->mem_ids));
s->mem_ids = av_calloc(hw_frames_hwctx->nb_surfaces,
sizeof(*s->mem_ids));
if (!s->mem_ids)
return AVERROR(ENOMEM);
for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++)

View File

@ -95,7 +95,7 @@ static av_cold int dejudder_init(AVFilterContext *ctx)
{
DejudderContext *s = ctx->priv;
s->ringbuff = av_mallocz_array(s->cycle+2, sizeof(*s->ringbuff));
s->ringbuff = av_calloc(s->cycle + 2, sizeof(*s->ringbuff));
if (!s->ringbuff)
return AVERROR(ENOMEM);

View File

@ -172,7 +172,7 @@ static int read_shape_from_file(int *cols, int *rows, int **values, const char *
ret = AVERROR_INVALIDDATA;
goto end;
}
if (!(*values = av_mallocz_array(sizeof(int) * *rows, *cols))) {
if (!(*values = av_calloc(sizeof(int) * *rows, *cols))) {
ret = AVERROR(ENOMEM);
goto end;
}

View File

@ -100,7 +100,7 @@ static int config_input(AVFilterLink *inlink)
return AVERROR(EINVAL);
for (i = 0; i < 3; i++) {
s->mv_table[i] = av_mallocz_array(s->b_count, sizeof(*s->mv_table[0]));
s->mv_table[i] = av_calloc(s->b_count, sizeof(*s->mv_table[0]));
if (!s->mv_table[i])
return AVERROR(ENOMEM);
}

View File

@ -353,7 +353,7 @@ static int config_input(AVFilterLink *inlink)
for (i = 0; i < NB_FRAMES; i++) {
Frame *frame = &mi_ctx->frames[i];
frame->blocks = av_mallocz_array(mi_ctx->b_count, sizeof(Block));
frame->blocks = av_calloc(mi_ctx->b_count, sizeof(*frame->blocks));
if (!frame->blocks)
return AVERROR(ENOMEM);
}
@ -373,19 +373,19 @@ static int config_input(AVFilterLink *inlink)
else if (mi_ctx->me_mode == ME_MODE_BILAT)
me_ctx->get_cost = &get_sbad_ob;
mi_ctx->pixel_mvs = av_mallocz_array(width * height, sizeof(PixelMVS));
mi_ctx->pixel_weights = av_mallocz_array(width * height, sizeof(PixelWeights));
mi_ctx->pixel_refs = av_mallocz_array(width * height, sizeof(PixelRefs));
mi_ctx->pixel_mvs = av_calloc(width * height, sizeof(*mi_ctx->pixel_mvs));
mi_ctx->pixel_weights = av_calloc(width * height, sizeof(*mi_ctx->pixel_weights));
mi_ctx->pixel_refs = av_calloc(width * height, sizeof(*mi_ctx->pixel_refs));
if (!mi_ctx->pixel_mvs || !mi_ctx->pixel_weights || !mi_ctx->pixel_refs)
return AVERROR(ENOMEM);
if (mi_ctx->me_mode == ME_MODE_BILAT)
if (!(mi_ctx->int_blocks = av_mallocz_array(mi_ctx->b_count, sizeof(Block))))
if (!FF_ALLOCZ_TYPED_ARRAY(mi_ctx->int_blocks, mi_ctx->b_count))
return AVERROR(ENOMEM);
if (mi_ctx->me_method == AV_ME_METHOD_EPZS) {
for (i = 0; i < 3; i++) {
mi_ctx->mv_table[i] = av_mallocz_array(mi_ctx->b_count, sizeof(*mi_ctx->mv_table[0]));
mi_ctx->mv_table[i] = av_calloc(mi_ctx->b_count, sizeof(*mi_ctx->mv_table[0]));
if (!mi_ctx->mv_table[i])
return AVERROR(ENOMEM);
}
@ -601,7 +601,7 @@ static int var_size_bme(MIContext *mi_ctx, Block *block, int x_mb, int y_mb, int
}
if (!block->subs) {
block->subs = av_mallocz_array(4, sizeof(Block));
block->subs = av_mallocz(4 * sizeof(*block->subs));
if (!block->subs)
return AVERROR(ENOMEM);
}

View File

@ -312,7 +312,7 @@ static int config_input(AVFilterLink *inlink)
s->ii_lz_32 = FFALIGN(s->ii_w + 1, 4);
// "+1" is for the space of the top 0-line
s->ii_orig = av_mallocz_array(s->ii_h + 1, s->ii_lz_32 * sizeof(*s->ii_orig));
s->ii_orig = av_calloc(s->ii_h + 1, s->ii_lz_32 * sizeof(*s->ii_orig));
if (!s->ii_orig)
return AVERROR(ENOMEM);

View File

@ -325,8 +325,8 @@ static int overlay_qsv_init(AVFilterContext *ctx)
vpp->comp_conf.Header.BufferId = MFX_EXTBUFF_VPP_COMPOSITE;
vpp->comp_conf.Header.BufferSz = sizeof(vpp->comp_conf);
vpp->comp_conf.NumInputStream = ctx->nb_inputs;
vpp->comp_conf.InputStream = av_mallocz_array(ctx->nb_inputs,
sizeof(*vpp->comp_conf.InputStream));
vpp->comp_conf.InputStream = av_calloc(ctx->nb_inputs,
sizeof(*vpp->comp_conf.InputStream));
if (!vpp->comp_conf.InputStream)
return AVERROR(ENOMEM);

View File

@ -271,8 +271,7 @@ static av_cold int program_opencl_init(AVFilterContext *avctx)
} else {
int i;
ctx->frames = av_mallocz_array(ctx->nb_inputs,
sizeof(*ctx->frames));
ctx->frames = av_calloc(ctx->nb_inputs, sizeof(*ctx->frames));
if (!ctx->frames)
return AVERROR(ENOMEM);

View File

@ -343,16 +343,16 @@ static int init_out_session(AVFilterContext *ctx)
memset(&par, 0, sizeof(par));
if (opaque) {
s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs_in));
s->surface_ptrs_in = av_calloc(in_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs_in));
if (!s->surface_ptrs_in)
return AVERROR(ENOMEM);
for (i = 0; i < in_frames_hwctx->nb_surfaces; i++)
s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i;
s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces;
s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs_out));
s->surface_ptrs_out = av_calloc(out_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs_out));
if (!s->surface_ptrs_out)
return AVERROR(ENOMEM);
for (i = 0; i < out_frames_hwctx->nb_surfaces; i++)
@ -383,16 +383,16 @@ static int init_out_session(AVFilterContext *ctx)
.Free = frame_free,
};
s->mem_ids_in = av_mallocz_array(in_frames_hwctx->nb_surfaces,
sizeof(*s->mem_ids_in));
s->mem_ids_in = av_calloc(in_frames_hwctx->nb_surfaces,
sizeof(*s->mem_ids_in));
if (!s->mem_ids_in)
return AVERROR(ENOMEM);
for (i = 0; i < in_frames_hwctx->nb_surfaces; i++)
s->mem_ids_in[i] = in_frames_hwctx->surfaces[i].Data.MemId;
s->nb_mem_ids_in = in_frames_hwctx->nb_surfaces;
s->mem_ids_out = av_mallocz_array(out_frames_hwctx->nb_surfaces,
sizeof(*s->mem_ids_out));
s->mem_ids_out = av_calloc(out_frames_hwctx->nb_surfaces,
sizeof(*s->mem_ids_out));
if (!s->mem_ids_out)
return AVERROR(ENOMEM);
for (i = 0; i < out_frames_hwctx->nb_surfaces; i++)

View File

@ -478,7 +478,7 @@ static int config_input_ref(AVFilterLink *inlink)
return AVERROR(ENOMEM);
for (int t = 0; t < s->nb_threads; t++) {
s->temp[t] = av_mallocz_array(2 * SUM_LEN(inlink->w), (desc->comp[0].depth > 8) ? sizeof(int64_t[4]) : sizeof(int[4]));
s->temp[t] = av_calloc(2 * SUM_LEN(inlink->w), (desc->comp[0].depth > 8) ? sizeof(int64_t[4]) : sizeof(int[4]));
if (!s->temp[t])
return AVERROR(ENOMEM);
}

View File

@ -229,7 +229,7 @@ static int init_filter_param(AVFilterContext *ctx, UnsharpFilterParam *fp, const
effect, effect_type, fp->msize_x, fp->msize_y, fp->amount / 65535.0);
fp->sr = av_malloc_array((MAX_MATRIX_SIZE - 1) * s->nb_threads, sizeof(uint32_t));
fp->sc = av_mallocz_array(2 * fp->steps_y * s->nb_threads, sizeof(uint32_t *));
fp->sc = av_calloc(fp->steps_y * s->nb_threads, 2 * sizeof(*fp->sc));
if (!fp->sr || !fp->sc)
return AVERROR(ENOMEM);

View File

@ -294,11 +294,11 @@ static int config_input(AVFilterLink *inlink)
// padding one row on the top, and padding one col on the left, that is why + 1 below
s->sat_linesize = inlink->w + 1;
s->sat = av_mallocz_array(inlink->h + 1, s->sat_linesize*sizeof(*s->sat));
s->sat = av_calloc(inlink->h + 1, s->sat_linesize * sizeof(*s->sat));
if (!s->sat)
return AVERROR(ENOMEM);
s->square_sat = av_mallocz_array(inlink->h + 1, s->sat_linesize*sizeof(*s->square_sat));
s->square_sat = av_calloc(inlink->h + 1, s->sat_linesize * sizeof(*s->square_sat));
if (!s->square_sat)
return AVERROR(ENOMEM);

View File

@ -123,7 +123,7 @@ static int init_pattern_from_string(AVFilterContext *ctx)
s->h = (double)s->w * M_PHI;
}
s->buf = av_mallocz_array(sizeof(uint8_t) * s->w, s->h);
s->buf = av_calloc(s->w, s->h * sizeof(*s->buf));
if (!s->buf)
return AVERROR(ENOMEM);
@ -183,7 +183,7 @@ static av_cold int init(AVFilterContext *ctx)
/* fill the first row randomly */
int i;
s->buf = av_mallocz_array(sizeof(uint8_t) * s->w, s->h);
s->buf = av_calloc(s->w, s->h * sizeof(*s->buf));
if (!s->buf)
return AVERROR(ENOMEM);
if (s->random_seed == -1)

View File

@ -1674,7 +1674,7 @@ static int check_stream_max_drift(AVFormatContext *s)
{
int64_t min_pos, pos;
int i;
int *idx = av_mallocz_array(s->nb_streams, sizeof(*idx));
int *idx = av_calloc(s->nb_streams, sizeof(*idx));
if (!idx)
return AVERROR(ENOMEM);
for (min_pos = pos = 0; min_pos != INT64_MAX; pos = min_pos + 1LU) {

View File

@ -84,7 +84,7 @@ static int hash_init(struct AVFormatContext *s)
int res;
struct HashContext *c = s->priv_data;
c->per_stream = 0;
c->hashes = av_mallocz_array(1, sizeof(*c->hashes));
c->hashes = av_mallocz(sizeof(*c->hashes));
if (!c->hashes)
return AVERROR(ENOMEM);
res = av_hash_alloc(&c->hashes[0], c->hash_name);
@ -101,7 +101,7 @@ static int streamhash_init(struct AVFormatContext *s)
int res, i;
struct HashContext *c = s->priv_data;
c->per_stream = 1;
c->hashes = av_mallocz_array(s->nb_streams, sizeof(*c->hashes));
c->hashes = av_calloc(s->nb_streams, sizeof(*c->hashes));
if (!c->hashes)
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_streams; i++) {
@ -254,7 +254,7 @@ static int framehash_init(struct AVFormatContext *s)
int res;
struct HashContext *c = s->priv_data;
c->per_stream = 0;
c->hashes = av_mallocz_array(1, sizeof(*c->hashes));
c->hashes = av_mallocz(sizeof(*c->hashes));
if (!c->hashes)
return AVERROR(ENOMEM);
res = av_hash_alloc(&c->hashes[0], c->hash_name);

View File

@ -326,7 +326,7 @@ static int hds_write_header(AVFormatContext *s)
return AVERROR_MUXER_NOT_FOUND;
}
c->streams = av_mallocz_array(s->nb_streams, sizeof(*c->streams));
c->streams = av_calloc(s->nb_streams, sizeof(*c->streams));
if (!c->streams) {
return AVERROR(ENOMEM);
}

View File

@ -106,7 +106,7 @@ static int ico_write_header(AVFormatContext *s)
avio_skip(pb, 16);
}
ico->images = av_mallocz_array(ico->nb_images, sizeof(IcoMuxContext));
ico->images = av_calloc(ico->nb_images, sizeof(*ico->images));
if (!ico->images)
return AVERROR(ENOMEM);

View File

@ -2687,7 +2687,7 @@ static int mkv_init(struct AVFormatContext *s)
mkv->cur_audio_pkt = av_packet_alloc();
if (!mkv->cur_audio_pkt)
return AVERROR(ENOMEM);
mkv->tracks = av_mallocz_array(s->nb_streams, sizeof(*mkv->tracks));
mkv->tracks = av_calloc(s->nb_streams, sizeof(*mkv->tracks));
if (!mkv->tracks)
return AVERROR(ENOMEM);

Some files were not shown because too many files have changed in this diff Show More