[x264-devel] MBAFF: Enable adaptive MBAFF with VSAD decision
Simon Horlick
git at videolan.org
Thu May 12 08:39:06 CEST 2011
x264 | branch: master | Simon Horlick <simonhorlick at gmail.com> | Mon Mar 14 02:54:30 2011 +0000| [115225d9d9df8e59e22b0874a20b44bb528c7bdd] | committer: Jason Garrett-Glaser
MBAFF: Enable adaptive MBAFF with VSAD decision
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=115225d9d9df8e59e22b0874a20b44bb528c7bdd
---
common/pixel.c | 10 ++++++++++
common/pixel.h | 1 +
encoder/encoder.c | 7 ++++++-
3 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/common/pixel.c b/common/pixel.c
index 58439af..0d37dd1 100644
--- a/common/pixel.c
+++ b/common/pixel.c
@@ -650,6 +650,16 @@ int pixel_vsad( pixel *src, int stride )
return score;
}
+int x264_field_vsad( x264_t *h, pixel *fenc, int stride )
+{
+ int score_field, score_frame;
+ score_frame = h->pixf.vsad( fenc, stride );
+ score_frame += h->pixf.vsad( fenc+16*stride, stride );
+ score_field = h->pixf.vsad( fenc, stride*2 );
+ score_field += h->pixf.vsad( fenc+stride, stride*2 );
+ return (score_field < score_frame);
+}
+
/****************************************************************************
* successive elimination
****************************************************************************/
diff --git a/common/pixel.h b/common/pixel.h
index c464345..d2b3582 100644
--- a/common/pixel.h
+++ b/common/pixel.h
@@ -126,5 +126,6 @@ void x264_pixel_init( int cpu, x264_pixel_function_t *pixf );
void x264_pixel_ssd_nv12( x264_pixel_function_t *pf, pixel *pix1, int i_pix1, pixel *pix2, int i_pix2, int i_width, int i_height, uint64_t *ssd_u, uint64_t *ssd_v );
uint64_t x264_pixel_ssd_wxh( x264_pixel_function_t *pf, pixel *pix1, int i_pix1, pixel *pix2, int i_pix2, int i_width, int i_height );
float x264_pixel_ssim_wxh( x264_pixel_function_t *pf, pixel *pix1, int i_pix1, pixel *pix2, int i_pix2, int i_width, int i_height, void *buf );
+int x264_field_vsad( x264_t *h, pixel *fenc, int stride );
#endif
diff --git a/encoder/encoder.c b/encoder/encoder.c
index d06b28e..18f203c 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -2057,7 +2057,12 @@ static int x264_slice_write( x264_t *h )
if( h->mb.b_adaptive_mbaff )
{
if( !(i_mb_y&1) )
- h->mb.b_interlaced = 1;
+ {
+ /* FIXME: VSAD is fast but fairly poor at choosing the best interlace type. */
+ int stride = h->fenc->i_stride[0];
+ pixel *fenc = h->fenc->plane[0] + 16 * (i_mb_x + i_mb_y * stride);
+ h->mb.b_interlaced = x264_field_vsad( h, fenc, stride );
+ }
x264_zigzag_init( h->param.cpu, &h->zigzagf, h->mb.b_interlaced );
}
h->mb.field[mb_xy] = h->mb.b_interlaced;
More information about the x264-devel
mailing list