Revision 2d241e66 libavformat/asf-enc.c

View differences:

libavformat/asf-enc.c
537 537

  
538 538
    int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS;
539 539

  
540
    padsize -= PACKET_HEADER_MIN_SIZE;
541
    if(asf->multi_payloads_present)
542
        padsize--;
543
    assert(padsize>=0);
544

  
540 545
    put_byte(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
541 546
    for (i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++){
542 547
        put_byte(pb, 0x0);
......
587 592
                            asf->packet_size_left
588 593
                        );
589 594

  
590
    packet_filled_size = PACKET_SIZE - packet_hdr_size - asf->packet_size_left;
595
    packet_filled_size = PACKET_SIZE - asf->packet_size_left;
596
    assert(packet_hdr_size <= asf->packet_size_left);
591 597
    memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left);
592 598

  
593 599
    put_buffer(&s->pb, asf->packet_buf, asf->packet_size - packet_hdr_size);
......
656 662
        if (asf->packet_timestamp_start == -1) {
657 663
            asf->multi_payloads_present = (payload_len < MULTI_PAYLOAD_CONSTANT);
658 664

  
665
            asf->packet_size_left = PACKET_SIZE;
659 666
            if (asf->multi_payloads_present){
660
                asf->packet_size_left = PACKET_SIZE; //For debug
661
                asf->packet_size_left = PACKET_SIZE - PACKET_HEADER_MIN_SIZE - 1;
662 667
                frag_len1 = MULTI_PAYLOAD_CONSTANT - 1;
663 668
            }
664 669
            else {
665
                asf->packet_size_left = PACKET_SIZE - PACKET_HEADER_MIN_SIZE;
666 670
                frag_len1 = SINGLE_PAYLOAD_DATA_LENGTH;
667 671
            }
668 672
            asf->packet_timestamp_start = timestamp;
669 673
        }
670 674
        else {
671 675
            // multi payloads
672
            frag_len1 = asf->packet_size_left - PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS;
676
            frag_len1 = asf->packet_size_left - PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS - PACKET_HEADER_MIN_SIZE - 1;
673 677

  
674 678
            asf->packet_timestamp_start = timestamp;
675 679
        }
......
697 701

  
698 702
        if (!asf->multi_payloads_present)
699 703
            flush_packet(s);
700
        else if (asf->packet_size_left <= (PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + 1))
704
        else if (asf->packet_size_left <= (PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + PACKET_HEADER_MIN_SIZE + 1))
701 705
            flush_packet(s);
702 706
    }
703 707
    stream->seq++;

Also available in: Unified diff