]> git.videolan.org Git - x264.git/commitdiff
MBAFF: Disallow skip where predicted interlace flag would be wrong
authorSimon Horlick <simonhorlick@gmail.com>
Tue, 29 Mar 2011 19:26:33 +0000 (20:26 +0100)
committerJason Garrett-Glaser <jason@x264.com>
Thu, 12 May 2011 06:06:10 +0000 (23:06 -0700)
common/common.h
common/macroblock.c
encoder/macroblock.c

index 1cc6508db412456fee4a1607f5b3e7fe9e0cc712..085f257a53dc4a0f612058f51fd08dfd71321f69 100644 (file)
@@ -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,
index b2941c37b495c6f36f4b56670b721a42982d5765..3ee8ca6d606bc756c084d18409270dcecb768ab6 100644 (file)
@@ -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 )
     {
index 9f0aae9d038516c34ec9fed60ac6a4b7a8e84985..d1a7eb1dc209d1f2bc6d79111751d39ad4af3ccf 100644 (file)
@@ -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) )
         {