aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-15 03:22:36 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-15 19:25:26 +0200
commit0f1db365c7ce7c7c0ef3ee484e780abf7daaba1f (patch)
treef656382e2a669d4fc4adff1435d559076b0662a1
parente42fc6263379176869dd9a6467e37f9956d56431 (diff)
downloadffmpeg-0f1db365c7ce7c7c0ef3ee484e780abf7daaba1f.tar.gz
avcodec/motionpixels: Cleanup generically after init failure
Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r--libavcodec/motionpixels.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
index 6cb444a703..b48200b017 100644
--- a/libavcodec/motionpixels.c
+++ b/libavcodec/motionpixels.c
@@ -81,19 +81,13 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1;
mp->vpt = av_mallocz_array(avctx->height, sizeof(YuvPixel));
mp->hpt = av_mallocz_array(h4 / 4, w4 / 4 * sizeof(YuvPixel));
- if (!mp->changes_map || !mp->vpt || !mp->hpt) {
- av_freep(&mp->changes_map);
- av_freep(&mp->vpt);
- av_freep(&mp->hpt);
+ if (!mp->changes_map || !mp->vpt || !mp->hpt)
return AVERROR(ENOMEM);
- }
avctx->pix_fmt = AV_PIX_FMT_RGB555;
mp->frame = av_frame_alloc();
- if (!mp->frame) {
- mp_decode_end(avctx);
+ if (!mp->frame)
return AVERROR(ENOMEM);
- }
return 0;
}
@@ -354,4 +348,5 @@ AVCodec ff_motionpixels_decoder = {
.close = mp_decode_end,
.decode = mp_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};