From d2d230a7569154306a1625ca37dbfa4c36627ec6 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 23 Feb 2006 08:56:53 +0000 Subject: [PATCH] fixing dv_guess_qnos() roman, dont hesitate to reverse this and solve it differntly if you want ... Originally committed as revision 5053 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/dv.c | 31 ++++++++++++++++++++++++++++--- tests/ffmpeg.regression.ref | 6 +++--- tests/libav.regression.ref | 4 ++-- tests/rotozoom.regression.ref | 4 ++-- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 84bc74d..4d79b2c 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -728,7 +728,7 @@ static always_inline int dv_guess_dct_mode(DCTELEM *blk) { static inline void dv_guess_qnos(EncBlockInfo* blks, int* qnos) { int size[5]; - int i, j, k, a, prev; + int i, j, k, a, prev, a2; EncBlockInfo* b; do { @@ -751,6 +751,13 @@ static inline void dv_guess_qnos(EncBlockInfo* blks, int* qnos) b->bit_size[a] += dv_rl2vlc_size(k - prev - 1, b->mb[k]); 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++); + 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]]); + } b->next[prev] = b->next[k]; } } @@ -760,8 +767,26 @@ static inline void dv_guess_qnos(EncBlockInfo* blks, int* qnos) } } } - } while ((vs_total_ac_bits < size[0] + size[1] + size[2] + size[3] + size[4]) && - (qnos[0]|qnos[1]|qnos[2]|qnos[3]|qnos[4])); + if(vs_total_ac_bits >= size[0] + size[1] + size[2] + size[3] + size[4]) + return; + } while (qnos[0]|qnos[1]|qnos[2]|qnos[3]|qnos[4]); + + + for(a=2; a==2 || vs_total_ac_bits < size[0]; a+=a){ + b = blks; + size[0] = 0; + for (j=0; j<6*5; j++, b++) { + prev= b->prev[0]; + for (k= b->next[prev]; k<64; k= b->next[k]) { + if(b->mb[k] < a && b->mb[k] > -a){ + b->next[prev] = b->next[k]; + }else{ + size[0] += dv_rl2vlc_size(k - prev - 1, b->mb[k]); + prev= k; + } + } + } + } } /* diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index 3cd459c..d72d934 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -133,10 +133,10 @@ 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 -e1da20e3f52f4d2aa18e9486986161fc *./data/a-dv.dv +4e6e84ebab4eef5a9d7171cfd687d4cd *./data/a-dv.dv 7200000 ./data/a-dv.dv -55612d1a7246c82a32414638d601ac95 *./data/out.yuv -stddev: 9.15 PSNR:28.88 bytes:7602176 +70c5b0eb61f16b7cd7328b4aca57a4e2 *./data/out.yuv +stddev: 9.16 PSNR:28.88 bytes:7602176 bd0db310a36ad94bcd4448abe0a88368 *./data/a-svq1.mov 1379827 ./data/a-svq1.mov bbff871d1475e1eee4231a08e075de2c *./data/out.yuv diff --git a/tests/libav.regression.ref b/tests/libav.regression.ref index f45c80d..36d3669 100644 --- a/tests/libav.regression.ref +++ b/tests/libav.regression.ref @@ -28,9 +28,9 @@ e4ed8d635d867e2f5980fd9c73c9cf3d *./data/b-libav.mov 8bf16d40a2ec19fa36b124a928e47e23 *./data/b-libav.nut 332358 ./data/b-libav.nut ./data/b-libav.nut CRC=0xccab3a27 -b466c970d54eb254ad0f954b08535634 *./data/b-libav.dv +9317bd7830cbc8d660cb7b8f5b949ac2 *./data/b-libav.dv 3600000 ./data/b-libav.dv -./data/b-libav.dv CRC=0xc5215996 +./data/b-libav.dv CRC=0xedf45b11 9a9da315747599f7718cc9a9a09c21ff *./data/b-libav.pbm 317075 ./data/b-libav.pbm ./data/b-libav.pbm CRC=0xb92906cb diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref index 9413872..b402424 100644 --- a/tests/rotozoom.regression.ref +++ b/tests/rotozoom.regression.ref @@ -133,9 +133,9 @@ stddev: 10.94 PSNR:27.34 bytes:7602176 2725570 ./data/a-snow53.avi dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -a553532dcd54c1c421b52c3b6fece6ef *./data/a-dv.dv +b829649260346655ad2c820ab56edeb3 *./data/a-dv.dv 7200000 ./data/a-dv.dv -1a1717b271a7536d641d5e1750d852d9 *./data/out.yuv +ecf8fde289dd44819493844e95057a6a *./data/out.yuv stddev: 3.16 PSNR:38.12 bytes:7602176 5b02b6ae7ffa257a66ae9857a992fdfe *./data/a-svq1.mov 769527 ./data/a-svq1.mov -- 2.7.4