diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-14 21:31:53 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-20 01:03:52 +0200 |
commit | 1ea365082318f06cd42a8b37dd0c7724b599c821 (patch) | |
tree | 4df48a8b9f4614803fd2a88c29ad2ff7f7070294 /libavcodec | |
parent | 4b154743163ffbe3fdc50759c0c55dc854636488 (diff) | |
download | ffmpeg-1ea365082318f06cd42a8b37dd0c7724b599c821.tar.gz |
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>
Diffstat (limited to 'libavcodec')
60 files changed, 125 insertions, 125 deletions
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index e2dd85b756..99df55dc7b 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -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); diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index 487b84fd85..0c64f2c7b0 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -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); diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index ba873ec53a..9e1aaf065a 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -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)); } } diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index b4809111f8..2376a7cd02 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -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); diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c index 9917f2d819..e342f09fdb 100644 --- a/libavcodec/atrac3plusdec.c +++ b/libavcodec/atrac3plusdec.c @@ -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) { diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index 74b8371501..e29d9c659b 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -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)); diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index 66e1695ec9..008a6360b6 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -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)); } diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c index 38e4acb4f0..3d87064a40 100644 --- a/libavcodec/cfhdenc.c +++ b/libavcodec/cfhdenc.c @@ -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) diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c index 57cb620179..ecfd4abfc9 100644 --- a/libavcodec/cngdec.c +++ b/libavcodec/cngdec.c @@ -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); diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 023dd3c0b2..294c040716 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -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); diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c index 1113517880..7ffb8a3496 100644 --- a/libavcodec/diracdec.c +++ b/libavcodec/diracdec.c @@ -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) diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index d113c1db7b..9ecd220e7f 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -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); diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index e45c14e878..d192f3251d 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -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; diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index b57ea21941..568d686f39 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -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; diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 66b7e258ee..0d5b3467d1 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -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); diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 1c580c3b49..a27eca5ae3 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -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++) { diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c index 66f4557f06..c9e8d11ab8 100644 --- a/libavcodec/g2meet.c +++ b/libavcodec/g2meet.c @@ -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); } diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index c7e8b2827b..5ca41cc91c 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -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); diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index eafb883429..57a61752a3 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -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; diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c index cefaf77bfd..77979d04e7 100644 --- a/libavcodec/ivi.c +++ b/libavcodec/ivi.c @@ -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); diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 83f7d6efbf..7ebd6856e0 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -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); diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 2fbdb64280..0aa984bc53 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -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); diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index c95f22bc90..80b2e2d627 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -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)); diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index f2cbc6eeb1..2df1c5090f 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -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; diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index 82002ac346..45b23fcbb5 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -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"); diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index f66345e998..10e5a22fa9 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -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); diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 379c167e6f..0f886713e3 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -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); diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 839b6ce9de..7dd70a3450 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -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); diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c index 15bb8e5c1c..20b3b0f804 100644 --- a/libavcodec/libxavs.c +++ b/libavcodec/libxavs.c @@ -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 */ diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 7bec5ce221..7f89641660 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -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]; diff --git a/libavcodec/mlz.c b/libavcodec/mlz.c index ebce796ba5..dbeb7dcad9 100644 --- a/libavcodec/mlz.c +++ b/libavcodec/mlz.c @@ -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; diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 1896330fe1..7ac9634538 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -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; diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index ae25afd7f8..edc46ed33a 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -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); diff --git a/libavcodec/omx.c b/libavcodec/omx.c index 4078ac84a4..cec0d04b8a 100644 --- a/libavcodec/omx.c +++ b/libavcodec/omx.c @@ -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++) { diff --git a/libavcodec/opus.c b/libavcodec/opus.c index 5ca6ca92f3..df8ba93fa9 100644 --- a/libavcodec/opus.c +++ b/libavcodec/opus.c @@ -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); diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c index 3ebf199219..b063e0efeb 100644 --- a/libavcodec/opusdec.c +++ b/libavcodec/opusdec.c @@ -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); diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 55eda4c2a9..388639a110 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -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); } diff --git a/libavcodec/png.c b/libavcodec/png.c index 4ea286075d..e772eaad26 100644 --- a/libavcodec/png.c +++ b/libavcodec/png.c @@ -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) diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index fe1f3a28bd..7750620b22 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -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; diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c index 2b5f111fbe..93c8408297 100644 --- a/libavcodec/psymodel.c +++ b/libavcodec/psymodel.c @@ -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); diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 9c5d66c0d4..73b1b7d7d9 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -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; diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c index 80c4579fc0..86411b21be 100644 --- a/libavcodec/pthread_slice.c +++ b/libavcodec/pthread_slice.c @@ -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)); diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 2f332092a1..9d08485c92 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -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); diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 090fdbe75e..f7bb3f5eff 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -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); diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 4089157d47..fd131995b3 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -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); diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index f8e363ada7..3eac96f25e 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -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)); diff --git a/libavcodec/snow.c b/libavcodec/snow.c index a037e36873..e0fb58042c 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -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); } diff --git a/libavcodec/snow_dwt.c b/libavcodec/snow_dwt.c index 3dca3c6d30..c093ebff07 100644 --- a/libavcodec/snow_dwt.c +++ b/libavcodec/snow_dwt.c @@ -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 *)); diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index d2c0beb1aa..55ebfba50f 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -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); } diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index b2c8215002..e329578af0 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -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); } diff --git a/libavcodec/tests/snowenc.c b/libavcodec/tests/snowenc.c index d5f94e8a61..07af1f2cf9 100644 --- a/libavcodec/tests/snowenc.c +++ b/libavcodec/tests/snowenc.c @@ -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"); diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 8566f7ba74..870e0666aa 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -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; diff --git a/libavcodec/tta.c b/libavcodec/tta.c index d9ff45fad6..17b4ca9032 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -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 diff --git a/libavcodec/utils.c b/libavcodec/utils.c index cfc07cbcb8..387d285633 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -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; diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 7510816ec1..ec054ae701 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -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; diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index dac2b6841c..6e07bc5a8a 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -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); diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index 72c6ba1130..858c6ac6dd 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -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++) { diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 166c1bf60d..16726080b3 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -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)); diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index c1b58d4752..8317ac6bd8 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -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); diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 3efd4438d9..8b19ba4e64 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -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); |