Revision e07b882b libavformat/utils.c

View differences:

libavformat/utils.c
2657 2657
    pkt->destruct= NULL;             // do not free original but only the copy
2658 2658
    av_dup_packet(&this_pktl->pkt);  // duplicate the packet if it uses non-alloced memory
2659 2659

  
2660
    if(!s->packet_buffer_end || compare(s, &s->packet_buffer_end->pkt, pkt)){
2660
    if(s->streams[pkt->stream_index]->last_in_packet_buffer){
2661
        next_point = &(s->streams[pkt->stream_index]->last_in_packet_buffer->next);
2662
    }else
2661 2663
        next_point = &s->packet_buffer;
2662
        while(*next_point){
2663
            if(compare(s, &(*next_point)->pkt, pkt))
2664
                break;
2664

  
2665
    if(*next_point){
2666
        if(compare(s, &s->packet_buffer_end->pkt, pkt)){
2667
            while(!compare(s, &(*next_point)->pkt, pkt)){
2665 2668
            next_point= &(*next_point)->next;
2666 2669
        }
2670
            goto next_non_null;
2667 2671
    }else{
2668 2672
        next_point = &(s->packet_buffer_end->next);
2669
        assert(!*next_point);
2673
        }
2670 2674
    }
2671
    this_pktl->next= *next_point;
2675
        assert(!*next_point);
2672 2676

  
2673
    if(!*next_point)
2674 2677
        s->packet_buffer_end= this_pktl;
2678
next_non_null:
2675 2679

  
2676
    *next_point= this_pktl;
2680
    this_pktl->next= *next_point;
2677 2681

  
2678
    s->streams[pkt->stream_index]->num_in_packet_buffer++;
2682
    s->streams[pkt->stream_index]->last_in_packet_buffer=
2683
    *next_point= this_pktl;
2679 2684
}
2680 2685

  
2681 2686
int ff_interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacket *pkt)
......
2701 2706
    }
2702 2707

  
2703 2708
    for(i=0; i < s->nb_streams; i++)
2704
        stream_count+= !!s->streams[i]->num_in_packet_buffer;
2709
        stream_count+= !!s->streams[i]->last_in_packet_buffer;
2705 2710

  
2706 2711
    if(stream_count && (s->nb_streams == stream_count || flush)){
2707 2712
        pktl= s->packet_buffer;
......
2711 2716
        if(!s->packet_buffer)
2712 2717
            s->packet_buffer_end= NULL;
2713 2718

  
2714
        s->streams[out->stream_index]->num_in_packet_buffer--;
2719
        if(s->streams[out->stream_index]->last_in_packet_buffer == pktl)
2720
            s->streams[out->stream_index]->last_in_packet_buffer= NULL;
2715 2721
        av_freep(&pktl);
2716 2722
        return 1;
2717 2723
    }else{

Also available in: Unified diff