[FFmpeg-devel] [PATCH] Fix DV uninitialized reads
Reimar Döffinger
Reimar.Doeffinger
Mon Sep 21 14:40:51 CEST 2009
Hello,
I think this fixes the uninitialized data in the DV encoder that causes
sporadic "make test" failures, at least valgrind complains no longer.
Quick measurements with "time" indicate a slowdown by about 0.8%.
regression test values for the encoded files changes (memset to 0
instead of 0xff might avoid that though), but the decoded data
stays the same - so at least for the cases "make test" covers it is
correct.
Index: libavcodec/dv.c
===================================================================
--- libavcodec/dv.c (revision 19948)
+++ libavcodec/dv.c (working copy)
@@ -1102,8 +1102,14 @@
av_log(NULL, AV_LOG_ERROR, "ac bitstream overflow\n");
}
- for (j=0; j<5*s->sys->bpm; j++)
+ for (j=0; j<5*s->sys->bpm; j++) {
+ int pos, size;
flush_put_bits(&pbs[j]);
+ pos = put_bits_count(&pbs[j]) >> 3;
+ size = pbs[j].size_in_bits >> 3;
+ if (pos < size)
+ memset(pbs[j].buf + pos, 0xff, size - pos);
+ }
return 0;
}
Index: tests/lavf.regression.ref
===================================================================
--- tests/lavf.regression.ref (revision 19948)
+++ tests/lavf.regression.ref (working copy)
@@ -30,7 +30,7 @@
c145305a775eb2de43cdf94eb1ab5240 *./tests/data/b-lavf.mov
357669 ./tests/data/b-lavf.mov
./tests/data/b-lavf.mov CRC=0x2f6a9b26
-31f115e7106265a7a7cea7f4fcf5c329 *./tests/data/b-lavf.dv
+522e5e5a46b99f8ad8aabdaf3d2f1869 *./tests/data/b-lavf.dv
3600000 ./tests/data/b-lavf.dv
./tests/data/b-lavf.dv CRC=0x02c0af30
bf5c730bb8426dbcfc5420e71ee490f2 *./tests/data/b-lavf.gxf
Index: tests/rotozoom.regression.ref
===================================================================
--- tests/rotozoom.regression.ref (revision 19948)
+++ tests/rotozoom.regression.ref (working copy)
@@ -150,15 +150,15 @@
2721758 ./tests/data/a-snow53.avi
dde5895817ad9d219f79a52d0bdfb001 *./tests/data/snowll.rotozoom.out.yuv
stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200
-02c85b9bebb23f147ef598da7bcbf736 *./tests/data/a-dv.dv
+bfa766f89bfeabc0ae1044f3954bed52 *./tests/data/a-dv.dv
7200000 ./tests/data/a-dv.dv
7ec62bd3350a6848364669e6e1e4b9cc *./tests/data/dv.rotozoom.out.yuv
stddev: 1.71 PSNR: 43.46 bytes: 7603200/ 7603200
-203e50e75a43fb1b26e1b53d99e1de4f *./tests/data/a-dv411.dv
+00a9d8683ac6826af41bcf7223fb0389 *./tests/data/a-dv411.dv
7200000 ./tests/data/a-dv411.dv
7f9fa421028aabb11eaf4c6513a5a843 *./tests/data/dv.rotozoom.out.yuv
stddev: 10.09 PSNR: 28.04 bytes: 7603200/ 7603200
-2bae05531a24cd6764eefba64db345bc *./tests/data/a-dv50.dv
+61e31c79e8949b25c849753a0785b0d7 *./tests/data/a-dv50.dv
14400000 ./tests/data/a-dv50.dv
af3f2dd5ab62c1a1d98b07d4aeb6852f *./tests/data/dv50.rotozoom.out.yuv
stddev: 0.82 PSNR: 49.81 bytes: 7603200/ 7603200
Index: tests/vsynth.regression.ref
===================================================================
--- tests/vsynth.regression.ref (revision 19948)
+++ tests/vsynth.regression.ref (working copy)
@@ -150,15 +150,15 @@
3419980 ./tests/data/a-snow53.avi
c5ccac874dbf808e9088bc3107860042 *./tests/data/snowll.vsynth.out.yuv
stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200
-1482a23e323277f1ff67a29dd07b158d *./tests/data/a-dv.dv
+27ade3031b17214cf81c19cbf70f37d7 *./tests/data/a-dv.dv
7200000 ./tests/data/a-dv.dv
02ac7cdeab91d4d5621e7ce96dddc498 *./tests/data/dv.vsynth.out.yuv
stddev: 6.90 PSNR: 31.33 bytes: 7603200/ 7603200
-ec643f879ccc4d53d285712ec25b5d32 *./tests/data/a-dv411.dv
+bd67f2431db160d4bb6dcd791cea6efd *./tests/data/a-dv411.dv
7200000 ./tests/data/a-dv411.dv
b6640a3a572353f51284acb746eb00c4 *./tests/data/dv.vsynth.out.yuv
stddev: 30.76 PSNR: 18.36 bytes: 7603200/ 7603200
-2a0eace8da46f0061493677deb1fd66d *./tests/data/a-dv50.dv
+26dba84f0ea895b914ef5b333d8394ac *./tests/data/a-dv50.dv
14400000 ./tests/data/a-dv50.dv
a2ff093e93ffed10f730fa21df02fc50 *./tests/data/dv50.vsynth.out.yuv
stddev: 1.72 PSNR: 43.37 bytes: 7603200/ 7603200
More information about the ffmpeg-devel
mailing list