diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-11-09 10:14:46 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-11-16 13:24:44 +0100 |
commit | 6886a85f5ca9402c0b589a9af7d53ce53f8a8000 (patch) | |
tree | b7567194a0bcd69eb1350a1f0e3158d2b76cb4aa /libavcodec/zerocodec.c | |
parent | a837c4f2df96a30bf9aa4115b426d608487c7101 (diff) | |
download | ffmpeg-6886a85f5ca9402c0b589a9af7d53ce53f8a8000.tar.gz |
zerocodec: use the AVFrame API properly.
Diffstat (limited to 'libavcodec/zerocodec.c')
-rw-r--r-- | libavcodec/zerocodec.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libavcodec/zerocodec.c b/libavcodec/zerocodec.c index 135a809d18..eeba2dedf7 100644 --- a/libavcodec/zerocodec.c +++ b/libavcodec/zerocodec.c @@ -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; @@ -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; } |