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/svq1enc.c | |
parent | 20ee12c677c6f58afbae643f039ba06e7d6f070a (diff) |
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/svq1enc.c')
-rw-r--r-- | libavcodec/svq1enc.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 7c9430a137..92f91aeebd 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -552,7 +552,6 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) av_freep(&s->m.me.scratchpad); av_freep(&s->m.me.map); - av_freep(&s->m.me.score_map); av_freep(&s->mb_type); av_freep(&s->dummy); av_freep(&s->scratchbuf); @@ -608,18 +607,17 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) s->m.me.temp = s->m.me.scratchpad = av_mallocz((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->mb_type = av_mallocz((s->y_block_width + 1) * s->y_block_height * sizeof(int16_t)); s->dummy = av_mallocz((s->y_block_width + 1) * s->y_block_height * sizeof(int32_t)); + s->m.me.map = av_mallocz(2 * ME_MAP_SIZE * sizeof(*s->m.me.map)); s->svq1encdsp.ssd_int8_vs_int16 = ssd_int8_vs_int16_c; if (!s->m.me.temp || !s->m.me.scratchpad || !s->m.me.map || - !s->m.me.score_map || !s->mb_type || !s->dummy) { + !s->mb_type || !s->dummy) return AVERROR(ENOMEM); - } + s->m.me.score_map = s->m.me.map + ME_MAP_SIZE; #if ARCH_PPC ff_svq1enc_init_ppc(&s->svq1encdsp); |