1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00

avcodec/huffyuvdec: Cleanup generically on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-11-29 20:17:35 +01:00 committed by Andreas Rheinhardt
parent b3df59a5ea
commit 908187bbf6

View File

@ -36,6 +36,7 @@
#include "get_bits.h"
#include "huffyuv.h"
#include "huffyuvdsp.h"
#include "internal.h"
#include "lossless_videodsp.h"
#include "thread.h"
#include "libavutil/imgutils.h"
@ -348,7 +349,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
if ((ret = read_huffman_tables(s, avctx->extradata + 4,
avctx->extradata_size - 4)) < 0)
goto error;
return ret;
} else {
switch (avctx->bits_per_coded_sample & 7) {
case 1:
@ -376,7 +377,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->context = 0;
if ((ret = read_old_huffman_tables(s)) < 0)
goto error;
return ret;
}
if (s->version <= 2) {
@ -404,8 +405,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->alpha = 1;
break;
default:
ret = AVERROR_INVALIDDATA;
goto error;
return AVERROR_INVALIDDATA;
}
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
&s->chroma_h_shift,
@ -539,8 +539,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
avctx->pix_fmt = AV_PIX_FMT_YUVA420P16;
break;
default:
ret = AVERROR_INVALIDDATA;
goto error;
return AVERROR_INVALIDDATA;
}
}
@ -548,26 +547,19 @@ static av_cold int decode_init(AVCodecContext *avctx)
if ((avctx->pix_fmt == AV_PIX_FMT_YUV422P || avctx->pix_fmt == AV_PIX_FMT_YUV420P) && avctx->width & 1) {
av_log(avctx, AV_LOG_ERROR, "width must be even for this colorspace\n");
ret = AVERROR_INVALIDDATA;
goto error;
return AVERROR_INVALIDDATA;
}
if (s->predictor == MEDIAN && avctx->pix_fmt == AV_PIX_FMT_YUV422P &&
avctx->width % 4) {
av_log(avctx, AV_LOG_ERROR, "width must be a multiple of 4 "
"for this combination of colorspace and predictor type.\n");
ret = AVERROR_INVALIDDATA;
goto error;
return AVERROR_INVALIDDATA;
}
if ((ret = ff_huffyuv_alloc_temp(s)) < 0) {
ff_huffyuv_common_end(s);
goto error;
}
if ((ret = ff_huffyuv_alloc_temp(s)) < 0)
return ret;
return 0;
error:
decode_end(avctx);
return ret;
}
/** Subset of GET_VLC for use in hand-roller VLC code */
@ -1281,6 +1273,7 @@ const AVCodec ff_huffyuv_decoder = {
.decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND |
AV_CODEC_CAP_FRAME_THREADS,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
#if CONFIG_FFVHUFF_DECODER
@ -1295,6 +1288,7 @@ const AVCodec ff_ffvhuff_decoder = {
.decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND |
AV_CODEC_CAP_FRAME_THREADS,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
#endif /* CONFIG_FFVHUFF_DECODER */
@ -1310,5 +1304,6 @@ const AVCodec ff_hymt_decoder = {
.decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND |
AV_CODEC_CAP_FRAME_THREADS,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
#endif /* CONFIG_HYMT_DECODER */