avcodec/mpegvideo: Only allocate cbp_table, pred_dir_table when needed

Namely for the MPEG-4 decoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2024-04-21 00:11:56 +02:00
parent 582d828f75
commit caac9740f8
1 changed files with 6 additions and 7 deletions

View File

@ -593,13 +593,12 @@ int ff_mpv_init_context_frame(MpegEncContext *s)
tmp += mv_table_size;
}
}
}
if (s->out_format == FMT_H263) {
/* cbp, ac_pred, pred_dir */
if (!(s->cbp_table = av_mallocz(mb_array_size)) ||
!(s->pred_dir_table = av_mallocz(mb_array_size)))
return AVERROR(ENOMEM);
if (s->codec_id == AV_CODEC_ID_MPEG4 && !s->encoding) {
/* cbp, pred_dir */
if (!(s->cbp_table = av_mallocz(mb_array_size)) ||
!(s->pred_dir_table = av_mallocz(mb_array_size)))
return AVERROR(ENOMEM);
}
}
if (s->msmpeg4_version >= 3) {