]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mss4.c
Merge commit 'd4df02131b5522a99a4e6035368484e809706ed5'
[ffmpeg] / libavcodec / mss4.c
index fd1f316bbf17cc5c3f945c09d49bcf24436ac43a..662cf24df50a100f2d76f84c1f80a95844502478 100644 (file)
@@ -626,14 +626,23 @@ static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     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");
@@ -650,21 +659,13 @@ static av_cold int mss4_decode_init(AVCodecContext *avctx)
         }
     }
 
-    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;
 }