summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-10-09 16:13:32 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-11-19 17:47:04 +0100
commitc03e53aea7c73ea90c21eea712c50ba227f8d164 (patch)
tree06c6a61dd27019e2c619908f45fe70a8b7729387 /libavformat/mux.c
parent3188b606d7ed74080e9d8c84a35430421184d043 (diff)
downloadffmpeg-c03e53aea7c73ea90c21eea712c50ba227f8d164.tar.gz
avformat/mux: Store pointer to interleavement func in FFFormatContext
It avoids branches lateron and will allow to easily avoid the overhead of the linked list currently in use in case there is only one stream. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index a6e1a08be0..884640611a 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -334,6 +334,9 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT)
si->nb_interleaved_streams++;
}
+ si->interleave_packet = of->interleave_packet;
+ if (!si->interleave_packet)
+ si->interleave_packet = ff_interleave_packet_per_dts;
if (!s->priv_data && of->priv_data_size > 0) {
s->priv_data = av_mallocz(of->priv_data_size);
@@ -1054,19 +1057,6 @@ const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream)
return NULL;
}
-/**
- * A wrapper around AVOutputFormat.interleave_packet.
- * See its documentation for details.
- */
-static int interleave_packet(AVFormatContext *s, AVPacket *pkt,
- int flush, int has_packet)
-{
- if (s->oformat->interleave_packet) {
- return s->oformat->interleave_packet(s, pkt, flush, has_packet);
- } else
- return ff_interleave_packet_per_dts(s, pkt, flush, has_packet);
-}
-
static int check_bitstream(AVFormatContext *s, FFStream *sti, AVPacket *pkt)
{
int ret;
@@ -1089,8 +1079,9 @@ static int check_bitstream(AVFormatContext *s, FFStream *sti, AVPacket *pkt)
static int interleaved_write_packet(AVFormatContext *s, AVPacket *pkt,
int flush, int has_packet)
{
+ FFFormatContext *const si = ffformatcontext(s);
for (;; ) {
- int ret = interleave_packet(s, pkt, flush, has_packet);
+ int ret = si->interleave_packet(s, pkt, flush, has_packet);
if (ret <= 0)
return ret;