[FFmpeg-devel] [PATCH 2/2] mux/chunked interleaver: better align duration chunks.
Michael Niedermayer
michaelni at gmx.at
Wed Jan 16 00:16:01 CET 2013
This code causes the chunking to tend toward more optimal
alignment between streams.
The first chunks can still be less optimal aligned
---
libavformat/mux.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 0648b3f..11299c1 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -555,9 +555,14 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
st->interleaver_chunk_duration += pkt->duration;
if ( st->interleaver_chunk_size > s->max_chunk_size-1U
|| st->interleaver_chunk_duration > max-1U) {
- st->interleaver_chunk_size =
- st->interleaver_chunk_duration = 0;
+ st->interleaver_chunk_size = 0;
+ st->interleaver_chunk_duration -= max;
this_pktl->pkt.flags |= CHUNK_START;
+ if (max>1) {
+ 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;
+ }
}
}
if (*next_point) {
--
1.7.9.5
More information about the ffmpeg-devel
mailing list