Commit 7ad06554 authored by Fiona Glaser's avatar Fiona Glaser

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.
parent 1c7caa53
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment