[FFmpeg-cvslog] avformat/mxfenc: Avoid allocation for timecode track

Andreas Rheinhardt git at videolan.org
Sun Dec 19 03:43:18 EET 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Nov  7 22:11:22 2021 +0100| [bb69b734c74cc22301a4fa2c3263077ffe7064b1] | committer: Andreas Rheinhardt

avformat/mxfenc: Avoid allocation for timecode track

Reviewed-by: Tomas Härdin <tjoppen at acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bb69b734c74cc22301a4fa2c3263077ffe7064b1
---

 libavformat/mxfenc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index bb6d94bda5..1cdfc07382 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -420,6 +420,7 @@ typedef struct MXFContext {
     int track_instance_count; // used to generate MXFTrack uuids
     int cbr_index;           ///< use a constant bitrate index
     uint8_t unused_tags[MXF_NUM_TAGS];  ///< local tags that we know will not be used
+    MXFStreamContext timecode_track_priv;
 } MXFContext;
 
 static void mxf_write_uuid(AVIOContext *pb, enum MXFMetadataSetType type, int value)
@@ -2704,9 +2705,7 @@ static int mxf_init(AVFormatContext *s)
     mxf->timecode_track = av_mallocz(sizeof(*mxf->timecode_track));
     if (!mxf->timecode_track)
         return AVERROR(ENOMEM);
-    mxf->timecode_track->priv_data = av_mallocz(sizeof(MXFStreamContext));
-    if (!mxf->timecode_track->priv_data)
-        return AVERROR(ENOMEM);
+    mxf->timecode_track->priv_data = &mxf->timecode_track_priv;
     mxf->timecode_track->index = -1;
 
     return 0;
@@ -3079,10 +3078,7 @@ static void mxf_deinit(AVFormatContext *s)
 
     av_freep(&mxf->index_entries);
     av_freep(&mxf->body_partition_offset);
-    if (mxf->timecode_track) {
-        av_freep(&mxf->timecode_track->priv_data);
-        av_freep(&mxf->timecode_track);
-    }
+    av_freep(&mxf->timecode_track);
 }
 
 static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flush)



More information about the ffmpeg-cvslog mailing list