diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-02-02 10:04:36 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-02-02 10:04:36 +0000 |
commit | bc185fc1611fe4cf38e7b0f79919e76e0205f03c (patch) | |
tree | b4544c4f898dff060727721130fa93ccf41dd9d4 /libavformat/mxfenc.c | |
parent | 0e9dbd9685bddfe1fed9dd251ed11c09b07faced (diff) | |
download | ffmpeg-bc185fc1611fe4cf38e7b0f79919e76e0205f03c.tar.gz |
fix flush and interleaving by edit units
Originally committed as revision 16937 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mxfenc.c')
-rw-r--r-- | libavformat/mxfenc.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index bb39897c19..03409079cb 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1296,25 +1296,37 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket if (stream_count && (s->nb_streams == stream_count || flush)) { pktl = s->packet_buffer; - *out = pktl->pkt; - //av_log(s, AV_LOG_DEBUG, "out st:%d dts:%lld\n", (*out).stream_index, (*out).dts); - s->packet_buffer = pktl->next; - av_freep(&pktl); - - if (flush && stream_count < s->nb_streams) { + if (s->nb_streams != stream_count) { + MXFContext *mxf = s->priv_data; + AVPacketList *first = NULL; + // find first packet in edit unit + while (pktl) { + AVStream *st = s->streams[pktl->pkt.stream_index]; + if (st->index == mxf->edit_unit_start) + break; + else if (!first) + first = pktl; + pktl = pktl->next; + } // purge packet queue - pktl = s->packet_buffer; while (pktl) { AVPacketList *next = pktl->next; av_free_packet(&pktl->pkt); av_freep(&pktl); pktl = next; } - s->packet_buffer = NULL; + if (!first) + goto out; + pktl = first; } + *out = pktl->pkt; + //av_log(s, AV_LOG_DEBUG, "out st:%d dts:%lld\n", (*out).stream_index, (*out).dts); + s->packet_buffer = pktl->next; + av_freep(&pktl); return 1; } else { + out: av_init_packet(out); return 0; } |