X-Git-Url: https://git.piment-noir.org/?p=deb_ffmpeg.git;a=blobdiff_plain;f=ffmpeg%2Flibavcodec%2Fsmvjpegdec.c;h=375c9d91c3ccf4a3abe509eedde6f2ea4ac081de;hp=69327cd7989439b57e1a4b7a2d279bbac8045358;hb=f6fa7814ccfe3e76514b36cf04f5cd3cb657c8cf;hpb=2ba45a602cbfa7b771effba9b11bb4245c21bc00 diff --git a/ffmpeg/libavcodec/smvjpegdec.c b/ffmpeg/libavcodec/smvjpegdec.c index 69327cd..375c9d9 100644 --- a/ffmpeg/libavcodec/smvjpegdec.c +++ b/ffmpeg/libavcodec/smvjpegdec.c @@ -75,6 +75,20 @@ static inline void smv_img_pnt(uint8_t *dst_data[4], uint8_t *src_data[4], 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; @@ -89,8 +103,10 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx) 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]; @@ -120,6 +136,8 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx) } av_dict_free(&thread_opt); + if (ret < 0) + smvjpeg_decode_end(avctx); return ret; } @@ -176,20 +194,6 @@ static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_siz 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,