]> git.sesse.net Git - x264/commitdiff
MBAFF: Add support for slice-max-size
authorSimon Horlick <simonhorlick@gmail.com>
Wed, 23 Mar 2011 21:55:03 +0000 (21:55 +0000)
committerFiona Glaser <fiona@x264.com>
Thu, 12 May 2011 06:06:59 +0000 (23:06 -0700)
Also add slice-max-size to the regression tests.

encoder/encoder.c
tools/test_x264.py

index b67c7243704e82d71d97a88ac42e44363db4d98d..599b7032a3eb7103d756fb506ac7209971b7b83a 100644 (file)
@@ -572,11 +572,6 @@ static int x264_validate_parameters( x264_t *h, int b_open )
         h->param.rc.i_vbv_max_bitrate = 0;
     }
 
-    if( h->param.b_interlaced && h->param.i_slice_max_size )
-    {
-        x264_log( h, X264_LOG_WARNING, "interlaced + slice-max-size is not implemented\n" );
-        h->param.i_slice_max_size = 0;
-    }
     h->param.i_slice_max_size = X264_MAX( h->param.i_slice_max_size, 0 );
     h->param.i_slice_max_mbs = X264_MAX( h->param.i_slice_max_mbs, 0 );
 
@@ -2026,7 +2021,7 @@ static int x264_slice_write( x264_t *h )
         if( x264_bitstream_check_buffer( h ) )
             return -1;
 
-        if( back_up_bitstream )
+        if( back_up_bitstream && (!h->sh.b_mbaff || (i_mb_y&1) == 0) )
         {
             mv_bits_bak = h->stat.frame.i_mv_bits;
             tex_bits_bak = h->stat.frame.i_tex_bits;
@@ -2151,7 +2146,16 @@ reencode:
                         i_skip = i_skip_bak;
                     }
                     h->mb.b_reencode_mb = 1;
-                    h->sh.i_last_mb = mb_xy-1;
+                    if( h->sh.b_mbaff )
+                    {
+                        // set to bottom of previous mbpair
+                        if( i_mb_x )
+                            h->sh.i_last_mb = mb_xy-1+h->mb.i_mb_stride*(!(i_mb_y&1));
+                        else
+                            h->sh.i_last_mb = (i_mb_y-2+!(i_mb_y&1))*h->mb.i_mb_stride + h->mb.i_mb_width - 1;
+                    }
+                    else
+                        h->sh.i_last_mb = mb_xy-1;
                     break;
                 }
                 else
index c02e5dcfead5de8d1c76945033dda956478dbba3..bb98b6558515099b22bb860b1bc7986491df48da 100755 (executable)
@@ -35,6 +35,7 @@ OPTIONS = [
     ("", "--intra-refresh"),
     ("", "--no-cabac"),
     ("", "--interlaced"),
+    ("", "--slice-max-size 1000"),
     ("", "--frame-packing 5"),
     [ "--preset %s" % p for p in ("ultrafast",
                                   "superfast",