[x264-devel] MBAFF: Disable adaptive MBAFF when subme 0 is used

Simon Horlick git at videolan.org
Thu May 12 08:38:58 CEST 2011


x264 | branch: master | Simon Horlick <simonhorlick at gmail.com> | Tue Jan 11 20:09:00 2011 +0000| [e8f59709185ac5e5f3f3d37e64509dc1e61bf415] | committer: Jason Garrett-Glaser

MBAFF: Disable adaptive MBAFF when subme 0 is used

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=e8f59709185ac5e5f3f3d37e64509dc1e61bf415
---

 common/common.h   |    1 +
 encoder/encoder.c |   13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/common/common.h b/common/common.h
index d65c126..4ef96b8 100644
--- a/common/common.h
+++ b/common/common.h
@@ -574,6 +574,7 @@ struct x264_t
         int     i_psy_trellis; /* Psy trellis strength--fixed point value*/
 
         int     b_interlaced;
+        int     b_adaptive_mbaff; /* MBAFF+subme 0 requires non-adaptive MBAFF i.e. all field mbs */
 
         /* Allowed qpel MV range to stay within the picture + emulated edge pixels */
         int     mv_min[2];
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 657e295..16f92aa 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -1035,6 +1035,10 @@ x264_t *x264_encoder_open( x264_param_t *param )
     h->mb.i_mb_width = h->sps->i_mb_width;
     h->mb.i_mb_height = h->sps->i_mb_height;
     h->mb.i_mb_count = h->mb.i_mb_width * h->mb.i_mb_height;
+    /* Adaptive MBAFF and subme 0 are not supported as we require halving motion
+     * vectors during prediction, resulting in hpel mvs.
+     * The chosen solution is to make MBAFF non-adaptive in this case. */
+    h->mb.b_adaptive_mbaff = h->param.b_interlaced && h->param.analyse.i_subpel_refine;
 
     /* Init frames. */
     if( h->param.i_bframe_adaptive == X264_B_ADAPT_TRELLIS && !h->param.rc.b_stat_read )
@@ -2031,9 +2035,12 @@ static int x264_slice_write( x264_t *h )
 
         if( h->param.b_interlaced )
         {
-            if( !(i_mb_y&1) )
-                h->mb.b_interlaced = 1;
-            x264_zigzag_init( h->param.cpu, &h->zigzagf, h->mb.b_interlaced );
+            if( h->mb.b_adaptive_mbaff )
+            {
+                if( !(i_mb_y&1) )
+                    h->mb.b_interlaced = 1;
+                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