Commit 1191db31 authored by Michael Niedermayer's avatar Michael Niedermayer

mux: fix chunked interleaver

The code did not account properly for packets that where added to
the end of the packet list. Also flags for such packets where not
set correctly leading to incorrect chunked interleaving.

Reported-by: bcoudurier
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent b7bc49a9
...@@ -549,20 +549,21 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, ...@@ -549,20 +549,21 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
next_point = &s->packet_buffer; next_point = &s->packet_buffer;
} }
if (*next_point) { if (chunked) {
if (chunked) { uint64_t max= av_rescale_q_rnd(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base, AV_ROUND_UP);
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
if ( st->interleaver_chunk_size + pkt->size <= s->max_chunk_size-1U && st->interleaver_chunk_duration + pkt->duration <= max-1U) {
&& st->interleaver_chunk_duration + pkt->duration <= max-1U) { st->interleaver_chunk_size += pkt->size;
st->interleaver_chunk_size += pkt->size; st->interleaver_chunk_duration += pkt->duration;
st->interleaver_chunk_duration += pkt->duration; } else {
goto next_non_null; st->interleaver_chunk_size =
} else { st->interleaver_chunk_duration = 0;
st->interleaver_chunk_size = this_pktl->pkt.flags |= CHUNK_START;
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)) { if (compare(s, &s->packet_buffer_end->pkt, pkt)) {
while ( *next_point while ( *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