X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fmux.c;h=d93931518ab7ac7cf95141283cc0fcad3120a9da;hb=b454c64e0311d813fef9c22cf34f83c2ce77ab23;hp=c34a2946c773a108099f21b3a7752a6309c65d68;hpb=e730c3a2cbc4070f3e1799d2a6789f239f7377b1;p=ffmpeg diff --git a/libavformat/mux.c b/libavformat/mux.c index c34a2946c77..d93931518ab 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -395,7 +395,7 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) return ret; } - if ((ret = init_pts(s) < 0)) + if ((ret = init_pts(s)) < 0) return ret; return 0; @@ -549,20 +549,21 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, next_point = &s->packet_buffer; } - if (*next_point) { - if (chunked) { - uint64_t max= av_rescale_q(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base); - 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; - st->interleaver_chunk_duration += pkt->duration; - goto next_non_null; - } else { - st->interleaver_chunk_size = - st->interleaver_chunk_duration = 0; - this_pktl->pkt.flags |= CHUNK_START; - } + if (chunked) { + 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; + st->interleaver_chunk_duration += pkt->duration; + } else { + st->interleaver_chunk_size = + st->interleaver_chunk_duration = 0; + this_pktl->pkt.flags |= CHUNK_START; } + } + if (*next_point) { + if (chunked && !(this_pktl->pkt.flags & CHUNK_START)) + goto next_non_null; if (compare(s, &s->packet_buffer_end->pkt, pkt)) { while ( *next_point