[FFmpeg-devel] [PATCH 34/34] avformat/mux: Remove unnecessary av_packet_unref()

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Sep 6 05:28:02 EEST 2021


AVFormatInternal.parse_pkt is always blank after having been used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavformat/mux.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index c5e07aaf1c..47883ece37 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1196,8 +1196,6 @@ int av_write_frame(AVFormatContext *s, AVPacket *in)
          * The following avoids copying in's data unnecessarily.
          * Copying side data is unavoidable as a bitstream filter
          * may change it, e.g. free it on errors. */
-        av_packet_unref(pkt);
-        pkt->buf  = NULL;
         pkt->data = in->data;
         pkt->size = in->size;
         ret = av_packet_copy_props(pkt, in);
@@ -1240,7 +1238,6 @@ int av_write_trailer(AVFormatContext *s)
     AVPacket *const pkt = s->internal->parse_pkt;
     int i, ret1, ret = 0;
 
-    av_packet_unref(pkt);
     for (i = 0; i < s->nb_streams; i++) {
         if (s->streams[i]->internal->bsfc) {
             ret1 = write_packets_from_bsfs(s, s->streams[i], pkt, 1/*interleaved*/);
@@ -1345,7 +1342,6 @@ static int write_uncoded_frame_internal(AVFormatContext *s, int stream_index,
 
         if (!framep)
             goto fail;
-        av_packet_unref(pkt);
         pkt->buf = av_buffer_create((void *)framep, bufsize,
                                    uncoded_frame_free, NULL, 0);
         if (!pkt->buf) {
-- 
2.30.2



More information about the ffmpeg-devel mailing list