From 693b0e1d66e08aec96669cb596acb545643992ea Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 23 Sep 2002 15:16:09 +0000 Subject: [PATCH] fixing variance scaling for b frames (messed adaptive quants up) cliping too long MVs in b frames instead of setting them to 0 Originally committed as revision 965 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/motion_est.c | 23 ++++++++++------------- tests/ffmpeg.regression.ref | 4 ++-- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index d4ee88bf6f..c59e06b48a 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1546,7 +1546,7 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, score=fbmin; type= MB_TYPE_BIDIR; } - score= (score*score)>>8; + score= (score*score + 128*256)>>16; s->mc_mb_var_sum += score; s->mc_mb_var[mb_y*s->mb_width + mb_x] = score; //FIXME use SSD } @@ -1698,18 +1698,15 @@ void ff_fix_long_b_mvs(MpegEncContext * s, int16_t (*mv_table)[2], int f_code, i int xy= (y+1)* (s->mb_width+2)+1; int i= y*s->mb_width; for(x=0; xmb_width; x++){ - if(s->mb_type[i]&type){ - if( fcode_tab[mv_table[xy][0] + MAX_MV] > f_code - || fcode_tab[mv_table[xy][0] + MAX_MV] == 0 - || fcode_tab[mv_table[xy][1] + MAX_MV] > f_code - || fcode_tab[mv_table[xy][1] + MAX_MV] == 0 ){ - if(s->mb_type[i]&(~type)) s->mb_type[i] &= ~type; - else{ - mv_table[xy][0] = 0; - mv_table[xy][1] = 0; - //this is certainly bad FIXME - } - } + if( fcode_tab[mv_table[xy][0] + MAX_MV] > f_code + || fcode_tab[mv_table[xy][0] + MAX_MV] == 0){ + if(mv_table[xy][0]>0) mv_table[xy][0]= (16< f_code + || fcode_tab[mv_table[xy][1] + MAX_MV] == 0){ + if(mv_table[xy][1]>0) mv_table[xy][1]= (16<