Revision 012dc2c4

View differences:

libavformat/mxfenc.c
1807 1807

  
1808 1808
static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
1809 1809
{
1810
    AVPacketList *pktl;
1811
    int stream_count = 0;
1812
    int streams[MAX_STREAMS];
1813

  
1814
    memset(streams, 0, sizeof(streams));
1815
    pktl = s->packet_buffer;
1816
    while (pktl) {
1817
        //av_log(s, AV_LOG_DEBUG, "show st:%d dts:%lld\n", pktl->pkt.stream_index, pktl->pkt.dts);
1818
        if (!streams[pktl->pkt.stream_index])
1819
            stream_count++;
1820
        streams[pktl->pkt.stream_index]++;
1821
        pktl = pktl->next;
1822
    }
1810
    int i, stream_count = 0;
1811

  
1812
    for (i = 0; i < s->nb_streams; i++)
1813
        stream_count += !!s->streams[i]->last_in_packet_buffer;
1823 1814

  
1824 1815
    if (stream_count && (s->nb_streams == stream_count || flush)) {
1825
        pktl = s->packet_buffer;
1816
        AVPacketList *pktl = s->packet_buffer;
1826 1817
        if (s->nb_streams != stream_count) {
1827 1818
            AVPacketList *last = NULL;
1828 1819
            // find last packet in edit unit
libavformat/oggenc.c
36 36
    int64_t last_kf_pts;
37 37
    int vrev;
38 38
    int eos;
39
    unsigned packet_count; ///< number of packet buffered
39 40
} OGGStreamContext;
40 41

  
41 42
static void ogg_update_checksum(AVFormatContext *s, int64_t crc_offset)
......
286 287

  
287 288
static int ogg_interleave_per_granule(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
288 289
{
289
    AVPacketList *pktl;
290
    int stream_count = 0;
291
    int streams[MAX_STREAMS] = {0};
290
    OGGStreamContext *ogg;
291
    int i, stream_count = 0;
292 292
    int interleaved = 0;
293 293

  
294 294
    if (pkt) {
295 295
        ff_interleave_add_packet(s, pkt, ogg_compare_granule);
296
        ogg = s->streams[pkt->stream_index]->priv_data;
297
        ogg->packet_count++;
296 298
    }
297 299

  
298
    pktl = s->packet_buffer;
299
    while (pktl) {
300
        if (streams[pktl->pkt.stream_index] == 0)
301
            stream_count++;
302
        streams[pktl->pkt.stream_index]++;
303
        // need to buffer at least one packet to set eos flag
304
        if (streams[pktl->pkt.stream_index] == 2)
305
            interleaved++;
306
        pktl = pktl->next;
300
    for (i = 0; i < s->nb_streams; i++) {
301
        ogg = s->streams[i]->priv_data;
302
        stream_count += !!ogg->packet_count;
303
        interleaved += ogg->packet_count > 1;
307 304
    }
308 305

  
309 306
    if ((s->nb_streams == stream_count && interleaved == stream_count) ||
310 307
        (flush && stream_count)) {
311
        pktl= s->packet_buffer;
308
        AVPacketList *pktl= s->packet_buffer;
312 309
        *out= pktl->pkt;
313 310
        s->packet_buffer = pktl->next;
314
        if (flush && streams[out->stream_index] == 1) {
315
            OGGStreamContext *ogg = s->streams[out->stream_index]->priv_data;
311

  
312
        ogg = s->streams[out->stream_index]->priv_data;
313
        if (flush && ogg->packet_count == 1)
316 314
            ogg->eos = 1;
317
        }
315
        ogg->packet_count--;
316

  
318 317
        if(!s->packet_buffer)
319 318
            s->packet_buffer_end= NULL;
320 319

  

Also available in: Unified diff