[FFmpeg-devel] [PATCH 34/45] avcodec/smvjpegdec: Cleanup generically on init failure
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Fri Nov 27 03:02:38 EET 2020
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
libavcodec/smvjpegdec.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/libavcodec/smvjpegdec.c b/libavcodec/smvjpegdec.c
index 32756b54f3..807d990d00 100644
--- a/libavcodec/smvjpegdec.c
+++ b/libavcodec/smvjpegdec.c
@@ -105,37 +105,29 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
s->picture[1] = av_frame_alloc();
- if (!s->picture[1]) {
- av_frame_free(&s->picture[0]);
+ if (!s->picture[1])
return AVERROR(ENOMEM);
- }
s->jpg.picture_ptr = s->picture[0];
codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
if (!codec) {
av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
- smvjpeg_decode_end(avctx);
return AVERROR_DECODER_NOT_FOUND;
}
s->avctx = avcodec_alloc_context3(codec);
- if (!s->avctx) {
- smvjpeg_decode_end(avctx);
+ if (!s->avctx)
return AVERROR(ENOMEM);
- }
av_dict_set(&thread_opt, "threads", "1", 0);
s->avctx->refcounted_frames = 1;
s->avctx->flags = avctx->flags;
s->avctx->idct_algo = avctx->idct_algo;
- if ((ret = ff_codec_open2_recursive(s->avctx, codec, &thread_opt)) < 0) {
+ if ((ret = ff_codec_open2_recursive(s->avctx, codec, &thread_opt)) < 0)
av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
- }
av_dict_free(&thread_opt);
- if (ret < 0)
- smvjpeg_decode_end(avctx);
return ret;
}
@@ -219,4 +211,5 @@ AVCodec ff_smvjpeg_decoder = {
.close = smvjpeg_decode_end,
.decode = smvjpeg_decode_frame,
.priv_class = &smvjpegdec_class,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
--
2.25.1
More information about the ffmpeg-devel
mailing list