]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mss3.c
Merge commit '074c769de93bf12e9f44d77e58a8c7167f9dfb13'
[ffmpeg] / libavcodec / mss3.c
index a3aec80c2df6a6158b42432dd84f88526b95dc6e..c6bb838045dfa694cfbdde05cc3caed058d62d02 100644 (file)
@@ -803,15 +803,24 @@ static int mss3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     return buf_size;
 }
 
+static av_cold int mss3_decode_end(AVCodecContext *avctx)
+{
+    MSS3Context * const c = avctx->priv_data;
+    int i;
+
+    av_frame_free(&c->pic);
+    for (i = 0; i < 3; i++)
+        av_freep(&c->dct_coder[i].prev_dc);
+
+    return 0;
+}
+
 static av_cold int mss3_decode_init(AVCodecContext *avctx)
 {
     MSS3Context * const c = avctx->priv_data;
     int i;
 
     c->avctx = avctx;
-    c->pic = av_frame_alloc();
-    if (!c->pic)
-        return AVERROR(ENOMEM);
 
     if ((avctx->width & 0xF) || (avctx->height & 0xF)) {
         av_log(avctx, AV_LOG_ERROR,
@@ -838,6 +847,12 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx)
         }
     }
 
+    c->pic = av_frame_alloc();
+    if (!c->pic) {
+        mss3_decode_end(avctx);
+        return AVERROR(ENOMEM);
+    }
+
     avctx->pix_fmt     = AV_PIX_FMT_YUV420P;
 
     init_coders(c);
@@ -845,18 +860,6 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx)
     return 0;
 }
 
-static av_cold int mss3_decode_end(AVCodecContext *avctx)
-{
-    MSS3Context * const c = avctx->priv_data;
-    int i;
-
-    av_frame_free(&c->pic);
-    for (i = 0; i < 3; i++)
-        av_freep(&c->dct_coder[i].prev_dc);
-
-    return 0;
-}
-
 AVCodec ff_msa1_decoder = {
     .name           = "msa1",
     .long_name      = NULL_IF_CONFIG_SMALL("MS ATC Screen"),