Commit 46730e7a authored by Michael Niedermayer's avatar Michael Niedermayer

mux/chunked interleaver: better align duration chunks.

This code causes the chunking to tend toward more optimal
alignment between streams.
The first chunks can still be less optimal aligned
parent 69a96f9d
...@@ -555,9 +555,15 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, ...@@ -555,9 +555,15 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
st->interleaver_chunk_duration += pkt->duration; st->interleaver_chunk_duration += pkt->duration;
if ( (s->max_chunk_size && st->interleaver_chunk_size > s->max_chunk_size) if ( (s->max_chunk_size && st->interleaver_chunk_size > s->max_chunk_size)
|| (max && st->interleaver_chunk_duration > max)) { || (max && st->interleaver_chunk_duration > max)) {
st->interleaver_chunk_size = st->interleaver_chunk_size = 0;
st->interleaver_chunk_duration = 0;
this_pktl->pkt.flags |= CHUNK_START; this_pktl->pkt.flags |= CHUNK_START;
if (max && st->interleaver_chunk_duration > max) {
int64_t syncoffset = (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)*max/2;
int64_t syncto = av_rescale(pkt->dts + syncoffset, 1, max)*max - syncoffset;
st->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max;
} else
st->interleaver_chunk_duration = 0;
} }
} }
if (*next_point) { if (*next_point) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment