changeset 4500:cc4b6d42dcd5 libavformat

fix mxf interleaving packet purge
author bcoudurier
date Mon, 16 Feb 2009 01:51:52 +0000
parents dee012239d99
children 3e5b9c1a413e
files mxfenc.c
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mxfenc.c	Sun Feb 15 20:45:10 2009 +0000
+++ b/mxfenc.c	Mon Feb 16 01:51:52 2009 +0000
@@ -1831,20 +1831,15 @@
     if (stream_count && (s->nb_streams == stream_count || flush)) {
         pktl = s->packet_buffer;
         if (s->nb_streams != stream_count) {
-            AVPacketList *first = NULL;
             AVPacketList *last = NULL;
-            // find first packet in edit unit
+            // find last packet in edit unit
             while (pktl) {
-                AVStream *st = s->streams[pktl->pkt.stream_index];
-                if (st->index == 0)
+                if (!stream_count || pktl->pkt.stream_index == 0)
                     break;
-                else if (!first)
-                    first = pktl;
                 last = pktl;
                 pktl = pktl->next;
+                stream_count--;
             }
-            if (last)
-                last->next = NULL;
             // purge packet queue
             while (pktl) {
                 AVPacketList *next = pktl->next;
@@ -1852,9 +1847,13 @@
                 av_freep(&pktl);
                 pktl = next;
             }
-            if (!first)
+            if (last)
+                last->next = NULL;
+            else {
+                s->packet_buffer = NULL;
                 goto out;
-            pktl = first;
+            }
+            pktl = s->packet_buffer;
         }
 
         *out = pktl->pkt;