[FFmpeg-devel] [PATCH 21/34] avformat/matroskaenc: Avoid allocation of AVPacket

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Sep 6 05:27:49 EEST 2021


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavformat/matroskaenc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 6e34243f6b..250623535a 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -453,8 +453,6 @@ static void mkv_deinit(AVFormatContext *s)
 {
     MatroskaMuxContext *mkv = s->priv_data;
 
-    av_packet_free(&mkv->cur_audio_pkt);
-
     ffio_free_dyn_buf(&mkv->cluster_bc);
     ffio_free_dyn_buf(&mkv->info.bc);
     ffio_free_dyn_buf(&mkv->track.bc);
@@ -2683,9 +2681,8 @@ static int mkv_init(struct AVFormatContext *s)
     } else
         mkv->mode = MODE_MATROSKAv2;
 
-    mkv->cur_audio_pkt = av_packet_alloc();
-    if (!mkv->cur_audio_pkt)
-        return AVERROR(ENOMEM);
+    mkv->cur_audio_pkt = s->internal->pkt;
+
     mkv->tracks = av_mallocz_array(s->nb_streams, sizeof(*mkv->tracks));
     if (!mkv->tracks)
         return AVERROR(ENOMEM);
-- 
2.30.2



More information about the ffmpeg-devel mailing list