diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-05 17:33:37 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-10-03 20:50:50 +0200 |
commit | 4fa8daab799572c743ad2e966d89f038f1b4cc4d (patch) | |
tree | 9d287bf508dca407bec77c3be4ceb53477ff3411 /libavformat/gxfenc.c | |
parent | 9190302b2e6fb69e8fd7fb1c594857be016ed4b2 (diff) | |
download | ffmpeg-4fa8daab799572c743ad2e966d89f038f1b4cc4d.tar.gz |
avformat/mux: Don't use stack packet when writing interleaved packets
Currently the interleave_packet functions use a packet for
a new packet to be interleaved (may be NULL if there is none) and
a packet for output; said packet is always a stack packet in
interleaved_write_packet(). But all the interleave_packet functions
in use first move the packet to the packet list and then check whether
a packet can be returned, i.e. the effective lifetime of the new packet
ends before the packet for output is touched.
So one can use one packet both for input and output by adding a new
parameter that indicates whether there is a packet to add to the packet
list; there is just one complication: In case the muxer is flushed,
there is no packet available. This can be solved by reusing one of
the packets from AVFormatInternal. They are currently unused when
flushing in av_interleaved_write_frame().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/gxfenc.c')
-rw-r--r-- | libavformat/gxfenc.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 8cc3bd456e..133d1e9fb3 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -992,10 +992,11 @@ static int gxf_compare_field_nb(AVFormatContext *s, const AVPacket *next, (field_nb[1] == field_nb[0] && sc[1]->order > sc[0]->order); } -static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush) +static int gxf_interleave_packet(AVFormatContext *s, AVPacket *pkt, + int flush, int has_packet) { int ret; - if (pkt) { + if (has_packet) { AVStream *st = s->streams[pkt->stream_index]; GXFStreamContext *sc = st->priv_data; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) @@ -1006,7 +1007,7 @@ static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pk if ((ret = ff_interleave_add_packet(s, pkt, gxf_compare_field_nb)) < 0) return ret; } - return ff_interleave_packet_per_dts(s, out, NULL, flush); + return ff_interleave_packet_per_dts(s, pkt, flush, 0); } const AVOutputFormat ff_gxf_muxer = { |