Revision 2d241e66

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++;
tests/ffmpeg.regression.ref
188 188
353368 ./data/a-flac.flac
189 189
c4228df189aad9567a037727d0e763e4 *./data/out.wav
190 190
stddev: 33.31 PSNR:65.87 bytes:1040384
191
9fe59eb60481009f6f7d13d1b031975d *./data/a-wmav1.asf
191
768305cec342e01b7a9d38e971ef0174 *./data/a-wmav1.asf
192 192
99596 ./data/a-wmav1.asf
193 193
2ab193df22bb473e61015e56ac11faf3 *./data/out.wav
194 194
stddev:12251.50 PSNR:14.56 bytes:1056768
195 195
stddev:2106.00 PSNR:29.85 bytes:1048576
196
ff09659af56c931350db4dec737eea7f *./data/a-wmav2.asf
196
c706c7cf9db10df7a7353a40feddcfdd *./data/a-wmav2.asf
197 197
99602 ./data/a-wmav2.asf
198 198
8d05d345bc14153f3d0da95fdf34e084 *./data/out.wav
199 199
stddev:12255.92 PSNR:14.55 bytes:1056768
200 200
stddev:2099.31 PSNR:29.88 bytes:1048576
201
e56c2c60b025594eac3ba670ae3cc50d *./data/a-vorbis.asf
201
ef725cb9c13b9437a41428eabadeba52 *./data/a-vorbis.asf
202 202
35686 ./data/a-vorbis.asf
203
295d828df6167db030d0812ce1a8fd93 *./data/out.wav
203
e46368ef818f2ec3abcc3f8390d14df5 *./data/out.wav
204 204
stddev:3882.46 PSNR:24.54 bytes:1056768
tests/libav.regression.ref
2 2
8a0536ccfe36f4fff408b3327d33e1dd *./data/b-libav.avi
3 3
340344 ./data/b-libav.avi
4 4
./data/b-libav.avi CRC=0x400c29e9
5
af76964183b72ab3e18f1581e55950db *./data/b-libav.asf
5
149792fc0d4e5ccb395c47716e2975d9 *./data/b-libav.asf
6 6
339767 ./data/b-libav.asf
7 7
./data/b-libav.asf CRC=0x74113749
8 8
1ad618e9fd318eb3483270cf9b9b3f43 *./data/b-libav.rm
tests/rotozoom.regression.ref
188 188
353368 ./data/a-flac.flac
189 189
c4228df189aad9567a037727d0e763e4 *./data/out.wav
190 190
stddev: 33.31 PSNR:65.87 bytes:1040384
191
9fe59eb60481009f6f7d13d1b031975d *./data/a-wmav1.asf
191
768305cec342e01b7a9d38e971ef0174 *./data/a-wmav1.asf
192 192
99596 ./data/a-wmav1.asf
193 193
2ab193df22bb473e61015e56ac11faf3 *./data/out.wav
194 194
stddev:12251.50 PSNR:14.56 bytes:1056768
195 195
stddev:2106.00 PSNR:29.85 bytes:1048576
196
ff09659af56c931350db4dec737eea7f *./data/a-wmav2.asf
196
c706c7cf9db10df7a7353a40feddcfdd *./data/a-wmav2.asf
197 197
99602 ./data/a-wmav2.asf
198 198
8d05d345bc14153f3d0da95fdf34e084 *./data/out.wav
199 199
stddev:12255.92 PSNR:14.55 bytes:1056768
200 200
stddev:2099.31 PSNR:29.88 bytes:1048576
201
e56c2c60b025594eac3ba670ae3cc50d *./data/a-vorbis.asf
201
ef725cb9c13b9437a41428eabadeba52 *./data/a-vorbis.asf
202 202
35686 ./data/a-vorbis.asf
203
295d828df6167db030d0812ce1a8fd93 *./data/out.wav
203
e46368ef818f2ec3abcc3f8390d14df5 *./data/out.wav
204 204
stddev:3882.46 PSNR:24.54 bytes:1056768

Also available in: Unified diff