diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-03-15 11:26:13 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-03-19 00:18:35 +0100 |
commit | 93c70b85557a440fe3551cc7bd43b39035e3b970 (patch) | |
tree | a6ef70d221464cb6a3cc028a8e9295ea19e6dc6f /libavcodec | |
parent | 3d4634f1ff7ca3f18a4886e8336bda5a7e4ab3a8 (diff) |
avcodec/zerocodec: Use ff_inflate_init/end()
This fixes the problem of potentially closing a z_stream
that has never been successfully initialized.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/zerocodec.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/libavcodec/zerocodec.c b/libavcodec/zerocodec.c index 3bd04567a1..86cdf96f5a 100644 --- a/libavcodec/zerocodec.c +++ b/libavcodec/zerocodec.c @@ -20,11 +20,12 @@ #include "avcodec.h" #include "internal.h" +#include "zlib_wrapper.h" #include "libavutil/common.h" typedef struct ZeroCodecContext { AVFrame *previous_frame; - z_stream zstream; + FFZStream zstream; } ZeroCodecContext; static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, @@ -33,7 +34,7 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, ZeroCodecContext *zc = avctx->priv_data; AVFrame *pic = data; AVFrame *prev_pic = zc->previous_frame; - z_stream *zstream = &zc->zstream; + z_stream *const zstream = &zc->zstream.zstream; uint8_t *prev = prev_pic->data[0]; uint8_t *dst; int i, j, zret, ret; @@ -106,7 +107,7 @@ static av_cold int zerocodec_decode_close(AVCodecContext *avctx) av_frame_free(&zc->previous_frame); - inflateEnd(&zc->zstream); + ff_inflate_end(&zc->zstream); return 0; } @@ -114,27 +115,15 @@ static av_cold int zerocodec_decode_close(AVCodecContext *avctx) static av_cold int zerocodec_decode_init(AVCodecContext *avctx) { ZeroCodecContext *zc = avctx->priv_data; - z_stream *zstream = &zc->zstream; - int zret; avctx->pix_fmt = AV_PIX_FMT_UYVY422; avctx->bits_per_raw_sample = 8; - zstream->zalloc = Z_NULL; - zstream->zfree = Z_NULL; - zstream->opaque = Z_NULL; - - zret = inflateInit(zstream); - if (zret != Z_OK) { - av_log(avctx, AV_LOG_ERROR, "Could not initialize inflate: %d.\n", zret); - return AVERROR(ENOMEM); - } - zc->previous_frame = av_frame_alloc(); if (!zc->previous_frame) return AVERROR(ENOMEM); - return 0; + return ff_inflate_init(&zc->zstream, avctx); } static void zerocodec_decode_flush(AVCodecContext *avctx) |