diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-01-16 00:03:36 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-01-17 15:11:02 +0100 |
commit | 46730e7a0c1a934be05def268b992239b94269c3 (patch) | |
tree | 7015422a571b84ed12c53fccc70905c31dea0697 /libavformat/mux.c | |
parent | 69a96f9d4cf6d5a7f5b568c713b48d78452838fd (diff) | |
download | ffmpeg-46730e7a0c1a934be05def268b992239b94269c3.tar.gz |
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
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r-- | libavformat/mux.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c index ccb1530d78..98ec7a4cf2 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -555,9 +555,15 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, st->interleaver_chunk_duration += pkt->duration; if ( (s->max_chunk_size && st->interleaver_chunk_size > s->max_chunk_size) || (max && st->interleaver_chunk_duration > max)) { - st->interleaver_chunk_size = - st->interleaver_chunk_duration = 0; + st->interleaver_chunk_size = 0; 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) { |