]> git.sesse.net Git - x264/commitdiff
MBAFF: Add regularization to VSAD metric
authorFiona Glaser <fiona@x264.com>
Mon, 9 May 2011 01:46:52 +0000 (18:46 -0700)
committerFiona Glaser <fiona@x264.com>
Thu, 12 May 2011 06:07:17 +0000 (23:07 -0700)
Bias towards the MBAFF decisions made in neighboring mb pairs.
~2% better compression on a random 1080i HDTV source.

common/pixel.c

index 5a4565523d42f174b138f81de9fa1b0ccdb24de9..f1e45915899cb110ac78ea8766bcf9bed29dec32 100644 (file)
@@ -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);
 }