return buf_size;
}
-static av_cold int mss4_decode_init(AVCodecContext *avctx)
+static av_cold int mss4_decode_end(AVCodecContext *avctx)
{
MSS4Context * const c = avctx->priv_data;
int i;
- c->pic = av_frame_alloc();
- if (!c->pic)
- return AVERROR(ENOMEM);
+ av_frame_free(&c->pic);
+ for (i = 0; i < 3; i++)
+ av_freep(&c->prev_dc[i]);
+ mss4_free_vlcs(c);
+
+ return 0;
+}
+
+static av_cold int mss4_decode_init(AVCodecContext *avctx)
+{
+ MSS4Context * const c = avctx->priv_data;
+ int i;
if (mss4_init_vlcs(c)) {
av_log(avctx, AV_LOG_ERROR, "Cannot initialise VLCs\n");
}
}
- avctx->pix_fmt = AV_PIX_FMT_YUV444P;
-
- return 0;
-}
-
-static av_cold int mss4_decode_end(AVCodecContext *avctx)
-{
- MSS4Context * const c = avctx->priv_data;
- int i;
-
- av_frame_free(&c->pic);
+ c->pic = av_frame_alloc();
+ if (!c->pic) {
+ mss4_decode_end(avctx);
+ return AVERROR(ENOMEM);
+ }
- for (i = 0; i < 3; i++)
- av_freep(&c->prev_dc[i]);
- mss4_free_vlcs(c);
+ avctx->pix_fmt = AV_PIX_FMT_YUV444P;
return 0;
}