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/mxfenc.c | |
parent | 9190302b2e6fb69e8fd7fb1c594857be016ed4b2 (diff) |
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/mxfenc.c')
-rw-r--r-- | libavformat/mxfenc.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 56facbe4b7..c36ebef932 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -3096,7 +3096,7 @@ static void mxf_deinit(AVFormatContext *s) } } -static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush) +static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flush) { FFFormatContext *const si = ffformatcontext(s); int i, stream_count = 0; @@ -3161,16 +3161,17 @@ static int mxf_compare_timestamps(AVFormatContext *s, const AVPacket *next, (next->dts == pkt->dts && sc->order < sc2->order); } -static int mxf_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush) +static int mxf_interleave(AVFormatContext *s, AVPacket *pkt, + int flush, int has_packet) { int ret; - if (pkt) { + if (has_packet) { MXFStreamContext *sc = s->streams[pkt->stream_index]->priv_data; pkt->pts = pkt->dts = sc->pkt_cnt++; if ((ret = ff_interleave_add_packet(s, pkt, mxf_compare_timestamps)) < 0) return ret; } - return mxf_interleave_get_packet(s, out, NULL, flush); + return mxf_interleave_get_packet(s, pkt, flush); } #define MXF_COMMON_OPTIONS \ |