diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2005-12-25 16:34:12 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2005-12-25 16:34:12 +0000 |
commit | aaaa6f154908fdeb3555aae4f83d23de520df0e8 (patch) | |
tree | 9405a35db530eed06216ab07666321b7706bd32f | |
parent | c69e7914be63cca5b08713dcdacb1baf801b0d02 (diff) | |
download | ffmpeg-aaaa6f154908fdeb3555aae4f83d23de520df0e8.tar.gz |
dont discard least significant bits
Originally committed as revision 4773 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/motion_est.c | 68 | ||||
-rw-r--r-- | tests/ffmpeg.regression.ref | 14 | ||||
-rw-r--r-- | tests/rotozoom.regression.ref | 42 |
3 files changed, 62 insertions, 62 deletions
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index bd0074f3ad..7c20272c0a 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1164,26 +1164,26 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, /* intra / predictive decision */ pix = c->src[0][0]; sum = s->dsp.pix_sum(pix, s->linesize); - varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500 + 128)>>8; + varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500; pic->mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8; - pic->mb_var [s->mb_stride * mb_y + mb_x] = varc; - c->mb_var_sum_temp += varc; + pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8; + c->mb_var_sum_temp += (varc+128)>>8; if(c->avctx->me_threshold){ - vard= (check_input_motion(s, mb_x, mb_y, 1)+128)>>8; + vard= check_input_motion(s, mb_x, mb_y, 1); - if(vard<c->avctx->me_threshold){ - pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = vard; - c->mc_mb_var_sum_temp += vard; - if (vard <= 64 || vard < varc) { //FIXME - c->scene_change_score+= ff_sqrt(vard<<8) - ff_sqrt(varc<<8); + if((vard+128)>>8 < c->avctx->me_threshold){ + pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8; + c->mc_mb_var_sum_temp += (vard+128)>>8; + if (vard <= 64<<8 || vard < varc) { //FIXME + c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); }else{ c->scene_change_score+= s->qscale; } return; } - if(vard<c->avctx->mb_threshold) + if((vard+128)>>8 < c->avctx->mb_threshold) mb_type= s->mb_type[mb_x + mb_y*s->mb_stride]; } @@ -1256,19 +1256,19 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, /* At this point (mx,my) are full-pell and the relative displacement */ ppix = c->ref[0][0] + (my * s->linesize) + mx; - vard = (s->dsp.sse[0](NULL, pix, ppix, s->linesize, 16)+128)>>8; + vard = s->dsp.sse[0](NULL, pix, ppix, s->linesize, 16); - pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = vard; + pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8; // pic->mb_cmp_score[s->mb_stride * mb_y + mb_x] = dmin; - c->mc_mb_var_sum_temp += vard; + c->mc_mb_var_sum_temp += (vard+128)>>8; #if 0 printf("varc=%4d avg_var=%4d (sum=%4d) vard=%4d mx=%2d my=%2d\n", varc, s->avg_mb_var, sum, vard, mx - xx, my - yy); #endif if(mb_type){ - if (vard <= 64 || vard < varc) - c->scene_change_score+= ff_sqrt(vard<<8) - ff_sqrt(varc<<8); + if (vard <= 64<<8 || vard < varc) + c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); else c->scene_change_score+= s->qscale; @@ -1288,14 +1288,14 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 1); } }else if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){ - if (vard <= 64 || vard < varc) - c->scene_change_score+= ff_sqrt(vard<<8) - ff_sqrt(varc<<8); + if (vard <= 64<<8 || vard < varc) + c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); else c->scene_change_score+= s->qscale; - if (vard*2 + 200 > varc) + if (vard*2 + 200*256 > varc) mb_type|= CANDIDATE_MB_TYPE_INTRA; - if (varc*2 + 200 > vard){ + if (varc*2 + 200*256 > vard){ mb_type|= CANDIDATE_MB_TYPE_INTER; c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16); if(s->flags&CODEC_FLAG_MV0) @@ -1306,7 +1306,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, my <<=shift; } if((s->flags&CODEC_FLAG_4MV) - && !c->skip && varc>50 && vard>10){ + && !c->skip && varc>50<<8 && vard>10<<8){ if(h263_mv4_search(s, mx, my, shift) < INT_MAX) mb_type|=CANDIDATE_MB_TYPE_INTER4V; @@ -1327,7 +1327,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, dmin= ff_get_mb_score(s, mx, my, 0, 0, 0, 16, 1); if((s->flags&CODEC_FLAG_4MV) - && !c->skip && varc>50 && vard>10){ + && !c->skip && varc>50<<8 && vard>10<<8){ int dmin4= h263_mv4_search(s, mx, my, shift); if(dmin4 < dmin){ mb_type= CANDIDATE_MB_TYPE_INTER4V; @@ -1348,7 +1348,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, /* get intra luma score */ if((c->avctx->mb_cmp&0xFF)==FF_CMP_SSE){ - intra_score= (varc<<8) - 500; //FIXME dont scale it down so we dont have to fix it + intra_score= varc - 500; }else{ int mean= (sum+128)>>8; mean*= 0x01010101; @@ -1394,8 +1394,8 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, }else s->current_picture.mb_type[mb_y*s->mb_stride + mb_x]= 0; - if (vard <= 64 || vard < varc) { //FIXME - c->scene_change_score+= ff_sqrt(vard<<8) - ff_sqrt(varc<<8); + if (vard <= 64<<8 || vard < varc) { //FIXME + c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); }else{ c->scene_change_score+= s->qscale; } @@ -1815,26 +1815,26 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, c->skip=0; if(c->avctx->me_threshold){ - int vard= (check_input_motion(s, mb_x, mb_y, 0)+128)>>8; + int vard= check_input_motion(s, mb_x, mb_y, 0); - if(vard<c->avctx->me_threshold){ + if((vard+128)>>8 < c->avctx->me_threshold){ // pix = c->src[0][0]; // sum = s->dsp.pix_sum(pix, s->linesize); -// varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500 + 128)>>8; +// varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500; -// pic->mb_var [s->mb_stride * mb_y + mb_x] = varc; - s->current_picture.mc_mb_var[s->mb_stride * mb_y + mb_x] = vard; +// pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8; + s->current_picture.mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8; /* pic->mb_mean [s->mb_stride * mb_y + mb_x] = (sum+128)>>8; - c->mb_var_sum_temp += varc;*/ - c->mc_mb_var_sum_temp += vard; -/* if (vard <= 64 || vard < varc) { - c->scene_change_score+= ff_sqrt(vard<<8) - ff_sqrt(varc<<8); + c->mb_var_sum_temp += (varc+128)>>8;*/ + c->mc_mb_var_sum_temp += (vard+128)>>8; +/* if (vard <= 64<<8 || vard < varc) { + c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); }else{ c->scene_change_score+= s->qscale; }*/ return; } - if(vard<c->avctx->mb_threshold){ + if((vard+128)>>8 < c->avctx->mb_threshold){ type= s->mb_type[mb_y*s->mb_stride + mb_x]; if(type == CANDIDATE_MB_TYPE_DIRECT){ direct_search(s, mb_x, mb_y); diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index 8b8eb2ea22..109a77a929 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -71,14 +71,14 @@ b0235e9bf3cf3867064b9ff21cda76de *./data/a-mpeg4-thread.avi 764896 ./data/a-mpeg4-thread.avi d10f9ee6af493233f46a2ff2b178940a *./data/out.yuv stddev: 12.32 PSNR:26.30 bytes:7602176 -50867a2530035615152f1e068c989bfc *./data/a-mpeg4-Q.avi -899514 ./data/a-mpeg4-Q.avi -cdb77818e108eab89c9ac4bcaf350e19 *./data/out.yuv +88cfdda74f0488cf4a8324667a1ec9e8 *./data/a-mpeg4-Q.avi +899452 ./data/a-mpeg4-Q.avi +af59c063ed644c7dc4151a0a2debbddd *./data/out.yuv stddev: 5.69 PSNR:33.00 bytes:7602176 -f89ab211c5a4a0267fc0318c02d735ca *./data/a-error-mpeg4-adv.avi -750788 ./data/a-error-mpeg4-adv.avi -83c96db61822c4ee2b9d46f1055264c5 *./data/out.yuv -stddev: 17.22 PSNR:23.40 bytes:7602176 +dd193b592a02864d612c64cbbf5e1258 *./data/a-error-mpeg4-adv.avi +766682 ./data/a-error-mpeg4-adv.avi +e90b201e20563ec7817f5dc4276902ed *./data/out.yuv +stddev: 15.90 PSNR:24.09 bytes:7602176 adf36cbca712f8202d474cf1f99bdcd0 *./data/a-mpeg4-nr.avi 689772 ./data/a-mpeg4-nr.avi 79f4e8263e40822c0cbf35725f375b24 *./data/out.yuv diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref index 8e62077bc0..ccf79444c6 100644 --- a/tests/rotozoom.regression.ref +++ b/tests/rotozoom.regression.ref @@ -51,9 +51,9 @@ stddev: 5.44 PSNR:33.41 bytes:7602176 868164 ./data/a-h263p.avi 80fb224bebbe2e04f228da7485b905c5 *./data/out.yuv stddev: 1.91 PSNR:42.49 bytes:7602176 -0c19edbe67bfbb521569ee95ebdd3fa5 *./data/a-odivx.mp4 -120196 ./data/a-odivx.mp4 -8b7657a7f9fc7298cc016abb466d1d19 *./data/out.yuv +c23f4022c3af937da7200b3ce8547910 *./data/a-odivx.mp4 +120178 ./data/a-odivx.mp4 +e8c90899c32e11e7e4d1354dab0b8f28 *./data/out.yuv stddev: 5.34 PSNR:33.56 bytes:7602176 4a8912deb0182471aaaf4fc3ece39fb2 *./data/a-huffyuv.avi 6454196 ./data/a-huffyuv.avi @@ -63,26 +63,26 @@ stddev: 0.00 PSNR:99.99 bytes:7602176 227834 ./data/a-mpeg4-rc.avi 2e02fa0261c21268d568ddde74f9431e *./data/out.yuv stddev: 4.26 PSNR:35.51 bytes:7602176 -6844785bcca74b4b9dc77ce6d21a3871 *./data/a-mpeg4-adv.avi -172538 ./data/a-mpeg4-adv.avi -49fecc1105d25ff1c2fc9c0d4cb821b0 *./data/out.yuv -stddev: 4.84 PSNR:34.41 bytes:7602176 -9f7f5a7da720ba720aa35d72ed062959 *./data/a-mpeg4-thread.avi -253448 ./data/a-mpeg4-thread.avi -672eff5de3b19df7b82ed3e6bed8642d *./data/out.yuv +49bb293a098ebf88870f663d590a02d9 *./data/a-mpeg4-adv.avi +172526 ./data/a-mpeg4-adv.avi +e3445dab9a3fa83a0f86457e24cb0cea *./data/out.yuv +stddev: 4.84 PSNR:34.42 bytes:7602176 +66de0faff3660a0893996b39742a4c02 *./data/a-mpeg4-thread.avi +253428 ./data/a-mpeg4-thread.avi +0f23dbeb37f14b71cfae86dfe6c0b0e4 *./data/out.yuv stddev: 4.05 PSNR:35.96 bytes:7602176 -1d39759d16065aeb96cc81aabd735f78 *./data/a-mpeg4-Q.avi -165034 ./data/a-mpeg4-Q.avi -b15dac581c3ba6e5e016df5dea360dc0 *./data/out.yuv +bb7f7889f0694a1c499041f3ee5e234d *./data/a-mpeg4-Q.avi +164998 ./data/a-mpeg4-Q.avi +b078f22c66083f0537bd3581509684d8 *./data/out.yuv stddev: 4.01 PSNR:36.05 bytes:7602176 -217c694a61eea2dd8896d558fed3fc05 *./data/a-error-mpeg4-adv.avi -175778 ./data/a-error-mpeg4-adv.avi -62106b2ae4c1cfc985face2dadb90cbc *./data/out.yuv -stddev: 10.05 PSNR:28.08 bytes:7602176 -75aeb8364b81a458af5523c4a2bfdb39 *./data/a-mpeg4-nr.avi -154392 ./data/a-mpeg4-nr.avi -33a6f702049ef4e074c6266b9d17d3e9 *./data/out.yuv -stddev: 4.73 PSNR:34.61 bytes:7602176 +74b9ddde044f90c8ee25042e9faaef68 *./data/a-error-mpeg4-adv.avi +177212 ./data/a-error-mpeg4-adv.avi +9fa0943825f364d6fb700dc75cf5d8bb *./data/out.yuv +stddev: 9.71 PSNR:28.37 bytes:7602176 +edf6bf425e6e5f78bdd1b992003aee9a *./data/a-mpeg4-nr.avi +154302 ./data/a-mpeg4-nr.avi +b69fc415185075bdb21bedeae03d20b8 *./data/out.yuv +stddev: 4.73 PSNR:34.62 bytes:7602176 1286f6db500a739f724994991be211b0 *./data/a-mpeg1b.mpg 231292 ./data/a-mpeg1b.mpg a0eeed27d5123995b32210dc35052cfe *./data/out.yuv |