diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-10-25 02:51:21 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-10-29 13:37:41 +0200 |
commit | 4200ed2e91d248ef62f7fb701a7679d0e0afa654 (patch) | |
tree | 29c1c9b12809d68a0a030202edf8e3fb672c29c0 /libavcodec/mpegvideo.c | |
parent | 20ee12c677c6f58afbae643f039ba06e7d6f070a (diff) | |
download | ffmpeg-4200ed2e91d248ef62f7fb701a7679d0e0afa654.tar.gz |
avcodec/mpegvideo: Allocate map and score_map buffers jointly
Reduces the amounts of allocs, frees and allocation checks.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r-- | libavcodec/mpegvideo.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index cea6b5e899..d02372ddc9 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -372,9 +372,10 @@ static int init_duplicate_context(MpegEncContext *s) yc_size += 2*s->b8_stride + 2*s->mb_stride; if (s->encoding) { - if (!FF_ALLOCZ_TYPED_ARRAY(s->me.map, ME_MAP_SIZE) || - !FF_ALLOCZ_TYPED_ARRAY(s->me.score_map, ME_MAP_SIZE)) + s->me.map = av_mallocz(2 * ME_MAP_SIZE * sizeof(*s->me.map)); + if (!s->me.map) return AVERROR(ENOMEM); + s->me.score_map = s->me.map + ME_MAP_SIZE; if (s->noise_reduction) { if (!FF_ALLOCZ_TYPED_ARRAY(s->dct_error_sum, 2)) @@ -444,7 +445,7 @@ static void free_duplicate_context(MpegEncContext *s) av_freep(&s->dct_error_sum); av_freep(&s->me.map); - av_freep(&s->me.score_map); + s->me.score_map = NULL; av_freep(&s->blocks); av_freep(&s->ac_val_base); s->block = NULL; |