[FFmpeg-cvslog] avformat/mux: Avoid overhead of packet list in case of single streams
Andreas Rheinhardt
git at videolan.org
Fri Nov 19 19:20:17 EET 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat Oct 9 16:27:03 2021 +0200| [52d13d54e139d23a841e7d7a5cd09dc8904b150a] | committer: Andreas Rheinhardt
avformat/mux: Avoid overhead of packet list in case of single streams
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Reviewed-by: James Almer <jamrial at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=52d13d54e139d23a841e7d7a5cd09dc8904b150a
---
libavformat/internal.h | 7 +++++++
libavformat/mux.c | 10 +++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 290e114506..20e93d9267 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -759,6 +759,13 @@ int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb,
int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
int flush, int has_packet);
+/**
+ * Interleave packets directly in the order in which they arrive
+ * without any sort of buffering.
+ */
+int ff_interleave_packet_passthrough(AVFormatContext *s, AVPacket *pkt,
+ int flush, int has_packet);
+
void ff_free_stream(AVFormatContext *s, AVStream *st);
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id);
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 884640611a..1389bcc003 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -336,7 +336,9 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
}
si->interleave_packet = of->interleave_packet;
if (!si->interleave_packet)
- si->interleave_packet = ff_interleave_packet_per_dts;
+ si->interleave_packet = si->nb_interleaved_streams > 1 ?
+ ff_interleave_packet_per_dts :
+ ff_interleave_packet_passthrough;
if (!s->priv_data && of->priv_data_size > 0) {
s->priv_data = av_mallocz(of->priv_data_size);
@@ -1028,6 +1030,12 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
}
}
+int ff_interleave_packet_passthrough(AVFormatContext *s, AVPacket *pkt,
+ int flush, int has_packet)
+{
+ return has_packet;
+}
+
int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset)
{
AVStream *st;
More information about the ffmpeg-cvslog
mailing list