]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/zerocodec.c
avcodec/pcm-dvd: print actual block size values in block size changed warning
[ffmpeg] / libavcodec / zerocodec.c
index 80264b34d6e1b7525996cde790c0bc2c8f4a4391..9f6c37c02a5120007bc07ef1de488bb0dec3fb94 100644 (file)
@@ -23,7 +23,7 @@
 #include "libavutil/common.h"
 
 typedef struct {
-    AVFrame  previous_frame;
+    AVFrame  *previous_frame;
     z_stream zstream;
 } ZeroCodecContext;
 
@@ -32,7 +32,7 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data,
 {
     ZeroCodecContext *zc = avctx->priv_data;
     AVFrame *pic         = data;
-    AVFrame *prev_pic    = &zc->previous_frame;
+    AVFrame *prev_pic    = zc->previous_frame;
     z_stream *zstream    = &zc->zstream;
     uint8_t *prev        = prev_pic->data[0];
     uint8_t *dst;
@@ -91,8 +91,8 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data,
         dst  -= pic->linesize[0];
     }
 
-    av_frame_unref(&zc->previous_frame);
-    if ((ret = av_frame_ref(&zc->previous_frame, pic)) < 0)
+    av_frame_unref(zc->previous_frame);
+    if ((ret = av_frame_ref(zc->previous_frame, pic)) < 0)
         return ret;
 
     *got_frame = 1;
@@ -104,7 +104,7 @@ static av_cold int zerocodec_decode_close(AVCodecContext *avctx)
 {
     ZeroCodecContext *zc = avctx->priv_data;
 
-    av_frame_unref(&zc->previous_frame);
+    av_frame_free(&zc->previous_frame);
 
     inflateEnd(&zc->zstream);
 
@@ -130,6 +130,12 @@ static av_cold int zerocodec_decode_init(AVCodecContext *avctx)
         return AVERROR(ENOMEM);
     }
 
+    zc->previous_frame = av_frame_alloc();
+    if (!zc->previous_frame) {
+        zerocodec_decode_close(avctx);
+        return AVERROR(ENOMEM);
+    }
+
     return 0;
 }