[FFmpeg-cvslog] avformat/movenc: Avoid allocation for timecode track
Andreas Rheinhardt
git at videolan.org
Mon Oct 5 02:48:46 EEST 2020
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Mon Sep 28 19:27:20 2020 +0200| [290de647595051034d8f021f24bb4610b2f39943] | committer: Andreas Rheinhardt
avformat/movenc: Avoid allocation for timecode track
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=290de647595051034d8f021f24bb4610b2f39943
---
libavformat/movenc.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5454a9172c..fea8a86192 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6165,11 +6165,12 @@ static int mov_check_timecode_track(AVFormatContext *s, AVTimecode *tc, int src_
static int mov_create_timecode_track(AVFormatContext *s, int index, int src_index, AVTimecode tc)
{
- int ret;
MOVMuxContext *mov = s->priv_data;
MOVTrack *track = &mov->tracks[index];
AVStream *src_st = s->streams[src_index];
- AVPacket pkt = {.stream_index = index, .flags = AV_PKT_FLAG_KEY, .size = 4};
+ uint8_t data[4];
+ AVPacket pkt = { .data = data, .stream_index = index,
+ .flags = AV_PKT_FLAG_KEY, .size = 4 };
AVRational rate = find_fps(s, src_st);
/* tmcd track based on video stream */
@@ -6192,13 +6193,8 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde
track->st->avg_frame_rate = av_inv_q(rate);
/* the tmcd track just contains one packet with the frame number */
- pkt.data = av_malloc(pkt.size);
- if (!pkt.data)
- return AVERROR(ENOMEM);
AV_WB32(pkt.data, tc.start);
- ret = ff_mov_write_packet(s, &pkt);
- av_free(pkt.data);
- return ret;
+ return ff_mov_write_packet(s, &pkt);
}
/*
More information about the ffmpeg-cvslog
mailing list