summaryrefslogtreecommitdiff
path: root/libavformat/mxfenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-09-16 20:04:04 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-09-16 20:04:04 +0000
commite07b882b4dcdc6fdf807414aebe176a46dd773da (patch)
treeb5753487d7c958983018f346a6b2f75f97ba13a9 /libavformat/mxfenc.c
parentd25130eb236ac30698ce1c92f27b3480ba1e0718 (diff)
Improve amortized worst case speed of the muxers packet interleaving code
from O(packets_in_the_file) to O(num_of_streams). Originally committed as revision 19887 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mxfenc.c')
-rw-r--r--libavformat/mxfenc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 0a44b12e09..8175a9b1cf 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1836,6 +1836,9 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
// purge packet queue
while (pktl) {
AVPacketList *next = pktl->next;
+
+ if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl)
+ s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL;
av_free_packet(&pktl->pkt);
av_freep(&pktl);
pktl = next;
@@ -1844,6 +1847,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
last->next = NULL;
else {
s->packet_buffer = NULL;
+ s->packet_buffer_end= NULL;
goto out;
}
pktl = s->packet_buffer;
@@ -1852,6 +1856,10 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
*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;
+ if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl)
+ s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL;
+ if(!s->packet_buffer)
+ s->packet_buffer_end= NULL;
av_freep(&pktl);
return 1;
} else {