]> git.sesse.net Git - x264/commitdiff
MBAFF: Enable adaptive MBAFF with VSAD decision
authorSimon Horlick <simonhorlick@gmail.com>
Mon, 14 Mar 2011 02:54:30 +0000 (02:54 +0000)
committerFiona Glaser <fiona@x264.com>
Thu, 12 May 2011 06:06:52 +0000 (23:06 -0700)
common/pixel.c
common/pixel.h
encoder/encoder.c

index a8a1a05056d8309f68ffdbfd3568b18b9d19b5fb..66378b64e8420a4812a3d0f9f0824d0be457ef59 100644 (file)
@@ -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
  ****************************************************************************/
index 8d31b7c27149dc1f8948e24ddae08ddb29635d17..ab6683323ddfdf5e4f39a5935c2634a584fe7b51 100644 (file)
@@ -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
index d77335c3a2eb93535c97c8b945341bda9f50f6c2..6ff8071a5924d0b3e20b553267d3906e27bd5eb9 100644 (file)
@@ -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;