[SCM] libav/experimental: Remove MAX_STREAMS usage in ogg and mxf muxers

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:58:56 UTC 2013


The following commit has been merged in the experimental branch:
commit 012dc2c426e02b688837d3d7477da55f4db032e6
Author: Baptiste Coudurier <baptiste.coudurier at gmail.com>
Date:   Fri Jan 29 06:38:00 2010 +0000

    Remove MAX_STREAMS usage in ogg and mxf muxers
    
    Originally committed as revision 21526 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 12dedcc..766327d 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1807,22 +1807,13 @@ static int mxf_write_footer(AVFormatContext *s)
 
 static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
 {
-    AVPacketList *pktl;
-    int stream_count = 0;
-    int streams[MAX_STREAMS];
-
-    memset(streams, 0, sizeof(streams));
-    pktl = s->packet_buffer;
-    while (pktl) {
-        //av_log(s, AV_LOG_DEBUG, "show st:%d dts:%lld\n", pktl->pkt.stream_index, pktl->pkt.dts);
-        if (!streams[pktl->pkt.stream_index])
-            stream_count++;
-        streams[pktl->pkt.stream_index]++;
-        pktl = pktl->next;
-    }
+    int i, stream_count = 0;
+
+    for (i = 0; i < s->nb_streams; i++)
+        stream_count += !!s->streams[i]->last_in_packet_buffer;
 
     if (stream_count && (s->nb_streams == stream_count || flush)) {
-        pktl = s->packet_buffer;
+        AVPacketList *pktl = s->packet_buffer;
         if (s->nb_streams != stream_count) {
             AVPacketList *last = NULL;
             // find last packet in edit unit
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 669d3a0..101570b 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -36,6 +36,7 @@ typedef struct {
     int64_t last_kf_pts;
     int vrev;
     int eos;
+    unsigned packet_count; ///< number of packet buffered
 } OGGStreamContext;
 
 static void ogg_update_checksum(AVFormatContext *s, int64_t crc_offset)
@@ -286,35 +287,33 @@ static int ogg_compare_granule(AVFormatContext *s, AVPacket *next, AVPacket *pkt
 
 static int ogg_interleave_per_granule(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
 {
-    AVPacketList *pktl;
-    int stream_count = 0;
-    int streams[MAX_STREAMS] = {0};
+    OGGStreamContext *ogg;
+    int i, stream_count = 0;
     int interleaved = 0;
 
     if (pkt) {
         ff_interleave_add_packet(s, pkt, ogg_compare_granule);
+        ogg = s->streams[pkt->stream_index]->priv_data;
+        ogg->packet_count++;
     }
 
-    pktl = s->packet_buffer;
-    while (pktl) {
-        if (streams[pktl->pkt.stream_index] == 0)
-            stream_count++;
-        streams[pktl->pkt.stream_index]++;
-        // need to buffer at least one packet to set eos flag
-        if (streams[pktl->pkt.stream_index] == 2)
-            interleaved++;
-        pktl = pktl->next;
+    for (i = 0; i < s->nb_streams; i++) {
+        ogg = s->streams[i]->priv_data;
+        stream_count += !!ogg->packet_count;
+        interleaved += ogg->packet_count > 1;
     }
 
     if ((s->nb_streams == stream_count && interleaved == stream_count) ||
         (flush && stream_count)) {
-        pktl= s->packet_buffer;
+        AVPacketList *pktl= s->packet_buffer;
         *out= pktl->pkt;
         s->packet_buffer = pktl->next;
-        if (flush && streams[out->stream_index] == 1) {
-            OGGStreamContext *ogg = s->streams[out->stream_index]->priv_data;
+
+        ogg = s->streams[out->stream_index]->priv_data;
+        if (flush && ogg->packet_count == 1)
             ogg->eos = 1;
-        }
+        ogg->packet_count--;
+
         if(!s->packet_buffer)
             s->packet_buffer_end= NULL;
 

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list