aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-11-29 20:17:35 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-05-02 02:58:47 +0200
commit908187bbf68e3c43f097f098b24e763c17187da9 (patch)
treecc07c744c6467d7e0b51bd5fdae60c041db0461f /libavcodec
parentb3df59a5ea87b736ec38020a37ae4c3ebfe61a90 (diff)
downloadffmpeg-908187bbf68e3c43f097f098b24e763c17187da9.tar.gz
avcodec/huffyuvdec: Cleanup generically on init failure
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/huffyuvdec.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index 62907ecb5e..52d8705b05 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -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 */