dst_data[1] = src_data[1];
}
+static av_cold int smvjpeg_decode_end(AVCodecContext *avctx)
+{
+ SMVJpegDecodeContext *s = avctx->priv_data;
+ MJpegDecodeContext *jpg = &s->jpg;
+ int ret;
+
+ jpg->picture_ptr = NULL;
+ av_frame_free(&s->picture[0]);
+ av_frame_free(&s->picture[1]);
+ ret = avcodec_close(s->avctx);
+ av_freep(&s->avctx);
+ return ret;
+}
+
static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
{
SMVJpegDecodeContext *s = avctx->priv_data;
return AVERROR(ENOMEM);
s->picture[1] = av_frame_alloc();
- if (!s->picture[1])
+ if (!s->picture[1]) {
+ av_frame_free(&s->picture[0]);
return AVERROR(ENOMEM);
+ }
s->jpg.picture_ptr = s->picture[0];
}
av_dict_free(&thread_opt);
+ if (ret < 0)
+ smvjpeg_decode_end(avctx);
return ret;
}
return ret;
}
-static av_cold int smvjpeg_decode_end(AVCodecContext *avctx)
-{
- SMVJpegDecodeContext *s = avctx->priv_data;
- MJpegDecodeContext *jpg = &s->jpg;
- int ret;
-
- jpg->picture_ptr = NULL;
- av_frame_free(&s->picture[0]);
- av_frame_free(&s->picture[1]);
- ret = avcodec_close(s->avctx);
- av_freep(&s->avctx);
- return ret;
-}
-
static const AVClass smvjpegdec_class = {
.class_name = "SMVJPEG decoder",
.item_name = av_default_item_name,