X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fcngenc.c;h=55826c75beb0f704095615f5bbf043598b631b1b;hb=b9fff6e15e73dc995695db9be8db084238cca14c;hp=e185c4a40a98a0020c7fbb11ff62b20212dbcef0;hpb=768b07e3bca7e81d2f9c60badb3973d3d88481dc;p=ffmpeg diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c index e185c4a40a9..55826c75beb 100644 --- a/libavcodec/cngenc.c +++ b/libavcodec/cngenc.c @@ -37,8 +37,8 @@ static av_cold int cng_encode_close(AVCodecContext *avctx) { CNGContext *p = avctx->priv_data; ff_lpc_end(&p->lpc); - av_free(p->samples32); - av_free(p->ref_coef); + av_freep(&p->samples32); + av_freep(&p->ref_coef); return 0; } @@ -58,10 +58,8 @@ static av_cold int cng_encode_init(AVCodecContext *avctx) return ret; p->samples32 = av_malloc_array(avctx->frame_size, sizeof(*p->samples32)); p->ref_coef = av_malloc_array(p->order, sizeof(*p->ref_coef)); - if (!p->samples32 || !p->ref_coef) { - cng_encode_close(avctx); + if (!p->samples32 || !p->ref_coef) return AVERROR(ENOMEM); - } return 0; } @@ -102,7 +100,7 @@ static int cng_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, return 0; } -AVCodec ff_comfortnoise_encoder = { +const AVCodec ff_comfortnoise_encoder = { .name = "comfortnoise", .long_name = NULL_IF_CONFIG_SMALL("RFC 3389 comfort noise generator"), .type = AVMEDIA_TYPE_AUDIO, @@ -113,4 +111,5 @@ AVCodec ff_comfortnoise_encoder = { .close = cng_encode_close, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, };