summaryrefslogtreecommitdiff
path: root/libavcodec/g722enc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-14 17:21:12 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-19 18:46:45 +0200
commit23daf8e67fd842a70b783105025ddb483c036472 (patch)
tree32b1c90e9456728f393efcc96541df03e34761d6 /libavcodec/g722enc.c
parentb14c42aa2a3ee61e452d57877b3a695901ba6137 (diff)
downloadffmpeg-23daf8e67fd842a70b783105025ddb483c036472.tar.gz
avcodec/g722enc: Cleanup generically on init failure
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/g722enc.c')
-rw-r--r--libavcodec/g722enc.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c
index 25b61df19e..9357f170fe 100644
--- a/libavcodec/g722enc.c
+++ b/libavcodec/g722enc.c
@@ -59,7 +59,6 @@ static av_cold int g722_encode_close(AVCodecContext *avctx)
static av_cold int g722_encode_init(AVCodecContext * avctx)
{
G722Context *c = avctx->priv_data;
- int ret;
c->band[0].scale_factor = 8;
c->band[1].scale_factor = 2;
@@ -73,10 +72,8 @@ static av_cold int g722_encode_init(AVCodecContext * avctx)
c->paths[i] = av_mallocz_array(max_paths, sizeof(**c->paths));
c->node_buf[i] = av_mallocz_array(frontier, 2 * sizeof(**c->node_buf));
c->nodep_buf[i] = av_mallocz_array(frontier, 2 * sizeof(**c->nodep_buf));
- if (!c->paths[i] || !c->node_buf[i] || !c->nodep_buf[i]) {
- ret = AVERROR(ENOMEM);
- goto error;
- }
+ if (!c->paths[i] || !c->node_buf[i] || !c->nodep_buf[i])
+ return AVERROR(ENOMEM);
}
}
@@ -118,9 +115,6 @@ static av_cold int g722_encode_init(AVCodecContext * avctx)
ff_g722dsp_init(&c->dsp);
return 0;
-error:
- g722_encode_close(avctx);
- return ret;
}
static const int16_t low_quant[33] = {
@@ -387,4 +381,5 @@ AVCodec ff_adpcm_g722_encoder = {
.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE },
.channel_layouts = (const uint64_t[]){ AV_CH_LAYOUT_MONO, 0 },
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};