[x264-devel] MBAFF: Disallow skip where predicted interlace flag would be wrong

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


x264 | branch: master | Simon Horlick <simonhorlick at gmail.com> | Tue Mar 29 20:26:33 2011 +0100| [31ae5ddaa4342679a14f3339b37b4fd484d32913] | committer: Jason Garrett-Glaser

MBAFF: Disallow skip where predicted interlace flag would be wrong

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

 common/common.h      |    1 +
 common/macroblock.c  |   25 +++++++++++++++++++++++++
 encoder/macroblock.c |    7 +------
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/common/common.h b/common/common.h
index 1cc6508..085f257 100644
--- a/common/common.h
+++ b/common/common.h
@@ -618,6 +618,7 @@ struct x264_t
         int     i_mb_topright_y;
         x264_left_table_t *left_index_table;
         int     topleft_partition;
+        int     b_allow_skip;
 
         /**** thread synchronization ends here ****/
         /* subsequent variables are either thread-local or constant,
diff --git a/common/macroblock.c b/common/macroblock.c
index b2941c3..3ee8ca6 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -1109,6 +1109,31 @@ void x264_macroblock_cache_load( x264_t *h, int mb_x, int mb_y )
         }
     }
 
+    /* Check whether skip here would cause decoder to predict interlace mode incorrectly.
+     * FIXME: It might be better to change the interlace type rather than forcing a skip to be non-skip. */
+    h->mb.b_allow_skip = 1;
+    if( h->sh.b_mbaff )
+    {
+        if( (mb_y&1) && IS_SKIP(h->mb.type[h->mb.i_mb_xy - h->mb.i_mb_stride]) )
+        {
+            if( h->mb.i_neighbour & MB_LEFT )
+            {
+                if( h->mb.field[h->mb.i_mb_xy - 1] != h->mb.b_interlaced )
+                    h->mb.b_allow_skip = 0;
+            }
+            else if( h->mb.i_neighbour & MB_TOP )
+            {
+                if( h->mb.field[h->mb.i_mb_top_xy] != h->mb.b_interlaced )
+                    h->mb.b_allow_skip = 0;
+            }
+            else // Frame mb pair is predicted
+            {
+                if( h->mb.b_interlaced )
+                    h->mb.b_allow_skip = 0;
+            }
+        }
+    }
+
     /* load skip */
     if( h->sh.i_type == SLICE_TYPE_B )
     {
diff --git a/encoder/macroblock.c b/encoder/macroblock.c
index 9f0aae9..d1a7eb1 100644
--- a/encoder/macroblock.c
+++ b/encoder/macroblock.c
@@ -569,13 +569,8 @@ void x264_macroblock_encode( x264_t *h )
         return;
     }
 
-    if( h->sh.b_mbaff
-        && h->mb.i_mb_xy == h->sh.i_first_mb + h->mb.i_mb_stride
-        && IS_SKIP(h->mb.type[h->sh.i_first_mb]) )
+    if( !h->mb.b_allow_skip )
     {
-        /* The first skip is predicted to be a frame mb pair.
-         * We don't yet support the aff part of mbaff, so force it to non-skip
-         * so that we can pick the aff flag. */
         b_force_no_skip = 1;
         if( IS_SKIP(h->mb.i_type) )
         {



More information about the x264-devel mailing list