[FFmpeg-devel] [PATCH 1/2] mux: fix chunked_duration rounding anomaly

Michael Niedermayer michaelni at gmx.at
Tue Jan 15 20:15:15 CET 2013


a small value was rounded to 0 and then treated special as if
chunked_duration was 0. This led to a inconsistency that further led
to wrong interleaving

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavformat/mux.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 649b496..ae5e691 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -551,7 +551,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
 
     if (*next_point) {
         if (chunked) {
-            uint64_t max= av_rescale_q(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base);
+            uint64_t max= av_rescale_q_rnd(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base, AV_ROUND_UP);
             if (   st->interleaver_chunk_size     + pkt->size     <= s->max_chunk_size-1U
                 && st->interleaver_chunk_duration + pkt->duration <= max-1U) {
                 st->interleaver_chunk_size     += pkt->size;
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list