fix broken memset(padding, 0) code

add a few asserts

Originally committed as revision 7903 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Michael Niedermayer 18 years ago
parent cf10ee184f
commit 2d241e6687
  1. 16
      libavformat/asf-enc.c
  2. 8
      tests/ffmpeg.regression.ref
  3. 2
      tests/libav.regression.ref
  4. 8
      tests/rotozoom.regression.ref

@ -537,6 +537,11 @@ static int put_payload_parsing_info(
int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS; int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS;
padsize -= PACKET_HEADER_MIN_SIZE;
if(asf->multi_payloads_present)
padsize--;
assert(padsize>=0);
put_byte(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS); put_byte(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
for (i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++){ for (i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++){
put_byte(pb, 0x0); put_byte(pb, 0x0);
@ -587,7 +592,8 @@ static void flush_packet(AVFormatContext *s)
asf->packet_size_left asf->packet_size_left
); );
packet_filled_size = PACKET_SIZE - packet_hdr_size - asf->packet_size_left; packet_filled_size = PACKET_SIZE - asf->packet_size_left;
assert(packet_hdr_size <= asf->packet_size_left);
memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left); memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left);
put_buffer(&s->pb, asf->packet_buf, asf->packet_size - packet_hdr_size); put_buffer(&s->pb, asf->packet_buf, asf->packet_size - packet_hdr_size);
@ -656,20 +662,18 @@ static void put_frame(
if (asf->packet_timestamp_start == -1) { if (asf->packet_timestamp_start == -1) {
asf->multi_payloads_present = (payload_len < MULTI_PAYLOAD_CONSTANT); asf->multi_payloads_present = (payload_len < MULTI_PAYLOAD_CONSTANT);
asf->packet_size_left = PACKET_SIZE;
if (asf->multi_payloads_present){ if (asf->multi_payloads_present){
asf->packet_size_left = PACKET_SIZE; //For debug
asf->packet_size_left = PACKET_SIZE - PACKET_HEADER_MIN_SIZE - 1;
frag_len1 = MULTI_PAYLOAD_CONSTANT - 1; frag_len1 = MULTI_PAYLOAD_CONSTANT - 1;
} }
else { else {
asf->packet_size_left = PACKET_SIZE - PACKET_HEADER_MIN_SIZE;
frag_len1 = SINGLE_PAYLOAD_DATA_LENGTH; frag_len1 = SINGLE_PAYLOAD_DATA_LENGTH;
} }
asf->packet_timestamp_start = timestamp; asf->packet_timestamp_start = timestamp;
} }
else { else {
// multi payloads // multi payloads
frag_len1 = asf->packet_size_left - PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS; frag_len1 = asf->packet_size_left - PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS - PACKET_HEADER_MIN_SIZE - 1;
asf->packet_timestamp_start = timestamp; asf->packet_timestamp_start = timestamp;
} }
@ -697,7 +701,7 @@ static void put_frame(
if (!asf->multi_payloads_present) if (!asf->multi_payloads_present)
flush_packet(s); flush_packet(s);
else if (asf->packet_size_left <= (PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + 1)) else if (asf->packet_size_left <= (PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + PACKET_HEADER_MIN_SIZE + 1))
flush_packet(s); flush_packet(s);
} }
stream->seq++; stream->seq++;

@ -188,17 +188,17 @@ c3382f03ce2efb5d475240d288a33898 *./data/a-flac.flac
353368 ./data/a-flac.flac 353368 ./data/a-flac.flac
c4228df189aad9567a037727d0e763e4 *./data/out.wav c4228df189aad9567a037727d0e763e4 *./data/out.wav
stddev: 33.31 PSNR:65.87 bytes:1040384 stddev: 33.31 PSNR:65.87 bytes:1040384
9fe59eb60481009f6f7d13d1b031975d *./data/a-wmav1.asf 768305cec342e01b7a9d38e971ef0174 *./data/a-wmav1.asf
99596 ./data/a-wmav1.asf 99596 ./data/a-wmav1.asf
2ab193df22bb473e61015e56ac11faf3 *./data/out.wav 2ab193df22bb473e61015e56ac11faf3 *./data/out.wav
stddev:12251.50 PSNR:14.56 bytes:1056768 stddev:12251.50 PSNR:14.56 bytes:1056768
stddev:2106.00 PSNR:29.85 bytes:1048576 stddev:2106.00 PSNR:29.85 bytes:1048576
ff09659af56c931350db4dec737eea7f *./data/a-wmav2.asf c706c7cf9db10df7a7353a40feddcfdd *./data/a-wmav2.asf
99602 ./data/a-wmav2.asf 99602 ./data/a-wmav2.asf
8d05d345bc14153f3d0da95fdf34e084 *./data/out.wav 8d05d345bc14153f3d0da95fdf34e084 *./data/out.wav
stddev:12255.92 PSNR:14.55 bytes:1056768 stddev:12255.92 PSNR:14.55 bytes:1056768
stddev:2099.31 PSNR:29.88 bytes:1048576 stddev:2099.31 PSNR:29.88 bytes:1048576
e56c2c60b025594eac3ba670ae3cc50d *./data/a-vorbis.asf ef725cb9c13b9437a41428eabadeba52 *./data/a-vorbis.asf
35686 ./data/a-vorbis.asf 35686 ./data/a-vorbis.asf
295d828df6167db030d0812ce1a8fd93 *./data/out.wav e46368ef818f2ec3abcc3f8390d14df5 *./data/out.wav
stddev:3882.46 PSNR:24.54 bytes:1056768 stddev:3882.46 PSNR:24.54 bytes:1056768

