]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/cngenc.c
avcodec: Constify AVCodecs
[ffmpeg] / libavcodec / cngenc.c
index e185c4a40a98a0020c7fbb11ff62b20212dbcef0..55826c75beb0f704095615f5bbf043598b631b1b 100644 (file)
@@ -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,
 };