Skip to content

Commit

Permalink
avformat/mxfenc: Avoid allocation for timecode track
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Härdin <[email protected]>
Signed-off-by: Andreas Rheinhardt <[email protected]>
  • Loading branch information
mkver committed Dec 19, 2021
1 parent 25ddf88 commit bb69b73
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions libavformat/mxfenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bb69b73

Please sign in to comment.