aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-15 08:33:22 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-19 18:52:41 +0200
commitc7867b6ed113d1fe71664cd29914af575e285aa0 (patch)
treec29df3f4c3041644041082a2fd51e50c3ce18e85
parente9831b1e985a61f1f0089eccc877f2e5add2d58c (diff)
downloadffmpeg-c7867b6ed113d1fe71664cd29914af575e285aa0.tar.gz
avcodec/mpegaudiodec*: Cleanup generically on init failure
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r--libavcodec/mpegaudiodec_fixed.c1
-rw-r--r--libavcodec/mpegaudiodec_float.c1
-rw-r--r--libavcodec/mpegaudiodec_template.c11
3 files changed, 5 insertions, 8 deletions
diff --git a/libavcodec/mpegaudiodec_fixed.c b/libavcodec/mpegaudiodec_fixed.c
index ad7ceb20b6..a2c433954b 100644
--- a/libavcodec/mpegaudiodec_fixed.c
+++ b/libavcodec/mpegaudiodec_fixed.c
@@ -116,5 +116,6 @@ AVCodec ff_mp3on4_decoder = {
.flush = flush_mp3on4,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
AV_SAMPLE_FMT_NONE },
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
#endif
diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c
index 0defdf3af1..4aa52d4f53 100644
--- a/libavcodec/mpegaudiodec_float.c
+++ b/libavcodec/mpegaudiodec_float.c
@@ -116,5 +116,6 @@ AVCodec ff_mp3on4float_decoder = {
.flush = flush_mp3on4,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
#endif
diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c
index d2b72497e1..12c1964446 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -1908,16 +1908,14 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx)
// Allocate zeroed memory for the first decoder context
s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
if (!s->mp3decctx[0])
- goto alloc_fail;
+ return AVERROR(ENOMEM);
// Put decoder context in place to make init_decode() happy
avctx->priv_data = s->mp3decctx[0];
ret = decode_init(avctx);
// Restore mp3on4 context pointer
avctx->priv_data = s;
- if (ret < 0) {
- decode_close_mp3on4(avctx);
+ if (ret < 0)
return ret;
- }
s->mp3decctx[0]->adu_mode = 1; // Set adu mode
/* Create a separate codec/context for each frame (first is already ok).
@@ -1926,7 +1924,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx)
for (i = 1; i < s->frames; i++) {
s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));
if (!s->mp3decctx[i])
- goto alloc_fail;
+ return AVERROR(ENOMEM);
s->mp3decctx[i]->adu_mode = 1;
s->mp3decctx[i]->avctx = avctx;
s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
@@ -1934,9 +1932,6 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx)
}
return 0;
-alloc_fail:
- decode_close_mp3on4(avctx);
- return AVERROR(ENOMEM);
}