@ -2,7 +2,7 @@ ffmpeg regression test
8a0536ccfe36f4fff408b3327d33e1dd *./data/b-libav.avi 8a0536ccfe36f4fff408b3327d33e1dd *./data/b-libav.avi
340344 ./data/b-libav.avi 340344 ./data/b-libav.avi
./data/b-libav.avi CRC=0x400c29e9 ./data/b-libav.avi CRC=0x400c29e9
af76964183b72ab3e18f1581e55950db *./data/b-libav.asf 149792fc0d4e5ccb395c47716e2975d9 *./data/b-libav.asf
339767 ./data/b-libav.asf 339767 ./data/b-libav.asf
./data/b-libav.asf CRC=0x74113749 ./data/b-libav.asf CRC=0x74113749
1ad618e9fd318eb3483270cf9b9b3f43 *./data/b-libav.rm 1ad618e9fd318eb3483270cf9b9b3f43 *./data/b-libav.rm

@ -188,17 +188,17 @@ c3382f03ce2efb5d475240d288a33898 *./data/a-flac.flac
353368 ./data/a-flac.flac 353368 ./data/a-flac.flac
c4228df189aad9567a037727d0e763e4 *./data/out.wav c4228df189aad9567a037727d0e763e4 *./data/out.wav
stddev: 33.31 PSNR:65.87 bytes:1040384 stddev: 33.31 PSNR:65.87 bytes:1040384
9fe59eb60481009f6f7d13d1b031975d *./data/a-wmav1.asf 768305cec342e01b7a9d38e971ef0174 *./data/a-wmav1.asf
99596 ./data/a-wmav1.asf 99596 ./data/a-wmav1.asf
2ab193df22bb473e61015e56ac11faf3 *./data/out.wav 2ab193df22bb473e61015e56ac11faf3 *./data/out.wav
stddev:12251.50 PSNR:14.56 bytes:1056768 stddev:12251.50 PSNR:14.56 bytes:1056768
stddev:2106.00 PSNR:29.85 bytes:1048576 stddev:2106.00 PSNR:29.85 bytes:1048576
ff09659af56c931350db4dec737eea7f *./data/a-wmav2.asf c706c7cf9db10df7a7353a40feddcfdd *./data/a-wmav2.asf
99602 ./data/a-wmav2.asf 99602 ./data/a-wmav2.asf
8d05d345bc14153f3d0da95fdf34e084 *./data/out.wav 8d05d345bc14153f3d0da95fdf34e084 *./data/out.wav
stddev:12255.92 PSNR:14.55 bytes:1056768 stddev:12255.92 PSNR:14.55 bytes:1056768
stddev:2099.31 PSNR:29.88 bytes:1048576 stddev:2099.31 PSNR:29.88 bytes:1048576
e56c2c60b025594eac3ba670ae3cc50d *./data/a-vorbis.asf ef725cb9c13b9437a41428eabadeba52 *./data/a-vorbis.asf
35686 ./data/a-vorbis.asf 35686 ./data/a-vorbis.asf
295d828df6167db030d0812ce1a8fd93 *./data/out.wav e46368ef818f2ec3abcc3f8390d14df5 *./data/out.wav
stddev:3882.46 PSNR:24.54 bytes:1056768 stddev:3882.46 PSNR:24.54 bytes:1056768

Loading…
Cancel
Save