summaryrefslogtreecommitdiff
path: root/libavformat/internal.h
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-05 17:33:37 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-10-03 20:50:50 +0200
commit4fa8daab799572c743ad2e966d89f038f1b4cc4d (patch)
tree9d287bf508dca407bec77c3be4ceb53477ff3411 /libavformat/internal.h
parent9190302b2e6fb69e8fd7fb1c594857be016ed4b2 (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/internal.h')
-rw-r--r--libavformat/internal.h19
1 files changed, 6 insertions, 13 deletions
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 6f1f1c072a..98341ba217 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -107,7 +107,8 @@ typedef struct FFFormatContext {
struct PacketList *parse_queue_end;
/**
* The generic code uses this as a temporary packet
- * to parse packets; it may also be used for other means
+ * to parse packets or for muxing, especially flushing.
+ * For demuxers, it may also be used for other means
* for short periods that are guaranteed not to overlap
* with calls to av_read_frame() (or ff_read_packet())
* or with each other.
@@ -746,18 +747,10 @@ int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb,
/**
* Interleave an AVPacket per dts so it can be muxed.
- *
- * @param s an AVFormatContext for output. pkt resp. out will be added to
- * resp. taken from its packet buffer.
- * @param out the interleaved packet will be output here
- * @param pkt the input packet; will be blank on return if not NULL
- * @param flush 1 if no further packets are available as input and all
- * remaining packets should be output
- * @return 1 if a packet was output, 0 if no packet could be output
- * (in which case out may be uninitialized), < 0 if an error occurred
- */
-int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
- AVPacket *pkt, int flush);
+ * See the documentation of AVOutputFormat.interleave_packet for details.
+ */
+int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
+ int flush, int has_packet);
void ff_free_stream(AVFormatContext *s, AVStream *st);