]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/zerocodec.c
lavc: mark the old audio/video encoding API as deprecated
[ffmpeg] / libavcodec / zerocodec.c
index 135a809d185d63fd4ab1734a53a0374ba1094378..1419e84a3415af20aee54adca4b6d735c636b98b 100644 (file)
@@ -22,8 +22,8 @@
 #include "internal.h"
 #include "libavutil/common.h"
 
-typedef struct {
-    AVFrame  previous_frame;
+typedef struct ZeroCodecContext {
+    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;
@@ -93,8 +93,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;
@@ -106,7 +106,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);
 
@@ -132,6 +132,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;
 }
 
@@ -144,5 +150,5 @@ AVCodec ff_zerocodec_decoder = {
     .init           = zerocodec_decode_init,
     .decode         = zerocodec_decode_frame,
     .close          = zerocodec_decode_close,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = AV_CODEC_CAP_DR1,
 };