diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-05-15 03:42:06 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-05-21 03:10:52 +0200 |
commit | b8ec4f7b20ae9aab85299b676d6f04ffae610b33 (patch) | |
tree | c95c8bab2f0d4f12a03edfd5ae4b44d693fabbd1 | |
parent | eacde6ee7be03fca5d5f9017478f436ee95b4fe4 (diff) | |
download | ffmpeg-b8ec4f7b20ae9aab85299b676d6f04ffae610b33.tar.gz |
avcodec/svq3: Allocate motion_val jointly
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | libavcodec/svq3.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index e1e65c4766..cdb2bd323b 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -74,7 +74,7 @@ typedef struct SVQ3Frame { AVFrame *f; - int16_t (*motion_val_buf[2])[2]; + int16_t (*motion_val_buf)[2]; int16_t (*motion_val[2])[2]; uint32_t *mb_type_buf, *mb_type; @@ -1323,10 +1323,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) static void free_picture(SVQ3Frame *pic) { - int i; - for (i = 0; i < 2; i++) { - av_freep(&pic->motion_val_buf[i]); - } + av_freep(&pic->motion_val_buf); av_freep(&pic->mb_type_buf); av_frame_unref(pic->f); @@ -1340,23 +1337,19 @@ static int get_buffer(AVCodecContext *avctx, SVQ3Frame *pic) const int b4_array_size = b4_stride * s->mb_height * 4; int ret; - if (!pic->motion_val_buf[0]) { - int i; - + if (!pic->motion_val_buf) { pic->mb_type_buf = av_calloc(big_mb_num + s->mb_stride, sizeof(uint32_t)); if (!pic->mb_type_buf) return AVERROR(ENOMEM); pic->mb_type = pic->mb_type_buf + 2 * s->mb_stride + 1; - for (i = 0; i < 2; i++) { - pic->motion_val_buf[i] = av_calloc(b4_array_size + 4, 2 * sizeof(int16_t)); - if (!pic->motion_val_buf[i]) { - ret = AVERROR(ENOMEM); - goto fail; - } - - pic->motion_val[i] = pic->motion_val_buf[i] + 4; + pic->motion_val_buf = av_calloc(b4_array_size + 4, 2 * sizeof(*pic->motion_val[0])); + if (!pic->motion_val_buf) { + ret = AVERROR(ENOMEM); + goto fail; } + pic->motion_val[0] = pic->motion_val_buf + 4; + pic->motion_val[1] = pic->motion_val[0] + b4_array_size + 4; } ret = ff_get_buffer(avctx, pic->f, |