From 6df5f6ae51ca3e9f3af760066bc7b3423677a8b4 Mon Sep 17 00:00:00 2001 From: Dan Maas Date: Sat, 25 Feb 2006 22:58:26 +0000 Subject: [PATCH] size[0-3] are not initialized (and can get random negative trash values), so the comparison with vs_total_ac_bits is messed up on the first couple loop iterations, leading to AC underflows. the b->prev[] pointers were not being maintained correctly. We potentially have to update b->prev[] both before and after the area whose VLC length is getting adjusted. this also might fix the ppc regression failure? patch by (Dan Maas ) Originally committed as revision 5064 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/dv.c | 7 +++++-- tests/ffmpeg.regression.ref | 4 ++-- tests/libav.regression.ref | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index baf463e75d..9f2cdd8903 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -731,7 +731,7 @@ static inline void dv_guess_qnos(EncBlockInfo* blks, int* qnos) int i, j, k, a, prev, a2; EncBlockInfo* b; - size[4]= 1<<24; + size[0] = size[1] = size[2] = size[3] = size[4] = 1<<24; do { b = blks; for (i=0; i<5; i++) { @@ -753,11 +753,14 @@ static inline void dv_guess_qnos(EncBlockInfo* blks, int* qnos) prev= k; } else { if(b->next[k] >= mb_area_start[a+1] && b->next[k]<64){ - for(a2=a+1; b->next[k] >= mb_area_start[a2+1]; a2++); + for(a2=a+1; b->next[k] >= mb_area_start[a2+1]; a2++) + b->prev[a2] = prev; assert(a2<4); assert(b->mb[b->next[k]]); b->bit_size[a2] += dv_rl2vlc_size(b->next[k] - prev - 1, b->mb[b->next[k]]) -dv_rl2vlc_size(b->next[k] - k - 1, b->mb[b->next[k]]); + for(; (b->prev[a2]==k) && (a2<4); a2++) + b->prev[a2] = prev; } b->next[prev] = b->next[k]; } diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index e2479321bf..c869b3a6cd 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -133,9 +133,9 @@ stddev: 23.20 PSNR:20.81 bytes:7602176 3533710 ./data/a-snow53.avi 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -229e5f8d1f386d0cf84f629be7d74955 *./data/a-dv.dv +a071e3aa523e0f91fce08bdba0d47199 *./data/a-dv.dv 7200000 ./data/a-dv.dv -0ac51c62d3c2a4bacf216ea73050485e *./data/out.yuv +a99de8648a78970065b834219d9fa27a *./data/out.yuv stddev: 9.10 PSNR:28.94 bytes:7602176 bd0db310a36ad94bcd4448abe0a88368 *./data/a-svq1.mov 1379827 ./data/a-svq1.mov diff --git a/tests/libav.regression.ref b/tests/libav.regression.ref index d64f523d59..673fd51a5a 100644 --- a/tests/libav.regression.ref +++ b/tests/libav.regression.ref @@ -28,7 +28,7 @@ e4ed8d635d867e2f5980fd9c73c9cf3d *./data/b-libav.mov 8bf16d40a2ec19fa36b124a928e47e23 *./data/b-libav.nut 332358 ./data/b-libav.nut ./data/b-libav.nut CRC=0xccab3a27 -973886f2acd79e6785e0f31519d721cf *./data/b-libav.dv +5a040cc1353f17f6a7305e972c0667d0 *./data/b-libav.dv 3600000 ./data/b-libav.dv ./data/b-libav.dv CRC=0x5e1f4cdc 9a9da315747599f7718cc9a9a09c21ff *./data/b-libav.pbm