summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-10-25 02:51:21 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-10-29 13:37:41 +0200
commit4200ed2e91d248ef62f7fb701a7679d0e0afa654 (patch)
tree29c1c9b12809d68a0a030202edf8e3fb672c29c0 /libavcodec/mpegvideo.c
parent20ee12c677c6f58afbae643f039ba06e7d6f070a (diff)
downloadffmpeg-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.c7
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;