mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
avcodec/mvha: 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>
This commit is contained in:
parent
c1b0b8f9be
commit
4960c62944
3
configure
vendored
3
configure
vendored
@ -2892,8 +2892,7 @@ msmpeg4v3_encoder_select="h263_encoder"
|
|||||||
mss2_decoder_select="mpegvideodec qpeldsp vc1_decoder"
|
mss2_decoder_select="mpegvideodec qpeldsp vc1_decoder"
|
||||||
mts2_decoder_select="jpegtables mss34dsp"
|
mts2_decoder_select="jpegtables mss34dsp"
|
||||||
mv30_decoder_select="aandcttables blockdsp"
|
mv30_decoder_select="aandcttables blockdsp"
|
||||||
mvha_decoder_deps="zlib"
|
mvha_decoder_select="inflate_wrapper llviddsp"
|
||||||
mvha_decoder_select="llviddsp"
|
|
||||||
mwsc_decoder_select="inflate_wrapper"
|
mwsc_decoder_select="inflate_wrapper"
|
||||||
mxpeg_decoder_select="mjpeg_decoder"
|
mxpeg_decoder_select="mjpeg_decoder"
|
||||||
nellymoser_decoder_select="mdct sinewin"
|
nellymoser_decoder_select="mdct sinewin"
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "lossless_videodsp.h"
|
#include "lossless_videodsp.h"
|
||||||
|
#include "zlib_wrapper.h"
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ typedef struct MVHAContext {
|
|||||||
uint32_t prob[256];
|
uint32_t prob[256];
|
||||||
VLC vlc;
|
VLC vlc;
|
||||||
|
|
||||||
z_stream zstream;
|
FFZStream zstream;
|
||||||
LLVidDSPContext llviddsp;
|
LLVidDSPContext llviddsp;
|
||||||
} MVHAContext;
|
} MVHAContext;
|
||||||
|
|
||||||
@ -168,21 +169,22 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (type == MKTAG('L','Z','Y','V')) {
|
if (type == MKTAG('L','Z','Y','V')) {
|
||||||
ret = inflateReset(&s->zstream);
|
z_stream *const zstream = &s->zstream.zstream;
|
||||||
|
ret = inflateReset(zstream);
|
||||||
if (ret != Z_OK) {
|
if (ret != Z_OK) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
|
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
|
||||||
return AVERROR_EXTERNAL;
|
return AVERROR_EXTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->zstream.next_in = avpkt->data + 8;
|
zstream->next_in = avpkt->data + 8;
|
||||||
s->zstream.avail_in = avpkt->size - 8;
|
zstream->avail_in = avpkt->size - 8;
|
||||||
|
|
||||||
for (int p = 0; p < 3; p++) {
|
for (int p = 0; p < 3; p++) {
|
||||||
for (int y = 0; y < avctx->height; y++) {
|
for (int y = 0; y < avctx->height; y++) {
|
||||||
s->zstream.next_out = frame->data[p] + (avctx->height - y - 1) * frame->linesize[p];
|
zstream->next_out = frame->data[p] + (avctx->height - y - 1) * frame->linesize[p];
|
||||||
s->zstream.avail_out = avctx->width >> (p > 0);
|
zstream->avail_out = avctx->width >> (p > 0);
|
||||||
|
|
||||||
ret = inflate(&s->zstream, Z_SYNC_FLUSH);
|
ret = inflate(zstream, Z_SYNC_FLUSH);
|
||||||
if (ret != Z_OK && ret != Z_STREAM_END) {
|
if (ret != Z_OK && ret != Z_STREAM_END) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", ret);
|
av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", ret);
|
||||||
return AVERROR_EXTERNAL;
|
return AVERROR_EXTERNAL;
|
||||||
@ -279,29 +281,19 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
static av_cold int decode_init(AVCodecContext *avctx)
|
static av_cold int decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
MVHAContext *s = avctx->priv_data;
|
MVHAContext *s = avctx->priv_data;
|
||||||
int zret;
|
|
||||||
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_YUV422P;
|
avctx->pix_fmt = AV_PIX_FMT_YUV422P;
|
||||||
|
|
||||||
s->zstream.zalloc = Z_NULL;
|
|
||||||
s->zstream.zfree = Z_NULL;
|
|
||||||
s->zstream.opaque = Z_NULL;
|
|
||||||
zret = inflateInit(&s->zstream);
|
|
||||||
if (zret != Z_OK) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
|
|
||||||
return AVERROR_EXTERNAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ff_llviddsp_init(&s->llviddsp);
|
ff_llviddsp_init(&s->llviddsp);
|
||||||
|
|
||||||
return 0;
|
return ff_inflate_init(&s->zstream, avctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int decode_close(AVCodecContext *avctx)
|
static av_cold int decode_close(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
MVHAContext *s = avctx->priv_data;
|
MVHAContext *s = avctx->priv_data;
|
||||||
|
|
||||||
inflateEnd(&s->zstream);
|
ff_inflate_end(&s->zstream);
|
||||||
ff_free_vlc(&s->vlc);
|
ff_free_vlc(&s->vlc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user