diff mbox series

[FFmpeg-devel,1/5] avcodec: Remove redundant freeing of extradata of encoders

Message ID HE1PR0301MB2154C0873CD26F07D901843B8F4D9@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 1c7f252783aec37e4ff8049476386f63afe91756
Headers show
Series [FFmpeg-devel,1/5] avcodec: Remove redundant freeing of extradata of encoders | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 15, 2021, 2:02 a.m. UTC
AVCodecContext.extradata is freed generically by libavformat for
encoders, so it is unnecessary for an encoder to do it on its own.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/flacenc.c       | 2 --
 libavcodec/huffyuvenc.c    | 1 -
 libavcodec/lclenc.c        | 1 -
 libavcodec/libfdk-aacenc.c | 1 -
 libavcodec/libkvazaar.c    | 3 ---
 libavcodec/libopusenc.c    | 2 --
 libavcodec/libspeexenc.c   | 1 -
 libavcodec/libtheoraenc.c  | 1 -
 libavcodec/libvorbisenc.c  | 1 -
 libavcodec/libx264.c       | 1 -
 libavcodec/libxavs.c       | 1 -
 libavcodec/libxvid.c       | 1 -
 libavcodec/mpegvideo_enc.c | 2 --
 libavcodec/opusenc.c       | 1 -
 libavcodec/vorbisenc.c     | 2 --
 15 files changed, 21 deletions(-)

Comments

Anton Khirnov April 18, 2021, 6:44 a.m. UTC | #1
Quoting Andreas Rheinhardt (2021-04-15 04:02:35)
> AVCodecContext.extradata is freed generically by libavformat for

you mean libavcodec?
diff mbox series

Patch

diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 05a85d830f..32b2465279 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -1455,8 +1455,6 @@  static av_cold int flac_encode_close(AVCodecContext *avctx)
         av_freep(&s->md5_buffer);
         ff_lpc_end(&s->lpc_ctx);
     }
-    av_freep(&avctx->extradata);
-    avctx->extradata_size = 0;
     return 0;
 }
 
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 2882433db5..7e5c8f7fac 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -1038,7 +1038,6 @@  static av_cold int encode_end(AVCodecContext *avctx)
 
     ff_huffyuv_common_end(s);
 
-    av_freep(&avctx->extradata);
     av_freep(&avctx->stats_out);
 
     return 0;
diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c
index 4fe52b40da..fbf65e5428 100644
--- a/libavcodec/lclenc.c
+++ b/libavcodec/lclenc.c
@@ -161,7 +161,6 @@  static av_cold int encode_end(AVCodecContext *avctx)
 {
     LclEncContext *c = avctx->priv_data;
 
-    av_freep(&avctx->extradata);
     deflateEnd(&c->zstream);
 
     return 0;
diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index 6494c11ddc..692508eaa3 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -112,7 +112,6 @@  static int aac_encode_close(AVCodecContext *avctx)
 
     if (s->handle)
         aacEncClose(&s->handle);
-    av_freep(&avctx->extradata);
     ff_af_queue_close(&s->afq);
 
     return 0;
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 4432649853..286d97a318 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -156,9 +156,6 @@  static av_cold int libkvazaar_close(AVCodecContext *avctx)
         ctx->api->config_destroy(ctx->config);
     }
 
-    if (avctx->extradata)
-        av_freep(&avctx->extradata);
-
     return 0;
 }
 
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index 70d17f802b..6c7ec4db3c 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -432,7 +432,6 @@  static av_cold int libopus_encode_init(AVCodecContext *avctx)
 
 fail:
     opus_multistream_encoder_destroy(enc);
-    av_freep(&avctx->extradata);
     return ret;
 }
 
@@ -538,7 +537,6 @@  static av_cold int libopus_encode_close(AVCodecContext *avctx)
     ff_af_queue_close(&opus->afq);
 
     av_freep(&opus->samples);
-    av_freep(&avctx->extradata);
 
     return 0;
 }
diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c
index 6a37dbc76c..9ea35a763f 100644
--- a/libavcodec/libspeexenc.c
+++ b/libavcodec/libspeexenc.c
@@ -318,7 +318,6 @@  static av_cold int encode_close(AVCodecContext *avctx)
     speex_encoder_destroy(s->enc_state);
 
     ff_af_queue_close(&s->afq);
-    av_freep(&avctx->extradata);
 
     return 0;
 }
diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index 16966ed433..8a7b80e174 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -365,7 +365,6 @@  static av_cold int encode_close(AVCodecContext* avc_context)
     th_encode_free(h->t_state);
     av_freep(&h->stats);
     av_freep(&avc_context->stats_out);
-    av_freep(&avc_context->extradata);
     avc_context->extradata_size = 0;
 
     return 0;
diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c
index bf94764954..9d36457328 100644
--- a/libavcodec/libvorbisenc.c
+++ b/libavcodec/libvorbisenc.c
@@ -196,7 +196,6 @@  static av_cold int libvorbis_encode_close(AVCodecContext *avctx)
 
     av_fifo_freep(&s->pkt_fifo);
     ff_af_queue_close(&s->afq);
-    av_freep(&avctx->extradata);
 
     av_vorbis_parse_free(&s->vp);
 
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 4ddc4973a4..4535d23848 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -508,7 +508,6 @@  static av_cold int X264_close(AVCodecContext *avctx)
 {
     X264Context *x4 = avctx->priv_data;
 
-    av_freep(&avctx->extradata);
     av_freep(&x4->sei);
     av_freep(&x4->reordered_opaque);
 
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index a83b93b836..62f7e9dfa7 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -228,7 +228,6 @@  static av_cold int XAVS_close(AVCodecContext *avctx)
 {
     XavsContext *x4 = avctx->priv_data;
 
-    av_freep(&avctx->extradata);
     av_freep(&x4->sei);
     av_freep(&x4->pts_buffer);
 
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index cb9135436a..a74a2c1dd2 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -883,7 +883,6 @@  static av_cold int xvid_encode_close(AVCodecContext *avctx)
         x->encoder_handle = NULL;
     }
 
-    av_freep(&avctx->extradata);
     if (x->twopassbuffer) {
         av_freep(&x->twopassbuffer);
         av_freep(&x->old_twopassbuffer);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 7909a5630a..6435c0f668 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1032,8 +1032,6 @@  av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
         s->out_format == FMT_MJPEG)
         ff_mjpeg_encode_close(s);
 
-    av_freep(&avctx->extradata);
-
     for (i = 0; i < FF_ARRAY_ELEMS(s->tmp_frames); i++)
         av_frame_free(&s->tmp_frames[i]);
 
diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index 8bc9e9dc4a..5822482bbf 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -614,7 +614,6 @@  static av_cold int opus_encode_end(AVCodecContext *avctx)
     ff_af_queue_close(&s->afq);
     ff_opus_psy_end(&s->psyctx);
     ff_bufqueue_discard_all(&s->bufqueue);
-    av_freep(&avctx->extradata);
 
     return 0;
 }
diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index 1b0ab3cadb..091338b41e 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -1254,8 +1254,6 @@  static av_cold int vorbis_encode_close(AVCodecContext *avctx)
     ff_af_queue_close(&venc->afq);
     ff_bufqueue_discard_all(&venc->bufqueue);
 
-    av_freep(&avctx->extradata);
-
     return 0 ;
 }