From: Jason Garrett-Glaser Date: Mon, 9 May 2011 01:46:52 +0000 (-0700) Subject: MBAFF: Add regularization to VSAD metric X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=949846678208f15e31d9de8446dbfe05df664a69;p=x264.git MBAFF: Add regularization to VSAD metric Bias towards the MBAFF decisions made in neighboring mb pairs. ~2% better compression on a random 1080i HDTV source. --- diff --git a/common/pixel.c b/common/pixel.c index 0dec7912..cf8be634 100644 --- a/common/pixel.c +++ b/common/pixel.c @@ -654,7 +654,9 @@ int x264_field_vsad( x264_t *h, int mb_x, int mb_y ) { int score_field, score_frame; int stride = h->fenc->i_stride[0]; + int mb_stride = h->mb.i_mb_stride; pixel *fenc = h->fenc->plane[0] + 16 * (mb_x + mb_y * stride); + int mb_xy = mb_x + mb_y*mb_stride; /* We don't want to analyze pixels outside the frame, as it gives inaccurate results. */ int mbpair_height = X264_MIN( h->param.i_height - mb_y * 16, 32 ); @@ -662,6 +664,11 @@ int x264_field_vsad( x264_t *h, int mb_x, int mb_y ) score_field = h->pixf.vsad( fenc, stride*2, mbpair_height >> 1 ); score_field += h->pixf.vsad( fenc+stride, stride*2, mbpair_height >> 1 ); + if( mb_x > 0 ) + score_field += 512 - h->mb.field[mb_xy -1]*1024; + if( mb_y > 0 ) + score_field += 512 - h->mb.field[mb_xy-mb_stride]*1024; + return (score_field < score_frame); }