CWG-D078 BLOCK_256 Partitions

Performance relative to v5 anchor:
| CONFIG |  b2  | PSNR_YUV | Enc Time | Dec Time |
| :----: | :--: | :------: | :------: | :------: |
|   AI   |  w/o |  +0.04%  |   102%   |   109%   |
|        | only |  +0.02%  |   104%   |   109%   |
|        |      |          |          |          |
|   RA   |  w/o |  -0.47%  |   116%   |   105%   |
|        | only |  -0.16%  |   132%   |   104%   |
|        |      |          |          |          |
|   LD   |  w/o |  -0.41%  |   118%   |   107%   |
|        | only |  -0.47%  |   129%   |   103%   |

STATS_CHANGED
diff --git a/aom/aom_encoder.h b/aom/aom_encoder.h
index ec1d73f..f2f687e 100644
--- a/aom/aom_encoder.h
+++ b/aom/aom_encoder.h
@@ -246,6 +246,20 @@
    * 0 or 1
    */
   unsigned int init_by_cfg_file;
+#if CONFIG_BLOCK_256
+  /*!\brief Superblock size
+   * 0, 64, 128 or 256
+   */
+  unsigned int superblock_size;
+  /*!\brief max partition size
+   * 8, 16, 32, 64, 128, 256
+   */
+  unsigned int max_partition_size;
+  /*!\brief min partition size
+   * 8, 16, 32, 64, 128, 256
+   */
+  unsigned int min_partition_size;
+#else
   /*!\brief Superblock size
    * 0, 64 or 128
    */
@@ -258,6 +272,7 @@
    * 8, 16, 32, 64, 128
    */
   unsigned int min_partition_size;
+#endif  // CONFIG_BLOCK_256
   /*!\brief enable AB Shape partition type
    *
    */
diff --git a/aom/src/aom_encoder.c b/aom/src/aom_encoder.c
index ef6e472..6909767 100644
--- a/aom/src/aom_encoder.c
+++ b/aom/src/aom_encoder.c
@@ -93,7 +93,11 @@
   if (cfg) {
     memset(&cfg->encoder_cfg, 0, sizeof(cfg->encoder_cfg));
     cfg->encoder_cfg.superblock_size = 0;  // Dynamic
+#if CONFIG_BLOCK_256
+    cfg->encoder_cfg.max_partition_size = 256;
+#else
     cfg->encoder_cfg.max_partition_size = 128;
+#endif  // CONFIG_BLOCK_256
     cfg->encoder_cfg.min_partition_size = 4;
     cfg->encoder_cfg.enable_trellis_quant = 3;
   }
diff --git a/aom_dsp/aom_dsp_common.h b/aom_dsp/aom_dsp_common.h
index c2b7d37..5901fe8 100644
--- a/aom_dsp/aom_dsp_common.h
+++ b/aom_dsp/aom_dsp_common.h
@@ -22,10 +22,6 @@
 extern "C" {
 #endif
 
-#ifndef MAX_SB_SIZE
-#define MAX_SB_SIZE 128
-#endif  // ndef MAX_SB_SIZE
-
 #define AOMMIN(x, y) (((x) < (y)) ? (x) : (y))
 #define AOMMAX(x, y) (((x) > (y)) ? (x) : (y))
 #define AOMSIGN(x) ((x) < 0 ? -1 : 0)
diff --git a/aom_dsp/aom_dsp_rtcd_defs.pl b/aom_dsp/aom_dsp_rtcd_defs.pl
index fd5f94f..f278fcc 100755
--- a/aom_dsp/aom_dsp_rtcd_defs.pl
+++ b/aom_dsp/aom_dsp_rtcd_defs.pl
@@ -39,7 +39,11 @@
   $avx2_x86_64 = 'avx2';
 }
 
-@block_widths = (4, 8, 16, 32, 64, 128);
+if (aom_config("CONFIG_BLOCK_256") eq "yes"){
+  @block_widths = (4, 8, 16, 32, 64, 128, 256);
+} else {
+  @block_widths = (4, 8, 16, 32, 64, 128);
+}
 
 @block_sizes = ();
 foreach $w (@block_widths) {
@@ -311,7 +315,7 @@
     add_proto qw/unsigned int/, "aom_highbd_sad${w}x${h}", "const uint16_t *src_ptr, int src_stride, const uint16_t *ref_ptr, int ref_stride";
     add_proto qw/unsigned int/, "aom_highbd_sad_skip_${w}x${h}", "const uint16_t *src_ptr, int src_stride, const uint16_t *ref_ptr, int ref_stride";
     add_proto qw/unsigned int/, "aom_highbd_sad${w}x${h}_avg", "const uint16_t *src_ptr, int src_stride, const uint16_t *ref_ptr, int ref_stride, const uint16_t *second_pred";
-    if ($w != 128 && $h != 128 && $w != 4) {
+    if ($w != 128 && $h != 128 && $w != 4 && $w != 256 && $h != 256) {
       if (aom_config("CONFIG_UNEVEN_4WAY") eq "yes") {
         if (!($w == 16 && $h == 16) && !($w == 16 && $h == 8) && !($w == 16 && $h == 4)) {
           specialize "aom_highbd_sad${w}x${h}", qw/sse2/;
@@ -324,6 +328,9 @@
     }
     add_proto qw/unsigned int/, "aom_highbd_dist_wtd_sad${w}x${h}_avg", "const uint16_t *src_ptr, int src_stride, const uint16_t *ref_ptr, int ref_stride, const uint16_t *second_pred, const DIST_WTD_COMP_PARAMS* jcp_param";
   }
+  specialize qw/aom_highbd_sad256x256 avx2/;
+  specialize qw/aom_highbd_sad256x128 avx2/;
+  specialize qw/aom_highbd_sad128x256 avx2/;
   specialize qw/aom_highbd_sad128x128 avx2/;
   specialize qw/aom_highbd_sad128x64  avx2/;
   specialize qw/aom_highbd_sad64x128  avx2/;
@@ -353,6 +360,10 @@
   specialize qw/aom_highbd_sad32x8    avx2 sse2/;
   specialize qw/aom_highbd_sad16x64   avx2 sse2/;
   specialize qw/aom_highbd_sad64x16   avx2 sse2/;
+
+  specialize qw/aom_highbd_sad_skip_256x256 avx2/;
+  specialize qw/aom_highbd_sad_skip_256x128 avx2/;
+  specialize qw/aom_highbd_sad_skip_128x256 avx2/;
   specialize qw/aom_highbd_sad_skip_128x128 avx2/;
   specialize qw/aom_highbd_sad_skip_128x64  avx2/;
   specialize qw/aom_highbd_sad_skip_64x128  avx2/;
@@ -379,6 +390,9 @@
   specialize qw/aom_highbd_sad_skip_16x64   avx2 sse2/;
   specialize qw/aom_highbd_sad_skip_64x16   avx2 sse2/;
 
+  specialize qw/aom_highbd_sad256x256_avg avx2/;
+  specialize qw/aom_highbd_sad256x128_avg avx2/;
+  specialize qw/aom_highbd_sad128x256_avg avx2/;
   specialize qw/aom_highbd_sad128x128_avg avx2/;
   specialize qw/aom_highbd_sad128x64_avg  avx2/;
   specialize qw/aom_highbd_sad64x128_avg  avx2/;
@@ -411,7 +425,12 @@
   foreach (@block_sizes) {
     ($w, $h) = @$_;
     add_proto qw/unsigned int/, "aom_highbd_masked_sad${w}x${h}", "const uint16_t *src8, int src_stride, const uint16_t *ref8, int ref_stride, const uint16_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask";
-    specialize "aom_highbd_masked_sad${w}x${h}", qw/ssse3 avx2/;
+    # TODO(any): Add ssse3 optimization
+    if ($w == 256 || $h == 256) {
+      specialize "aom_highbd_masked_sad${w}x${h}", qw/avx2/;
+    } else {
+      specialize "aom_highbd_masked_sad${w}x${h}", qw/ssse3 avx2/;
+    }
   }
 
   #
@@ -420,7 +439,10 @@
   foreach (@block_sizes) {
     ($w, $h) = @$_;
     add_proto qw/unsigned int/, "aom_highbd_obmc_sad${w}x${h}", "const uint16_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask";
-    if (! (($w == 128 && $h == 32) || ($w == 32 && $h == 128))) {
+    # TODO(any): Add sse4.1 optimization
+    if ($w == 256 || $h == 256) {
+      specialize "aom_highbd_obmc_sad${w}x${h}", qw/avx2/;
+    } elsif (! (($w == 128 && $h == 32) || ($w == 32 && $h == 128))) {
       specialize "aom_highbd_obmc_sad${w}x${h}", qw/sse4_1 avx2/;
     }
   }
@@ -432,10 +454,13 @@
     ($w, $h) = @$_;
     add_proto qw/void/, "aom_highbd_sad${w}x${h}x4d", "const uint16_t *src_ptr, int src_stride, const uint16_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
     add_proto qw/void/, "aom_highbd_sad_skip_${w}x${h}x4d", "const uint16_t *src_ptr, int src_stride, const uint16_t * const ref_ptr[], int ref_stride, uint32_t *sad_array";
-    if ($w != 128 && $h != 128) {
+    if ($w != 128 && $h != 128 && $w != 256 && $h != 256) {
       specialize "aom_highbd_sad${w}x${h}x4d", qw/sse2/;
     }
   }
+  specialize qw/aom_highbd_sad256x256x4d avx2/;
+  specialize qw/aom_highbd_sad256x128x4d avx2/;
+  specialize qw/aom_highbd_sad128x256x4d avx2/;
   specialize qw/aom_highbd_sad128x128x4d avx2/;
   specialize qw/aom_highbd_sad128x64x4d  avx2/;
   specialize qw/aom_highbd_sad64x128x4d  avx2/;
@@ -460,6 +485,9 @@
   specialize qw/aom_highbd_sad16x64x4d   avx2 sse2/;
   specialize qw/aom_highbd_sad64x16x4d   avx2 sse2/;
 
+  specialize qw/aom_highbd_sad_skip_256x256x4d avx2/;
+  specialize qw/aom_highbd_sad_skip_256x128x4d avx2/;
+  specialize qw/aom_highbd_sad_skip_128x256x4d avx2/;
   specialize qw/aom_highbd_sad_skip_128x128x4d avx2/;
   specialize qw/aom_highbd_sad_skip_128x64x4d  avx2/;
   specialize qw/aom_highbd_sad_skip_64x128x4d  avx2/;
@@ -567,30 +595,28 @@
       add_proto qw/unsigned int/, "aom_highbd_${bd}_variance${w}x${h}", "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, uint32_t *sse";
       add_proto qw/uint32_t/, "aom_highbd_${bd}_sub_pixel_variance${w}x${h}", "const uint16_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint16_t *ref_ptr, int ref_stride, uint32_t *sse";
       add_proto qw/uint32_t/, "aom_highbd_${bd}_sub_pixel_avg_variance${w}x${h}", "const uint16_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint16_t *ref_ptr, int ref_stride, uint32_t *sse, const uint16_t *second_pred";
-      if ($w != 128 && $h != 128 && $w != 4 && $h != 4) {
+      if ($w != 128 && $h != 128 && $w != 4 && $h != 4 && $w != 256 && $h != 256) {
         specialize "aom_highbd_${bd}_variance${w}x${h}", "sse2";
       }
       # TODO(rachelbarker): When ext-partition-types is enabled, we currently
       # don't have vectorized 4x16 highbd variance functions
       if ($w == 4 && $h == 4) {
         specialize "aom_highbd_${bd}_variance${w}x${h}", "sse4_1";
+        specialize "aom_highbd_${bd}_sub_pixel_variance${w}x${h}", "sse4_1";
+        specialize "aom_highbd_${bd}_sub_pixel_avg_variance${w}x${h}", "sse4_1";
       }
       if (aom_config("CONFIG_UNEVEN_4WAY") eq "yes") {
         if ($w != 128 && $h != 128 && $w != 4 && !($w == 16 && $h == 16) &&
-            !($w == 16 && $h == 8) && !($w == 16 && $h == 4)) {
+            !($w == 16 && $h == 8) && !($w == 16 && $h == 4) && $w != 256 && $h != 256) {
           specialize "aom_highbd_${bd}_sub_pixel_variance${w}x${h}", qw/sse2/;
           specialize "aom_highbd_${bd}_sub_pixel_avg_variance${w}x${h}", qw/sse2/;
         }
       } else {
-        if ($w != 128 && $h != 128 && $w != 4) {
+        if ($w != 128 && $h != 128 && $w != 4 && $w != 256 && $h != 256) {
           specialize "aom_highbd_${bd}_sub_pixel_variance${w}x${h}", qw/sse2/;
           specialize "aom_highbd_${bd}_sub_pixel_avg_variance${w}x${h}", qw/sse2/;
         }
       }  # CONFIG_UNEVEN_4WAY
-      if ($w == 4 && $h == 4) {
-        specialize "aom_highbd_${bd}_sub_pixel_variance${w}x${h}", "sse4_1";
-        specialize "aom_highbd_${bd}_sub_pixel_avg_variance${w}x${h}", "sse4_1";
-      }
 
       add_proto qw/uint32_t/, "aom_highbd_${bd}_dist_wtd_sub_pixel_avg_variance${w}x${h}", "const uint16_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint16_t *ref_ptr, int ref_stride, uint32_t *sse, const uint16_t *second_pred, const DIST_WTD_COMP_PARAMS* jcp_param";
     }
@@ -621,6 +647,17 @@
   #
   # Variance
   #
+  if (aom_config("CONFIG_BLOCK_256") eq "yes"){
+    add_proto qw/unsigned int aom_highbd_12_variance256x256/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
+    specialize qw/aom_highbd_12_variance256x256 avx2/;
+
+    add_proto qw/unsigned int aom_highbd_12_variance256x128/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
+    specialize qw/aom_highbd_12_variance256x128 avx2/;
+
+    add_proto qw/unsigned int aom_highbd_12_variance128x256/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
+    specialize qw/aom_highbd_12_variance128x256 avx2/;
+  }
+
   add_proto qw/unsigned int aom_highbd_12_variance128x128/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
   specialize qw/aom_highbd_12_variance128x128 sse2 avx2/;
 
@@ -673,6 +710,18 @@
   add_proto qw/unsigned int aom_highbd_12_variance64x16/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
   specialize qw/aom_highbd_12_variance64x16 sse2 avx2/;
 
+
+  if (aom_config("CONFIG_BLOCK_256") eq "yes"){
+    add_proto qw/unsigned int aom_highbd_10_variance256x256/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
+    specialize qw/aom_highbd_10_variance256x256 avx2/;
+
+    add_proto qw/unsigned int aom_highbd_10_variance256x128/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
+    specialize qw/aom_highbd_10_variance256x128 avx2/;
+
+    add_proto qw/unsigned int aom_highbd_10_variance128x256/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
+    specialize qw/aom_highbd_10_variance128x256 avx2/;
+  }
+
   add_proto qw/unsigned int aom_highbd_10_variance128x128/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
   specialize qw/aom_highbd_10_variance128x128 sse2 avx2/;
 
@@ -725,6 +774,18 @@
   add_proto qw/unsigned int aom_highbd_10_variance64x16/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
   specialize qw/aom_highbd_10_variance64x16 sse2 avx2/;
 
+
+  if (aom_config("CONFIG_BLOCK_256") eq "yes"){
+    add_proto qw/unsigned int aom_highbd_8_variance256x256/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
+    specialize qw/aom_highbd_8_variance256x256 avx2/;
+
+    add_proto qw/unsigned int aom_highbd_8_variance256x128/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
+    specialize qw/aom_highbd_8_variance256x128 avx2/;
+
+    add_proto qw/unsigned int aom_highbd_8_variance128x256/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
+    specialize qw/aom_highbd_8_variance128x256 avx2/;
+  }
+
   add_proto qw/unsigned int aom_highbd_8_variance128x128/, "const uint16_t *src_ptr, int source_stride, const uint16_t *ref_ptr, int ref_stride, unsigned int *sse";
   specialize qw/aom_highbd_8_variance128x128 sse2 avx2/;
 
@@ -821,6 +882,12 @@
   #
   # Subpixel Variance
   #
+  if (aom_config("CONFIG_BLOCK_256") eq "yes"){
+    # specialize qw/aom_highbd_12_sub_pixel_variance256x256 avx2/;
+    # specialize qw/aom_highbd_12_sub_pixel_variance256x128 avx2/;
+    # specialize qw/aom_highbd_12_sub_pixel_variance128x256 avx2/;
+  }
+
   add_proto qw/uint32_t aom_highbd_12_sub_pixel_variance128x128/, "const uint16_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint16_t *ref_ptr, int ref_stride, uint32_t *sse";
   # specialize qw/aom_highbd_12_sub_pixel_variance128x128 sse2 avx2/;
   specialize qw/aom_highbd_12_sub_pixel_variance128x128 sse2/;
@@ -859,7 +926,7 @@
 
   add_proto qw/uint32_t aom_highbd_12_sub_pixel_variance16x16/, "const uint16_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint16_t *ref_ptr, int ref_stride, uint32_t *sse";
   if (aom_config("CONFIG_UNEVEN_4WAY") eq "yes") {
-    # specialize qw/aom_highbd_12_sub_pixel_variance16x16 avx2/;
+    # specialize qw/aom_highbd_12_sub_pixel_variance16x16 sse2/;
   } else {
     # specialize qw/aom_highbd_12_sub_pixel_variance16x16 sse2 avx2/;
     specialize qw/aom_highbd_12_sub_pixel_variance16x16 sse2/;
@@ -904,6 +971,12 @@
     specialize qw/aom_highbd_12_sub_pixel_variance16x4 sse2 avx2/;
   }
 
+  if (aom_config("CONFIG_BLOCK_256") eq "yes"){
+    specialize qw/aom_highbd_10_sub_pixel_variance256x256 avx2/;
+    specialize qw/aom_highbd_10_sub_pixel_variance256x128 avx2/;
+    specialize qw/aom_highbd_10_sub_pixel_variance128x256 avx2/;
+  }
+
   add_proto qw/uint32_t aom_highbd_10_sub_pixel_variance128x128/, "const uint16_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint16_t *ref_ptr, int ref_stride, uint32_t *sse";
   specialize qw/aom_highbd_10_sub_pixel_variance128x128 sse2 avx2/;
 
@@ -974,6 +1047,13 @@
     specialize qw/aom_highbd_10_sub_pixel_variance16x4 sse2 avx2/;
   }
 
+
+  if (aom_config("CONFIG_BLOCK_256") eq "yes"){
+    specialize qw/aom_highbd_8_sub_pixel_variance256x256 avx2/;
+    specialize qw/aom_highbd_8_sub_pixel_variance256x128 avx2/;
+    specialize qw/aom_highbd_8_sub_pixel_variance128x256 avx2/;
+  }
+
   add_proto qw/uint32_t aom_highbd_8_sub_pixel_variance128x128/, "const uint16_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint16_t *ref_ptr, int ref_stride, uint32_t *sse";
   specialize qw/aom_highbd_8_sub_pixel_variance128x128 sse2 avx2/;
 
diff --git a/aom_dsp/sad.c b/aom_dsp/sad.c
index aa73d11..017edba 100644
--- a/aom_dsp/sad.c
+++ b/aom_dsp/sad.c
@@ -42,6 +42,17 @@
     return highbd_sad(src, src_stride, ref, ref_stride, m, n);  \
   }
 
+#if CONFIG_BLOCK_256
+// 256X256
+highbd_sadMxN(256, 256);
+
+// 256X128
+highbd_sadMxN(256, 128);
+
+// 128X256
+highbd_sadMxN(128, 256);
+#endif  // CONFIG_BLOCK_256
+
 // 128x128
 highbd_sadMxN(128, 128);
 
diff --git a/aom_dsp/sad4d.c b/aom_dsp/sad4d.c
index 3d970b1..73a51fb 100644
--- a/aom_dsp/sad4d.c
+++ b/aom_dsp/sad4d.c
@@ -95,6 +95,20 @@
     }                                                                         \
   }
 
+#if CONFIG_BLOCK_256
+// 256X256
+highbd_avg_skip_sadMxN(256, 256);
+highbd_sadMxNx4D(256, 256);
+
+// 256X128
+highbd_avg_skip_sadMxN(256, 128);
+highbd_sadMxNx4D(256, 128);
+
+// 128X256
+highbd_avg_skip_sadMxN(128, 256);
+highbd_sadMxNx4D(128, 256);
+#endif  // CONFIG_BLOCK_256
+
 // 128x128
 highbd_avg_skip_sadMxN(128, 128);
 highbd_sadMxNx4D(128, 128);
diff --git a/aom_dsp/sad_av1.c b/aom_dsp/sad_av1.c
index 040aede..9334f10 100644
--- a/aom_dsp/sad_av1.c
+++ b/aom_dsp/sad_av1.c
@@ -57,6 +57,11 @@
                                ref_stride, msk, msk_stride, m, n);            \
   }
 
+#if CONFIG_BLOCK_256
+HIGHBD_MASKSADMXN(256, 256)
+HIGHBD_MASKSADMXN(256, 128)
+HIGHBD_MASKSADMXN(128, 256)
+#endif  // CONFIG_BLOCK_256
 HIGHBD_MASKSADMXN(128, 128)
 HIGHBD_MASKSADMXN(128, 64)
 HIGHBD_MASKSADMXN(64, 128)
@@ -113,6 +118,11 @@
   }
 
 /* clang-format off */
+#if CONFIG_BLOCK_256
+HIGHBD_OBMCSADMXN(256, 256)
+HIGHBD_OBMCSADMXN(256, 128)
+HIGHBD_OBMCSADMXN(128, 256)
+#endif  // CONFIG_BLOCK_256
 HIGHBD_OBMCSADMXN(128, 128)
 HIGHBD_OBMCSADMXN(128, 64)
 HIGHBD_OBMCSADMXN(64, 128)
diff --git a/aom_dsp/variance.c b/aom_dsp/variance.c
index e6c6dbd..31b11f9 100644
--- a/aom_dsp/variance.c
+++ b/aom_dsp/variance.c
@@ -437,6 +437,11 @@
   HIGHBD_SUBPIX_VAR(W, H)      \
   HIGHBD_SUBPIX_AVG_VAR(W, H)
 
+#if CONFIG_BLOCK_256
+HIGHBD_VARIANCES(256, 256)
+HIGHBD_VARIANCES(256, 128)
+HIGHBD_VARIANCES(128, 256)
+#endif  // CONFIG_BLOCK_256
 HIGHBD_VARIANCES(128, 128)
 HIGHBD_VARIANCES(128, 64)
 HIGHBD_VARIANCES(64, 128)
@@ -738,6 +743,11 @@
 HIGHBD_MASK_SUBPIX_VAR(64, 128)
 HIGHBD_MASK_SUBPIX_VAR(128, 64)
 HIGHBD_MASK_SUBPIX_VAR(128, 128)
+#if CONFIG_BLOCK_256
+HIGHBD_MASK_SUBPIX_VAR(128, 256)
+HIGHBD_MASK_SUBPIX_VAR(256, 128)
+HIGHBD_MASK_SUBPIX_VAR(256, 256)
+#endif  // CONFIG_BLOCK_256
 HIGHBD_MASK_SUBPIX_VAR(4, 16)
 HIGHBD_MASK_SUBPIX_VAR(16, 4)
 HIGHBD_MASK_SUBPIX_VAR(8, 32)
@@ -922,6 +932,17 @@
 HIGHBD_OBMC_VAR(128, 128)
 HIGHBD_OBMC_SUBPIX_VAR(128, 128)
 
+#if CONFIG_BLOCK_256
+HIGHBD_OBMC_VAR(128, 256)
+HIGHBD_OBMC_SUBPIX_VAR(128, 256)
+
+HIGHBD_OBMC_VAR(256, 128)
+HIGHBD_OBMC_SUBPIX_VAR(256, 128)
+
+HIGHBD_OBMC_VAR(256, 256)
+HIGHBD_OBMC_SUBPIX_VAR(256, 256)
+#endif  // CONFIG_BLOCK_256
+
 HIGHBD_OBMC_VAR(4, 16)
 HIGHBD_OBMC_SUBPIX_VAR(4, 16)
 HIGHBD_OBMC_VAR(16, 4)
diff --git a/aom_dsp/x86/aom_convolve_copy_avx2.c b/aom_dsp/x86/aom_convolve_copy_avx2.c
index d3ac810..d0eee55 100644
--- a/aom_dsp/x86/aom_convolve_copy_avx2.c
+++ b/aom_dsp/x86/aom_convolve_copy_avx2.c
@@ -235,8 +235,7 @@
       dst += dst_stride;
       h -= 2;
     } while (h);
-  } else {
-    assert(w == 128);
+  } else if (w == 128) {
     do {
       highbd_copy_128(src, dst);
       src += src_stride;
@@ -246,5 +245,22 @@
       dst += dst_stride;
       h -= 2;
     } while (h);
+  } else {
+#if CONFIG_BLOCK_256
+    assert(w == 256);
+    do {
+      highbd_copy_128(src, dst);
+      highbd_copy_128(src + 128, dst + 128);
+      src += src_stride;
+      dst += dst_stride;
+      highbd_copy_128(src, dst);
+      highbd_copy_128(src + 128, dst + 128);
+      src += src_stride;
+      dst += dst_stride;
+      h -= 2;
+    } while (h);
+#else
+    assert(0);
+#endif  // CONFIG_BLOCK_256
   }
 }
diff --git a/aom_dsp/x86/aom_convolve_copy_sse2.c b/aom_dsp/x86/aom_convolve_copy_sse2.c
index 9db91c3..ceb80a6 100644
--- a/aom_dsp/x86/aom_convolve_copy_sse2.c
+++ b/aom_dsp/x86/aom_convolve_copy_sse2.c
@@ -292,7 +292,7 @@
       dst += dst_stride;
       h -= 2;
     } while (h);
-  } else {
+  } else if (w == 128) {
     do {
       highbd_copy_128(src, dst);
       src += src_stride;
@@ -302,5 +302,22 @@
       dst += dst_stride;
       h -= 2;
     } while (h);
+  } else {
+#if CONFIG_BLOCK_256
+    assert(w == 256);
+    do {
+      highbd_copy_128(src, dst);
+      highbd_copy_128(src + 128, dst + 128);
+      src += src_stride;
+      dst += dst_stride;
+      highbd_copy_128(src, dst);
+      highbd_copy_128(src + 128, dst + 128);
+      src += src_stride;
+      dst += dst_stride;
+      h -= 2;
+    } while (h);
+#else
+    assert(0);
+#endif  // CONFIG_BLOCK_256
   }
 }
diff --git a/aom_dsp/x86/highbd_subtract_sse2.c b/aom_dsp/x86/highbd_subtract_sse2.c
index fd23d29..073937c 100644
--- a/aom_dsp/x86/highbd_subtract_sse2.c
+++ b/aom_dsp/x86/highbd_subtract_sse2.c
@@ -208,6 +208,11 @@
 SUBTRACT_FUN(64x128) { STACK_V(64, subtract_64x64); }
 SUBTRACT_FUN(128x64) { STACK_H(64, subtract_64x64); }
 SUBTRACT_FUN(128x128) { STACK_V(64, subtract_128x64); }
+#if CONFIG_BLOCK_256
+SUBTRACT_FUN(128x256) { STACK_V(128, subtract_128x128); }
+SUBTRACT_FUN(256x128) { STACK_H(128, subtract_128x128); }
+SUBTRACT_FUN(256x256) { STACK_V(128, subtract_256x128); }
+#endif  // CONFIG_BLOCK_256
 SUBTRACT_FUN(4x16) { STACK_V(8, subtract_4x8); }
 SUBTRACT_FUN(16x4) { STACK_H(8, subtract_8x4); }
 SUBTRACT_FUN(8x32) { STACK_V(16, subtract_8x16); }
@@ -249,7 +254,16 @@
   if (rows == 128) {
     if (cols == 64) return subtract_64x128;
     if (cols == 128) return subtract_128x128;
+#if CONFIG_BLOCK_256
+    if (cols == 256) return subtract_256x128;
+#endif  // CONFIG_BLOCK_256
   }
+#if CONFIG_BLOCK_256
+  if (rows == 256) {
+    if (cols == 128) return subtract_128x256;
+    if (cols == 256) return subtract_256x256;
+  }
+#endif  // CONFIG_BLOCK_256
   assert(0);
   return NULL;
 }
diff --git a/aom_dsp/x86/highbd_variance_avx2.c b/aom_dsp/x86/highbd_variance_avx2.c
index 008eb46..5169097 100644
--- a/aom_dsp/x86/highbd_variance_avx2.c
+++ b/aom_dsp/x86/highbd_variance_avx2.c
@@ -13,6 +13,7 @@
 #include <assert.h>
 #include <immintrin.h>  // AVX2
 
+#include "aom_ports/mem.h"
 #include "config/aom_dsp_rtcd.h"
 #include "aom_dsp/aom_filter.h"
 #include "aom_dsp/x86/synonyms.h"
@@ -758,6 +759,11 @@
     return (var >= 0) ? (uint32_t)var : 0;                                 \
   }
 
+#if CONFIG_BLOCK_256
+VAR_FN(256, 256, 16, 16);
+VAR_FN(256, 128, 16, 15);
+VAR_FN(128, 256, 16, 15);
+#endif  // CONFIG_BLOCK_256
 VAR_FN(128, 128, 16, 14);
 VAR_FN(128, 64, 16, 13);
 VAR_FN(64, 128, 16, 13);
@@ -777,6 +783,11 @@
 VAR_FN(64, 16, 16, 10);
 VAR_FN(8, 16, 8, 7);
 
+#if CONFIG_BLOCK_256
+VAR_FN_BD12(256, 256, 8, 16);
+VAR_FN_BD12(256, 128, 8, 15);
+VAR_FN_BD12(128, 256, 8, 15);
+#endif  // CONFIG_BLOCK_256
 VAR_FN_BD12(128, 128, 8, 14);
 VAR_FN_BD12(128, 64, 8, 13);
 VAR_FN_BD12(64, 128, 8, 13);
@@ -853,6 +864,11 @@
     return (var > 0) ? var : 0;                                               \
   }
 
+#if CONFIG_BLOCK_256
+HIGHBD_SUBPIX_VAR(256, 256, 16);
+HIGHBD_SUBPIX_VAR(256, 128, 15);
+HIGHBD_SUBPIX_VAR(128, 256, 15);
+#endif  // CONFIG_BLOCK_256
 HIGHBD_SUBPIX_VAR(128, 128, 14);
 HIGHBD_SUBPIX_VAR(128, 64, 13);
 HIGHBD_SUBPIX_VAR(64, 128, 13);
@@ -870,6 +886,11 @@
 HIGHBD_SUBPIX_VAR(32, 8, 8);
 HIGHBD_SUBPIX_VAR(16, 4, 6);
 
+#if CONFIG_BLOCK_256
+// HIGHBD_SUBPIX_VAR_BD12(256, 256, 16);
+// HIGHBD_SUBPIX_VAR_BD12(256, 128, 15);
+// HIGHBD_SUBPIX_VAR_BD12(128, 256, 15);
+#endif  // CONFIG_BLOCK_256
 // HIGHBD_SUBPIX_VAR_BD12(128, 128, 14);
 // HIGHBD_SUBPIX_VAR_BD12(128, 64, 13);
 // HIGHBD_SUBPIX_VAR_BD12(64, 128, 13);
diff --git a/aom_dsp/x86/masked_sad_intrin_avx2.c b/aom_dsp/x86/masked_sad_intrin_avx2.c
index 3b7b740..83d2b25 100644
--- a/aom_dsp/x86/masked_sad_intrin_avx2.c
+++ b/aom_dsp/x86/masked_sad_intrin_avx2.c
@@ -376,6 +376,10 @@
 HIGHBD_MASKSADMXN_AVX2(64, 128);
 HIGHBD_MASKSADMXN_AVX2(128, 64);
 HIGHBD_MASKSADMXN_AVX2(128, 128);
+HIGHBD_MASKSADMXN_AVX2(128, 256);
+HIGHBD_MASKSADMXN_AVX2(256, 128);
+HIGHBD_MASKSADMXN_AVX2(256, 256);
+
 HIGHBD_MASKSADMXN_AVX2(4, 16);
 HIGHBD_MASKSADMXN_AVX2(16, 4);
 HIGHBD_MASKSADMXN_AVX2(8, 32);
diff --git a/aom_dsp/x86/masked_variance_intrin_ssse3.c b/aom_dsp/x86/masked_variance_intrin_ssse3.c
index bf4161b..ba4d99b 100644
--- a/aom_dsp/x86/masked_variance_intrin_ssse3.c
+++ b/aom_dsp/x86/masked_variance_intrin_ssse3.c
@@ -671,6 +671,11 @@
     return (var >= 0) ? (uint32_t)var : 0;                                  \
   }
 
+#if CONFIG_BLOCK_256
+HIGHBD_MASK_SUBPIX_VAR_SSSE3(256, 256)
+HIGHBD_MASK_SUBPIX_VAR_SSSE3(256, 128)
+HIGHBD_MASK_SUBPIX_VAR_SSSE3(128, 256)
+#endif  // CONFIG_BLOCK_256X256
 HIGHBD_MASK_SUBPIX_VAR_SSSE3(128, 128)
 HIGHBD_MASK_SUBPIX_VAR_SSSE3(128, 64)
 HIGHBD_MASK_SUBPIX_VAR_SSSE3(64, 128)
diff --git a/aom_dsp/x86/obmc_sad_avx2.c b/aom_dsp/x86/obmc_sad_avx2.c
index 3fc14fc..b657e2f 100644
--- a/aom_dsp/x86/obmc_sad_avx2.c
+++ b/aom_dsp/x86/obmc_sad_avx2.c
@@ -123,6 +123,9 @@
     }                                                                  \
   }
 
+HBD_OBMCSADWXH(256, 256)
+HBD_OBMCSADWXH(256, 128)
+HBD_OBMCSADWXH(128, 256)
 HBD_OBMCSADWXH(128, 128)
 HBD_OBMCSADWXH(128, 64)
 HBD_OBMCSADWXH(64, 128)
diff --git a/aom_dsp/x86/obmc_variance_sse4.c b/aom_dsp/x86/obmc_variance_sse4.c
index 750bf15..f354881 100644
--- a/aom_dsp/x86/obmc_variance_sse4.c
+++ b/aom_dsp/x86/obmc_variance_sse4.c
@@ -213,6 +213,11 @@
     return (var >= 0) ? (uint32_t)var : 0;                                 \
   }
 
+#if CONFIG_BLOCK_256
+HBD_OBMCVARWXH(256, 256)
+HBD_OBMCVARWXH(256, 128)
+HBD_OBMCVARWXH(128, 256)
+#endif  // CONFIG_BLOCK_256
 HBD_OBMCVARWXH(128, 128)
 HBD_OBMCVARWXH(128, 64)
 HBD_OBMCVARWXH(64, 128)
diff --git a/aom_dsp/x86/sad_highbd_avx2.c b/aom_dsp/x86/sad_highbd_avx2.c
index de2b3ab..bae6691 100644
--- a/aom_dsp/x86/sad_highbd_avx2.c
+++ b/aom_dsp/x86/sad_highbd_avx2.c
@@ -199,37 +199,41 @@
   return get_sad_from_mm256_epi32(&sad);
 }
 
-static AOM_FORCE_INLINE void sad128x1(const uint16_t *src_ptr,
-                                      const uint16_t *ref_ptr,
-                                      const uint16_t *sec_ptr,
-                                      __m256i *sad_acc) {
-  __m256i s[4], r[4];
-  int i;
-  for (i = 0; i < 2; i++) {
-    s[0] = _mm256_loadu_si256((const __m256i *)src_ptr);
-    s[1] = _mm256_loadu_si256((const __m256i *)(src_ptr + 16));
-    s[2] = _mm256_loadu_si256((const __m256i *)(src_ptr + 32));
-    s[3] = _mm256_loadu_si256((const __m256i *)(src_ptr + 48));
-    r[0] = _mm256_loadu_si256((const __m256i *)ref_ptr);
-    r[1] = _mm256_loadu_si256((const __m256i *)(ref_ptr + 16));
-    r[2] = _mm256_loadu_si256((const __m256i *)(ref_ptr + 32));
-    r[3] = _mm256_loadu_si256((const __m256i *)(ref_ptr + 48));
-    if (sec_ptr) {
-      r[0] =
-          _mm256_avg_epu16(r[0], _mm256_loadu_si256((const __m256i *)sec_ptr));
-      r[1] = _mm256_avg_epu16(
-          r[1], _mm256_loadu_si256((const __m256i *)(sec_ptr + 16)));
-      r[2] = _mm256_avg_epu16(
-          r[2], _mm256_loadu_si256((const __m256i *)(sec_ptr + 32)));
-      r[3] = _mm256_avg_epu16(
-          r[3], _mm256_loadu_si256((const __m256i *)(sec_ptr + 48)));
-      sec_ptr += 64;
-    }
-    highbd_sad16x4_core_avx2(s, r, sad_acc);
-    src_ptr += 64;
-    ref_ptr += 64;
+#define MAKE_SAD_WX1(w)                                                        \
+  static AOM_FORCE_INLINE void sad##w##x1(                                     \
+      const uint16_t *src_ptr, const uint16_t *ref_ptr,                        \
+      const uint16_t *sec_ptr, __m256i *sad_acc) {                             \
+    assert(w % 64 == 0);                                                       \
+    __m256i s[4], r[4];                                                        \
+    int i;                                                                     \
+    for (i = 0; i < w / 64; i++) {                                             \
+      s[0] = _mm256_loadu_si256((const __m256i *)src_ptr);                     \
+      s[1] = _mm256_loadu_si256((const __m256i *)(src_ptr + 16));              \
+      s[2] = _mm256_loadu_si256((const __m256i *)(src_ptr + 32));              \
+      s[3] = _mm256_loadu_si256((const __m256i *)(src_ptr + 48));              \
+      r[0] = _mm256_loadu_si256((const __m256i *)ref_ptr);                     \
+      r[1] = _mm256_loadu_si256((const __m256i *)(ref_ptr + 16));              \
+      r[2] = _mm256_loadu_si256((const __m256i *)(ref_ptr + 32));              \
+      r[3] = _mm256_loadu_si256((const __m256i *)(ref_ptr + 48));              \
+      if (sec_ptr) {                                                           \
+        r[0] = _mm256_avg_epu16(r[0],                                          \
+                                _mm256_loadu_si256((const __m256i *)sec_ptr)); \
+        r[1] = _mm256_avg_epu16(                                               \
+            r[1], _mm256_loadu_si256((const __m256i *)(sec_ptr + 16)));        \
+        r[2] = _mm256_avg_epu16(                                               \
+            r[2], _mm256_loadu_si256((const __m256i *)(sec_ptr + 32)));        \
+        r[3] = _mm256_avg_epu16(                                               \
+            r[3], _mm256_loadu_si256((const __m256i *)(sec_ptr + 48)));        \
+        sec_ptr += 64;                                                         \
+      }                                                                        \
+      highbd_sad16x4_core_avx2(s, r, sad_acc);                                 \
+      src_ptr += 64;                                                           \
+      ref_ptr += 64;                                                           \
+    }                                                                          \
   }
-}
+
+MAKE_SAD_WX1(128);
+MAKE_SAD_WX1(256);
 
 static AOM_FORCE_INLINE unsigned int aom_highbd_sad128xN_avx2(
     int N, const uint16_t *src, int src_stride, const uint16_t *ref,
@@ -245,6 +249,20 @@
   return get_sad_from_mm256_epi32(&sad);
 }
 
+static AOM_FORCE_INLINE unsigned int aom_highbd_sad256xN_avx2(
+    int N, const uint16_t *src, int src_stride, const uint16_t *ref,
+    int ref_stride) {
+  __m256i sad = _mm256_setzero_si256();
+  int row = 0;
+  while (row < N) {
+    sad256x1(src, ref, NULL, &sad);
+    src += src_stride;
+    ref += ref_stride;
+    row++;
+  }
+  return get_sad_from_mm256_epi32(&sad);
+}
+
 #define highbd_sadMxN_avx2(m, n)                                            \
   unsigned int aom_highbd_sad##m##x##n##_avx2(                              \
       const uint16_t *src, int src_stride, const uint16_t *ref,             \
@@ -278,6 +296,10 @@
 
 highbd_sadMxN_avx2(128, 64);
 highbd_sadMxN_avx2(128, 128);
+highbd_sadMxN_avx2(128, 256);
+
+highbd_sadMxN_avx2(256, 128);
+highbd_sadMxN_avx2(256, 256);
 
 highbd_sad_skip_MxN_avx2(16, 8);
 highbd_sad_skip_MxN_avx2(16, 16);
@@ -296,6 +318,10 @@
 
 highbd_sad_skip_MxN_avx2(128, 64);
 highbd_sad_skip_MxN_avx2(128, 128);
+highbd_sad_skip_MxN_avx2(128, 256);
+
+highbd_sad_skip_MxN_avx2(256, 128);
+highbd_sad_skip_MxN_avx2(256, 256);
 
 unsigned int aom_highbd_sad16x4_avg_avx2(const uint16_t *src, int src_stride,
                                          const uint16_t *ref, int ref_stride,
@@ -518,6 +544,53 @@
   return sum;
 }
 
+unsigned int aom_highbd_sad128x256_avg_avx2(const uint16_t *src, int src_stride,
+                                            const uint16_t *ref, int ref_stride,
+                                            const uint16_t *second_pred) {
+  unsigned int sum;
+  const int left_shift = 7;
+
+  sum = aom_highbd_sad128x128_avg_avx2(src, src_stride, ref, ref_stride,
+                                       second_pred);
+  src += src_stride << left_shift;
+  ref += ref_stride << left_shift;
+  second_pred += 128 << left_shift;
+  sum += aom_highbd_sad128x128_avg_avx2(src, src_stride, ref, ref_stride,
+                                        second_pred);
+  return sum;
+}
+
+unsigned int aom_highbd_sad256x128_avg_avx2(const uint16_t *src, int src_stride,
+                                            const uint16_t *ref, int ref_stride,
+                                            const uint16_t *second_pred) {
+  __m256i sad = _mm256_setzero_si256();
+  int row = 0;
+  while (row < 128) {
+    sad256x1(src, ref, second_pred, &sad);
+    src += src_stride;
+    ref += ref_stride;
+    second_pred += 256;
+    row += 1;
+  }
+  return get_sad_from_mm256_epi32(&sad);
+}
+
+unsigned int aom_highbd_sad256x256_avg_avx2(const uint16_t *src, int src_stride,
+                                            const uint16_t *ref, int ref_stride,
+                                            const uint16_t *second_pred) {
+  unsigned int sum;
+  const int left_shift = 7;
+
+  sum = aom_highbd_sad256x128_avg_avx2(src, src_stride, ref, ref_stride,
+                                       second_pred);
+  src += src_stride << left_shift;
+  ref += ref_stride << left_shift;
+  second_pred += 256 << left_shift;
+  sum += aom_highbd_sad256x128_avg_avx2(src, src_stride, ref, ref_stride,
+                                        second_pred);
+  return sum;
+}
+
 // SAD 4D
 // Combine 4 __m256i input vectors  v to uint32_t result[4]
 static AOM_FORCE_INLINE void get_4d_sad_from_mm256_epi32(const __m256i *v,
@@ -653,6 +726,27 @@
   get_4d_sad_from_mm256_epi32(sad_vec, sad_array);
 }
 
+static AOM_FORCE_INLINE void aom_highbd_sad256xNx4d_avx2(
+    int N, const uint16_t *src, int src_stride,
+    const uint16_t *const ref_array[], int ref_stride, uint32_t *sad_array) {
+  __m256i sad_vec[4];
+  int i, r;
+
+  init_sad(sad_vec);
+
+  for (i = 0; i < 4; ++i) {
+    const uint16_t *srcp = src;
+    const uint16_t *refp = ref_array[i];
+
+    for (r = 0; r < N; r++) {
+      sad256x1(srcp, refp, NULL, &sad_vec[i]);
+      srcp += src_stride;
+      refp += ref_stride;
+    }
+  }
+  get_4d_sad_from_mm256_epi32(sad_vec, sad_array);
+}
+
 #define highbd_sadMxNx4d_avx2(m, n)                                           \
   void aom_highbd_sad##m##x##n##x4d_avx2(                                     \
       const uint16_t *src, int src_stride, const uint16_t *const ref_array[], \
@@ -690,6 +784,10 @@
 
 highbd_sadMxNx4d_avx2(128, 64);
 highbd_sadMxNx4d_avx2(128, 128);
+highbd_sadMxNx4d_avx2(128, 256);
+
+highbd_sadMxNx4d_avx2(256, 128);
+highbd_sadMxNx4d_avx2(256, 256);
 
 highbd_sad_skip_MxNx4d_avx2(16, 8);
 highbd_sad_skip_MxNx4d_avx2(16, 16);
@@ -708,3 +806,7 @@
 
 highbd_sad_skip_MxNx4d_avx2(128, 64);
 highbd_sad_skip_MxNx4d_avx2(128, 128);
+highbd_sad_skip_MxNx4d_avx2(128, 256);
+
+highbd_sad_skip_MxNx4d_avx2(256, 128);
+highbd_sad_skip_MxNx4d_avx2(256, 256);
diff --git a/aom_scale/yv12config.h b/aom_scale/yv12config.h
index 405efb1..213f346 100644
--- a/aom_scale/yv12config.h
+++ b/aom_scale/yv12config.h
@@ -26,11 +26,21 @@
 
 /*!\cond */
 
-#define AOMINNERBORDERINPIXELS 160
 #define AOM_INTERP_EXTEND 4
-#define AOM_BORDER_IN_PIXELS 288
-#define AOM_ENC_NO_SCALE_BORDER 160
+#if CONFIG_BLOCK_256
+#define AOMINNERBORDERINPIXELS \
+  ALIGN_POWER_OF_TWO(256 + 2 * AOM_INTERP_EXTEND, 5)
+#define AOM_BORDER_IN_PIXELS \
+  ALIGN_POWER_OF_TWO(2 * 256 + 2 * AOM_INTERP_EXTEND, 5)
+#define AOM_ENC_NO_SCALE_BORDER \
+  ALIGN_POWER_OF_TWO(256 + 2 * AOM_INTERP_EXTEND, 5)
+#define AOM_DEC_BORDER_IN_PIXELS (256 >> 1)
+#else
+#define AOMINNERBORDERINPIXELS (128 + 32)
+#define AOM_BORDER_IN_PIXELS (2 * 128 + 32)
+#define AOM_ENC_NO_SCALE_BORDER (128 + 32)
 #define AOM_DEC_BORDER_IN_PIXELS 64
+#endif  // CONFIG_BLOCK_256
 
 /*!\endcond */
 /*!
diff --git a/apps/aomenc.c b/apps/aomenc.c
index 03cb907..08eeb9c 100644
--- a/apps/aomenc.c
+++ b/apps/aomenc.c
@@ -633,8 +633,13 @@
   /* These parameters are set in the function parseCfg.
      In absence of these parameters in the config file,
      the default values should match  */
+#if CONFIG_BLOCK_256
+  config->superblock_size = 256;
+  config->max_partition_size = 256;
+#else
   config->superblock_size = 128;
   config->max_partition_size = 128;
+#endif  // CONFIG_BLOCK_256
   config->min_partition_size = 4;
   config->enable_ab_partitions = 1;
   config->enable_rect_partitions = 1;
diff --git a/av1/arg_defs.c b/av1/arg_defs.c
index 21e8cc9..d866237 100644
--- a/av1/arg_defs.c
+++ b/av1/arg_defs.c
@@ -479,10 +479,17 @@
               "(4:4x4, 8:8x8, 16:16x16, 32:32x32, 64:64x64, 128:128x128). "
               "On frame with 4k+ resolutions or higher speed settings, the min "
               "partition size will have a minimum of 8."),
+#if CONFIG_BLOCK_256
+  .max_partition_size = ARG_DEF(
+      NULL, "max-partition-size", 1,
+      "Set max partition size "
+      "(4:4x4, 8:8x8, 16:16x16, 32:32x32, 64:64x64, 128:128x128, 256:256x256)"),
+#else
   .max_partition_size =
       ARG_DEF(NULL, "max-partition-size", 1,
               "Set max partition size "
               "(4:4x4, 8:8x8, 16:16x16, 32:32x32, 64:64x64, 128:128x128)"),
+#endif  // CONFIG_BLOCK_256
   .enable_chroma_deltaq = ARG_DEF(NULL, "enable-chroma-deltaq", 1,
                                   "Enable chroma delta quant "
                                   "(0: false (default), 1: true)"),
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 7c47bdd..69a3309 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -517,7 +517,11 @@
   1,    // enable refineMV mode
 #endif  // CONFIG_REFINEMV
   4,    // min_partition_size
-  128,  // max_partition_size
+#if CONFIG_BLOCK_256
+  256,  // max_partition_size
+#else
+  128,                      // max_partition_size
+#endif  // CONFIG_BLOCK_256
   1,    // enable intra edge filter
   1,    // frame order hint
   1,    // enable 64-pt transform usage
@@ -871,6 +875,15 @@
   RANGE_CHECK(extra_cfg, mode_cost_upd_freq, 0, 2);
   RANGE_CHECK(extra_cfg, mv_cost_upd_freq, 0, 3);
 
+#if CONFIG_BLOCK_256
+  RANGE_CHECK(extra_cfg, min_partition_size, 4, 256);
+  // when sdp is enabled, the maximum partition size must be equal to or greater
+  // than 8x8
+  if (extra_cfg->enable_sdp)
+    RANGE_CHECK(extra_cfg, max_partition_size, 8, 256);
+  else
+    RANGE_CHECK(extra_cfg, max_partition_size, 4, 256);
+#else
   RANGE_CHECK(extra_cfg, min_partition_size, 4, 128);
   // when sdp is enabled, the maximum partition size must be equal to or greater
   // than 8x8
@@ -878,6 +891,7 @@
     RANGE_CHECK(extra_cfg, max_partition_size, 8, 128);
   else
     RANGE_CHECK(extra_cfg, max_partition_size, 4, 128);
+#endif  // CONFIG_BLOCK_256
   RANGE_CHECK_HI(extra_cfg, min_partition_size, extra_cfg->max_partition_size);
 
   for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i) {
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index 8bfa9e1..24ed3b6 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -1208,7 +1208,7 @@
       FrameWorkerData *const frame_worker_data =
           (FrameWorkerData *)worker->data1;
       const AV1Decoder *pbi = frame_worker_data->pbi;
-      if (pbi->common.seq_params.sb_size == BLOCK_128X128) {
+      if (pbi->common.sb_size == BLOCK_128X128) {
         *sb_size = AOM_SUPERBLOCK_SIZE_128X128;
       } else {
         *sb_size = AOM_SUPERBLOCK_SIZE_64X64;
diff --git a/av1/common/alloccommon.c b/av1/common/alloccommon.c
index 608cd7e..2875d0b 100644
--- a/av1/common/alloccommon.c
+++ b/av1/common/alloccommon.c
@@ -291,7 +291,7 @@
 
 static void set_sb_si(AV1_COMMON *cm) {
   CommonSBInfoParams *const sbi_params = &cm->sbi_params;
-  const int mib_size_log2 = cm->seq_params.mib_size_log2;
+  const int mib_size_log2 = cm->mib_size_log2;
   sbi_params->sb_cols =
       ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, mib_size_log2) >> mib_size_log2;
   sbi_params->sb_rows =
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h
index 39b96a2..8d63f8c 100644
--- a/av1/common/av1_common_int.h
+++ b/av1/common/av1_common_int.h
@@ -1777,6 +1777,18 @@
   int16_t *gy1;
 #endif  // CONFIG_OPTFLOW_ON_TIP
 #endif  // CONFIG_TIP
+  /*!
+   * Size of the superblock used for this frame.
+   */
+  BLOCK_SIZE sb_size;
+  /*!
+   * Size of the superblock used for this frame in units of MI.
+   */
+  int mib_size;
+  /*!
+   * Log2 of the size of the superblock in units of MI.
+   */
+  int mib_size_log2;
 
 #if CONFIG_INSPECTION
   YV12_BUFFER_CONFIG predicted_pixels;
@@ -2411,7 +2423,11 @@
   out[0] -= cdf_element_prob(in, PARTITION_HORZ_A);
   out[0] -= cdf_element_prob(in, PARTITION_HORZ_B);
   out[0] -= cdf_element_prob(in, PARTITION_VERT_A);
+#if CONFIG_BLOCK_256
+  if (bsize < BLOCK_128X128) out[0] -= cdf_element_prob(in, PARTITION_HORZ_4);
+#else
   if (bsize != BLOCK_128X128) out[0] -= cdf_element_prob(in, PARTITION_HORZ_4);
+#endif  // CONFIG_BLOCK_256
   out[0] = AOM_ICDF(out[0]);
   out[1] = AOM_ICDF(CDF_PROB_TOP);
 }
@@ -2426,7 +2442,11 @@
   out[0] -= cdf_element_prob(in, PARTITION_HORZ_A);
   out[0] -= cdf_element_prob(in, PARTITION_VERT_A);
   out[0] -= cdf_element_prob(in, PARTITION_VERT_B);
+#if CONFIG_BLOCK_256
+  if (bsize < BLOCK_128X128) out[0] -= cdf_element_prob(in, PARTITION_VERT_4);
+#else
   if (bsize != BLOCK_128X128) out[0] -= cdf_element_prob(in, PARTITION_VERT_4);
+#endif  // CONFIG_BLOCK_256
   out[0] = AOM_ICDF(out[0]);
   out[1] = AOM_ICDF(CDF_PROB_TOP);
 }
@@ -2480,6 +2500,26 @@
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 }
 
+#if CONFIG_BLOCK_256
+/*!\brief Returns the context used by \ref PARTITION_SPLIT. */
+static INLINE int square_split_context(const MACROBLOCKD *xd, int mi_row,
+                                       int mi_col, BLOCK_SIZE bsize) {
+  const int plane = xd->tree_type == CHROMA_PART;
+  const PARTITION_CONTEXT *above_ctx =
+      xd->above_partition_context[plane] + mi_col;
+  const PARTITION_CONTEXT *left_ctx =
+      xd->left_partition_context[plane] + (mi_row & MAX_MIB_MASK);
+  assert(bsize < BLOCK_SIZES);
+  const int bsl_w = mi_size_wide_log2[bsize];
+  const int bsl_h = mi_size_high_log2[bsize];
+
+  const int above = (*above_ctx >> AOMMAX(bsl_w - 1, 0)) & 1;
+  const int left = (*left_ctx >> AOMMAX(bsl_h - 1, 0)) & 1;
+
+  return (left * 2 + above) + (bsize == BLOCK_256X256) * PARTITION_PLOFFSET;
+}
+#endif  // CONFIG_BLOCK_256
+
 static INLINE int partition_plane_context(const MACROBLOCKD *xd, int mi_row,
                                           int mi_col, BLOCK_SIZE bsize) {
   const int plane = xd->tree_type == CHROMA_PART;
@@ -2512,10 +2552,14 @@
 // Return the number of elements in the partition CDF when
 // partitioning the (square) block with luma block size of bsize.
 static INLINE int partition_cdf_length(BLOCK_SIZE bsize) {
-  if (bsize <= BLOCK_8X8)
-    return PARTITION_TYPES;
+  if (bsize <= BLOCK_8X8) return PARTITION_TYPES;
+#if CONFIG_BLOCK_256
+  else if (bsize >= BLOCK_128X128)
+    return EXT_PARTITION_TYPES - 2;
+#else
   else if (bsize == BLOCK_128X128)
     return EXT_PARTITION_TYPES - 2;
+#endif  // CONFIG_BLOCK_256
   else
     return EXT_PARTITION_TYPES;
 }
@@ -2528,8 +2572,7 @@
   const SequenceHeader *const seq_params = &cm->seq_params;
   const int num_planes = av1_num_planes(cm);
   const int width = mi_col_end - mi_col_start;
-  const int aligned_width =
-      ALIGN_POWER_OF_TWO(width, seq_params->mib_size_log2);
+  const int aligned_width = ALIGN_POWER_OF_TWO(width, cm->mib_size_log2);
   const int offset_y = mi_col_start;
   const int width_y = aligned_width;
   const int offset_uv = offset_y >> seq_params->subsampling_x;
@@ -2593,15 +2636,15 @@
 #endif
 
 #if !CONFIG_TX_PARTITION_CTX
-static INLINE void set_txfm_ctx(TXFM_CONTEXT *txfm_ctx, uint8_t txs, int len) {
+static INLINE void set_txfm_ctx(TXFM_CONTEXT *txfm_ctx, uint16_t txs, int len) {
   int i;
   for (i = 0; i < len; ++i) txfm_ctx[i] = txs;
 }
 
 static INLINE void set_txfm_ctxs(TX_SIZE tx_size, int n4_w, int n4_h, int skip,
                                  const MACROBLOCKD *xd) {
-  uint8_t bw = tx_size_wide[tx_size];
-  uint8_t bh = tx_size_high[tx_size];
+  uint16_t bw = tx_size_wide[tx_size];
+  uint16_t bh = tx_size_high[tx_size];
 
   if (skip) {
     bw = n4_w * MI_SIZE;
@@ -2694,7 +2737,11 @@
 // Currently this is set to BLOCK_128X128 (e.g. chroma always follows luma at
 // BLOCK_128X128, but can be de-coupled later).
 static AOM_INLINE bool is_bsize_above_decoupled_thresh(BLOCK_SIZE bsize) {
+#if CONFIG_BLOCK_256
+  return bsize >= BLOCK_128X128 && bsize <= BLOCK_256X256;
+#else
   return bsize == BLOCK_128X128;
+#endif  // CONFIG_BLOCK_256
 }
 
 // Whether the partition tree contains a block size that is strictly smaller
@@ -2777,7 +2824,7 @@
 }
 
 // Returns true if partition is implied for blocks near bottom/right
-// border, and not signaled in the bistream. And when it returns true, it also
+// border, and not signaled in the bitstream. And when it returns true, it also
 // sets `implied_partition` appropriately.
 // Note: `implied_partition` can be passed NULL.
 static AOM_INLINE bool is_partition_implied_at_boundary(
@@ -2859,6 +2906,43 @@
   return is_implied;
 }
 
+/*!\brief Returns the partition type forced by the bitstream constraint.
+ *
+ * \return A \ref PARTITION_TYPE that corresponds to the one forced by the
+ * bitstream. If no partition type is forced, returns \ref PARTITION_INVALID.
+ */
+static AOM_INLINE PARTITION_TYPE av1_get_normative_forced_partition_type(
+    const CommonModeInfoParams *const mi_params, TREE_TYPE tree_type, int ss_x,
+    int ss_y, int mi_row, int mi_col, BLOCK_SIZE bsize,
+    const PARTITION_TREE *ptree_luma, const CHROMA_REF_INFO *chroma_ref_info) {
+  // Return NONE if this block size is not splittable
+  if (!is_partition_point(bsize)) {
+    return PARTITION_NONE;
+  }
+
+  // Special case where 8x8 chroma blocks are not splittable.
+  // TODO(chiyotsai@google.com): This should be moved into `is_partition_point`,
+  // but this will require too many lines of change to do right now.
+  if (tree_type == CHROMA_PART && bsize == BLOCK_8X8) {
+    return PARTITION_NONE;
+  }
+
+  // Partitions forced by SDP
+  if (is_luma_chroma_share_same_partition(tree_type, ptree_luma, bsize)) {
+    assert(ptree_luma);
+    return sdp_chroma_part_from_luma(bsize, ptree_luma->partition, ss_x, ss_y);
+  }
+
+  // Partitions forced by boundary
+  PARTITION_TYPE implied_partition;
+  const bool is_part_implied = is_partition_implied_at_boundary(
+      mi_params, tree_type, ss_x, ss_y, mi_row, mi_col, bsize, chroma_ref_info,
+      &implied_partition);
+  if (is_part_implied) return implied_partition;
+
+  // No forced partitions
+  return PARTITION_INVALID;
+}
 #else
 // Return the number of sub-blocks whose width and height are
 // less than half of the parent block.
@@ -2913,6 +2997,9 @@
 
 static INLINE TX_SIZE get_sqr_tx_size(int tx_dim) {
   switch (tx_dim) {
+#if CONFIG_BLOCK_256
+    case 256:
+#endif  // CONFIG_BLOCK_256
     case 128:
     case 64: return TX_64X64; break;
     case 32: return TX_32X32; break;
@@ -3226,11 +3313,27 @@
   return base_partitions[split_idx];
 }
 
-static INLINE void set_sb_size(SequenceHeader *const seq_params,
-                               BLOCK_SIZE sb_size) {
+static AOM_INLINE void av1_set_frame_sb_size(AV1_COMMON *cm,
+                                             BLOCK_SIZE sb_size) {
+#if CONFIG_BLOCK_256
+  // BLOCK_256X256 gives no benefits in all intra encoding, so downsize the
+  // superblock size to 128x128 on key frames.
+  if (frame_is_intra_only(cm) && sb_size == BLOCK_256X256) {
+    sb_size = BLOCK_128X128;
+  }
+#endif  // CONFIG_BLOCK_256
+  cm->sb_size = sb_size;
+  cm->mib_size = mi_size_wide[sb_size];
+  cm->mib_size_log2 = mi_size_wide_log2[sb_size];
+}
+
+static INLINE void set_sb_size(AV1_COMMON *cm, BLOCK_SIZE sb_size) {
+  SequenceHeader *const seq_params = &cm->seq_params;
   seq_params->sb_size = sb_size;
-  seq_params->mib_size = mi_size_wide[seq_params->sb_size];
-  seq_params->mib_size_log2 = mi_size_wide_log2[seq_params->sb_size];
+  seq_params->mib_size = mi_size_wide[sb_size];
+  seq_params->mib_size_log2 = mi_size_wide_log2[sb_size];
+
+  av1_set_frame_sb_size(cm, sb_size);
 }
 
 #if CONFIG_LR_FLEX_SYNTAX
@@ -3272,8 +3375,8 @@
 
 static INLINE SB_INFO *av1_get_sb_info(const AV1_COMMON *cm, int mi_row,
                                        int mi_col) {
-  const int sb_row = mi_row >> cm->seq_params.mib_size_log2;
-  const int sb_col = mi_col >> cm->seq_params.mib_size_log2;
+  const int sb_row = mi_row >> cm->mib_size_log2;
+  const int sb_col = mi_col >> cm->mib_size_log2;
   return cm->sbi_params.sbi_grid_base + sb_row * cm->sbi_params.sbi_stride +
          sb_col;
 }
@@ -3506,7 +3609,7 @@
   const int dy = second_dr_intra_derivative[angle];
 #endif  // CONFIG_EXT_DIR
   weights[block_idx][mode_idx] =
-      (uint8_t *)(aom_calloc(txw * txh, sizeof(uint8_t)));
+      (uint8_t *)(aom_malloc(txw * txh * sizeof(uint8_t)));
   av1_dr_prediction_z1_info(weights[block_idx][mode_idx], txw, txh, txw_log2,
                             txh_log2, dy, mode);
   return;
diff --git a/av1/common/av1_loopfilter.c b/av1/common/av1_loopfilter.c
index 4e2b038..23b5073 100644
--- a/av1/common/av1_loopfilter.c
+++ b/av1/common/av1_loopfilter.c
@@ -449,8 +449,7 @@
           // deblock the edge if the edge belongs to a PU's edge only.
 #if DF_REDUCED_SB_EDGE
           const BLOCK_SIZE superblock_size = get_plane_block_size(
-              cm->seq_params.sb_size, plane_ptr->subsampling_x,
-              plane_ptr->subsampling_y);
+              cm->sb_size, plane_ptr->subsampling_x, plane_ptr->subsampling_y);
           const int vert_sb_mask = block_size_high[superblock_size] - 1;
           int horz_superblock_edge =
               (HORZ_EDGE == edge_dir) && !(coord & vert_sb_mask);
@@ -608,12 +607,13 @@
                                  const MACROBLOCKD_PLANE *const plane_ptr,
                                  const uint32_t mi_row, const uint32_t mi_col) {
   if (!plane && !cm->lf.filter_level[0]) return;
+  const int mib_size = cm->mib_size;
   const uint32_t scale_horz = plane_ptr->subsampling_x;
   const uint32_t scale_vert = plane_ptr->subsampling_y;
   uint16_t *const dst_ptr = plane_ptr->dst.buf;
   const int dst_stride = plane_ptr->dst.stride;
-  const int y_range = (MAX_MIB_SIZE >> scale_vert);
-  const int x_range = (MAX_MIB_SIZE >> scale_horz);
+  const int y_range = (mib_size >> scale_vert);
+  const int x_range = (mib_size >> scale_horz);
   for (int y = 0; y < y_range; y++) {
     uint16_t *p = dst_ptr + y * MI_SIZE * dst_stride;
     for (int x = 0; x < x_range;) {
@@ -656,12 +656,13 @@
                                  const MACROBLOCKD_PLANE *const plane_ptr,
                                  const uint32_t mi_row, const uint32_t mi_col) {
   if (!plane && !cm->lf.filter_level[1]) return;
+  const int mib_size = cm->mib_size;
   const uint32_t scale_horz = plane_ptr->subsampling_x;
   const uint32_t scale_vert = plane_ptr->subsampling_y;
   uint16_t *const dst_ptr = plane_ptr->dst.buf;
   const int dst_stride = plane_ptr->dst.stride;
-  const int y_range = (MAX_MIB_SIZE >> scale_vert);
-  const int x_range = (MAX_MIB_SIZE >> scale_horz);
+  const int y_range = (mib_size >> scale_vert);
+  const int x_range = (mib_size >> scale_horz);
   for (int x = 0; x < x_range; x++) {
     uint16_t *p = dst_ptr + x * MI_SIZE;
     for (int y = 0; y < y_range;) {
@@ -828,6 +829,7 @@
   }
 #endif
 
+  const int mib_size = cm->mib_size;
   for (plane = plane_start; plane < plane_end; plane++) {
     if (plane == 0 && !(cm->lf.filter_level[0]) && !(cm->lf.filter_level[1]))
       break;
@@ -837,32 +839,32 @@
       continue;
 
     if (cm->lf.combine_vert_horz_lf) {
-      // filter all vertical and horizontal edges in every 128x128 super block
-      for (mi_row = start; mi_row < stop; mi_row += MAX_MIB_SIZE) {
-        for (mi_col = col_start; mi_col < col_end; mi_col += MAX_MIB_SIZE) {
+      // filter all vertical and horizontal edges in every super block
+      for (mi_row = start; mi_row < stop; mi_row += mib_size) {
+        for (mi_col = col_start; mi_col < col_end; mi_col += mib_size) {
           // filter vertical edges
           av1_setup_dst_planes(pd, frame_buffer, mi_row, mi_col, plane,
                                plane + 1, NULL);
           av1_filter_block_plane_vert(cm, xd, plane, &pd[plane], mi_row,
                                       mi_col);
           // filter horizontal edges
-          if (mi_col - MAX_MIB_SIZE >= 0) {
-            av1_setup_dst_planes(pd, frame_buffer, mi_row,
-                                 mi_col - MAX_MIB_SIZE, plane, plane + 1, NULL);
+          if (mi_col - mib_size >= 0) {
+            av1_setup_dst_planes(pd, frame_buffer, mi_row, mi_col - mib_size,
+                                 plane, plane + 1, NULL);
             av1_filter_block_plane_horz(cm, xd, plane, &pd[plane], mi_row,
-                                        mi_col - MAX_MIB_SIZE);
+                                        mi_col - mib_size);
           }
         }
         // filter horizontal edges
-        av1_setup_dst_planes(pd, frame_buffer, mi_row, mi_col - MAX_MIB_SIZE,
-                             plane, plane + 1, NULL);
+        av1_setup_dst_planes(pd, frame_buffer, mi_row, mi_col - mib_size, plane,
+                             plane + 1, NULL);
         av1_filter_block_plane_horz(cm, xd, plane, &pd[plane], mi_row,
-                                    mi_col - MAX_MIB_SIZE);
+                                    mi_col - mib_size);
       }
     } else {
       // filter all vertical edges in every 128x128 super block
-      for (mi_row = start; mi_row < stop; mi_row += MAX_MIB_SIZE) {
-        for (mi_col = col_start; mi_col < col_end; mi_col += MAX_MIB_SIZE) {
+      for (mi_row = start; mi_row < stop; mi_row += mib_size) {
+        for (mi_col = col_start; mi_col < col_end; mi_col += mib_size) {
           av1_setup_dst_planes(pd, frame_buffer, mi_row, mi_col, plane,
                                plane + 1, NULL);
           av1_filter_block_plane_vert(cm, xd, plane, &pd[plane], mi_row,
@@ -871,8 +873,8 @@
       }
 
       // filter all horizontal edges in every 128x128 super block
-      for (mi_row = start; mi_row < stop; mi_row += MAX_MIB_SIZE) {
-        for (mi_col = col_start; mi_col < col_end; mi_col += MAX_MIB_SIZE) {
+      for (mi_row = start; mi_row < stop; mi_row += mib_size) {
+        for (mi_col = col_start; mi_col < col_end; mi_col += mib_size) {
           av1_setup_dst_planes(pd, frame_buffer, mi_row, mi_col, plane,
                                plane + 1, NULL);
           av1_filter_block_plane_horz(cm, xd, plane, &pd[plane], mi_row,
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 9be9d0e..1e1a75f 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -432,7 +432,11 @@
   BLOCK_SIZE bsize_base;
 } CHROMA_REF_INFO;
 
+#if CONFIG_BLOCK_256
+#define INTER_TX_SIZE_BUF_LEN 64
+#else
 #define INTER_TX_SIZE_BUF_LEN 16
+#endif  // CONFIG_BLOCK_256
 #define TXK_TYPE_BUF_LEN 64
 /*!\endcond */
 
@@ -887,6 +891,19 @@
   return RECT_INVALID;
 }
 
+/*!\brief Returns whether square split is allowed for current bsize. */
+static AOM_INLINE bool is_square_split_eligible(BLOCK_SIZE bsize,
+                                                BLOCK_SIZE sb_size) {
+#if CONFIG_BLOCK_256
+  (void)sb_size;
+  return bsize == BLOCK_128X128 || bsize == BLOCK_256X256;
+#else
+  (void)bsize;
+  (void)sb_size;
+  return false;
+#endif  // CONFIG_BLOCK_256
+}
+
 /*!\brief Returns whether the current partition is horizontal type or vertical
  * type. */
 static AOM_INLINE RECT_PART_TYPE get_rect_part_type(PARTITION_TYPE partition) {
@@ -958,6 +975,9 @@
     case BLOCK_32X32: return 3;
     case BLOCK_64X64: return 4;
     case BLOCK_128X128: return 5;
+#if CONFIG_BLOCK_256
+    case BLOCK_256X256: return 6;
+#endif  // CONFIG_BLOCK_256
     default: return SQR_BLOCK_SIZES;
   }
 }
@@ -1020,6 +1040,11 @@
       BLOCK_INVALID,  // BLOCK_64X128
       BLOCK_INVALID,  // BLOCK_128X64
       BLOCK_INVALID,  // BLOCK_128X128
+#if CONFIG_BLOCK_256
+      BLOCK_INVALID,  // BLOCK_128X256
+      BLOCK_INVALID,  // BLOCK_256X128
+      BLOCK_INVALID,  // BLOCK_256X256
+#endif                // CONFIG_BLOCK_256
     };
 
     return mid_sub_block_hpart[bsize];
@@ -1076,9 +1101,9 @@
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 
 static INLINE int is_partition_valid(BLOCK_SIZE bsize, PARTITION_TYPE p) {
-#if CONFIG_EXT_RECUR_PARTITIONS
+#if CONFIG_EXT_RECUR_PARTITIONS && !CONFIG_BLOCK_256
   if (p == PARTITION_SPLIT) return 0;
-#endif  // CONFIG_EXT_RECUR_PARTITIONS
+#endif  // CONFIG_EXT_RECUR_PARTITIONS && !CONFIG_BLOCK_256
   if (is_partition_point(bsize))
     return get_partition_subsize(bsize, p) < BLOCK_SIZES_ALL;
   else
@@ -1476,8 +1501,13 @@
   // - Current superblock, on decoder side.
   uint8_t *color_index_map;
 
+#if CONFIG_BLOCK_256
+  // block size in pixels
+  uint16_t width, height;
+#else
   // block size in pixels
   uint8_t width, height;
+#endif  // CONFIG_BLOCK_256
 
   qm_val_t *seg_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
   qm_val_t *seg_qmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
@@ -2772,13 +2802,91 @@
 static INLINE int av1_get_txb_size_index(BLOCK_SIZE bsize, int blk_row,
                                          int blk_col) {
   static const uint8_t tw_w_log2_table[BLOCK_SIZES_ALL] = {
-    0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 0, 1, 1, 2, 2, 3,
+    0,
+    0,
+    0,
+    0,
+    1,
+    1,
+    1,
+    2,
+    2,
+    2,
+    3,
+    3,
+    3,
+    3,
+    3,
+    3,
+#if CONFIG_BLOCK_256
+    3,
+    3,
+    3,
+#endif  // CONFIG_BLOCK_256
+    0,
+    1,
+    1,
+    2,
+    2,
+    3,
   };
   static const uint8_t tw_h_log2_table[BLOCK_SIZES_ALL] = {
-    0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 1, 0, 2, 1, 3, 2,
+    0,
+    0,
+    0,
+    0,
+    1,
+    1,
+    1,
+    2,
+    2,
+    2,
+    3,
+    3,
+    3,
+    3,
+    3,
+    3,
+#if CONFIG_BLOCK_256
+    3,
+    3,
+    3,
+#endif  // CONFIG_BLOCK_256
+    1,
+    0,
+    2,
+    1,
+    3,
+    2,
   };
   static const uint8_t stride_log2_table[BLOCK_SIZES_ALL] = {
-    0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 2, 2, 0, 1, 0, 1, 0, 1,
+    0,
+    0,
+    1,
+    1,
+    0,
+    1,
+    1,
+    0,
+    1,
+    1,
+    0,
+    1,
+    1,
+    1,
+    2,
+    2,
+#if CONFIG_BLOCK_256
+    2,
+    3,
+    3,
+#endif  // CONFIG_BLOCK_256
+    0,
+    1,
+    0,
+    1,
+    0,
+    1,
   };
   const int index =
       ((blk_row >> tw_h_log2_table[bsize]) << stride_log2_table[bsize]) +
@@ -2816,13 +2924,91 @@
   return index;
 #endif  // CONFIG_NEW_TX_PARTITION
   static const uint8_t tw_w_log2_table[BLOCK_SIZES_ALL] = {
-    0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    1,
+    1,
+    1,
+    2,
+    2,
+    2,
+    2,
+    2,
+    2,
+#if CONFIG_BLOCK_256
+    2,
+    2,
+    2,
+#endif  // CONFIG_BLOCK_256
+    0,
+    0,
+    1,
+    1,
+    2,
+    2,
   };
   static const uint8_t tw_h_log2_table[BLOCK_SIZES_ALL] = {
-    0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    1,
+    1,
+    1,
+    2,
+    2,
+    2,
+    2,
+    2,
+    2,
+#if CONFIG_BLOCK_256
+    2,
+    2,
+    2,
+#endif  // CONFIG_BLOCK_256
+    0,
+    0,
+    1,
+    1,
+    2,
+    2,
   };
   static const uint8_t stride_log2_table[BLOCK_SIZES_ALL] = {
-    0, 0, 1, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 3, 3, 0, 2, 0, 2, 0, 2,
+    0,
+    0,
+    1,
+    1,
+    1,
+    2,
+    2,
+    1,
+    2,
+    2,
+    1,
+    2,
+    2,
+    2,
+    3,
+    3,
+#if CONFIG_BLOCK_256
+    3,
+    4,
+    4,
+#endif  // CONFIG_BLOCK_256
+    0,
+    2,
+    0,
+    2,
+    0,
+    2,
   };
   index = ((blk_row >> tw_h_log2_table[bsize]) << stride_log2_table[bsize]) +
           (blk_col >> tw_w_log2_table[bsize]);
@@ -3127,7 +3313,33 @@
  */
 static INLINE int bsize_to_max_depth(BLOCK_SIZE bsize) {
   static const uint8_t bsize_to_max_depth_table[BLOCK_SIZES_ALL] = {
-    0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+    0,
+    1,
+    1,
+    1,
+    2,
+    2,
+    2,
+    2,
+    2,
+    2,
+    2,
+    2,
+    2,
+    2,
+    2,
+    2,
+#if CONFIG_BLOCK_256
+    2,
+    2,
+    2,
+#endif  // CONFIG_BLOCK_256
+    2,
+    2,
+    2,
+    2,
+    2,
+    2,
   };
   return bsize_to_max_depth_table[bsize];
 }
@@ -3147,7 +3359,33 @@
 static INLINE int bsize_to_tx_size_cat(BLOCK_SIZE bsize) {
   assert(bsize < BLOCK_SIZES_ALL);
   static const uint8_t bsize_to_tx_size_depth_table[BLOCK_SIZES_ALL] = {
-    0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 2, 2, 3, 3, 4, 4,
+    0,
+    1,
+    1,
+    1,
+    2,
+    2,
+    2,
+    3,
+    3,
+    3,
+    4,
+    4,
+    4,
+    4,
+    4,
+    4,
+#if CONFIG_BLOCK_256
+    4,
+    4,
+    4,
+#endif  // CONFIG_BLOCK_256
+    2,
+    2,
+    3,
+    3,
+    4,
+    4,
   };
   const int depth = bsize_to_tx_size_depth_table[bsize];
   assert(depth <= MAX_TX_CATS);
@@ -3385,8 +3623,12 @@
   return !has_second_ref(mbmi);
 }
 
+#if CONFIG_BLOCK_256
+static const int max_neighbor_obmc[MAX_SB_SIZE - 1] = { 0, 1, 2, 3, 4, 4, 4 };
+#else
 // input: log2 of length, 0(4), 1(8), ...
-static const int max_neighbor_obmc[6] = { 0, 1, 2, 3, 4, 4 };
+static const int max_neighbor_obmc[MAX_SB_SIZE - 1] = { 0, 1, 2, 3, 4, 4 };
+#endif  // BLOCK_256
 
 static INLINE int check_num_overlappable_neighbors(const MB_MODE_INFO *mbmi) {
   return !(mbmi->overlappable_neighbors[0] == 0 &&
diff --git a/av1/common/cdef.c b/av1/common/cdef.c
index 2c90fe0..39c5c42 100644
--- a/av1/common/cdef.c
+++ b/av1/common/cdef.c
@@ -41,11 +41,21 @@
   int maxc = mi_params->mi_cols - mi_col;
   int maxr = mi_params->mi_rows - mi_row;
 
-  if (bs == BLOCK_128X128 || bs == BLOCK_128X64)
+#if CONFIG_BLOCK_256
+  if (bs == BLOCK_256X256 || bs == BLOCK_256X128) {
+    maxc = AOMMIN(maxc, MI_SIZE_256X256);
+  } else
+#endif  // CONFIG_BLOCK_256
+      if (bs == BLOCK_128X128 || bs == BLOCK_128X64)
     maxc = AOMMIN(maxc, MI_SIZE_128X128);
   else
     maxc = AOMMIN(maxc, MI_SIZE_64X64);
-  if (bs == BLOCK_128X128 || bs == BLOCK_64X128)
+#if CONFIG_BLOCK_256
+  if (bs == BLOCK_256X256 || bs == BLOCK_128X256) {
+    maxr = AOMMIN(maxr, MI_SIZE_256X256);
+  } else
+#endif  // CONFIG_BLOCK_256
+      if (bs == BLOCK_128X128 || bs == BLOCK_64X128)
     maxr = AOMMIN(maxr, MI_SIZE_128X128);
   else
     maxr = AOMMIN(maxr, MI_SIZE_64X64);
diff --git a/av1/common/cdef.h b/av1/common/cdef.h
index 75c12de..1e843fe 100644
--- a/av1/common/cdef.h
+++ b/av1/common/cdef.h
@@ -34,14 +34,32 @@
          AOMMIN(abs(diff), AOMMAX(0, threshold - (abs(diff) >> shift)));
 }
 
-static AOM_INLINE int av1_get_cdef_transmitted_index(int mi_row, int mi_col) {
+#if defined(__clang__) && defined(__has_attribute)
+#if __has_attribute(no_sanitize)
+#define AOM_NO_UNSIGNED_OVERFLOW_CHECK \
+  __attribute__((                      \
+      no_sanitize("unsigned-integer-overflow", "unsigned-shift-base")))
+#endif
+#endif
+
+#ifndef AOM_NO_UNSIGNED_OVERFLOW_CHECK
+#define AOM_NO_UNSIGNED_OVERFLOW_CHECK
+#endif
+
+AOM_NO_UNSIGNED_OVERFLOW_CHECK static AOM_INLINE int
+av1_get_cdef_transmitted_index(int mi_row, int mi_col) {
   // Find index of this CDEF unit in this superblock.
-  const int index_mask = 1 << MI_IN_CDEF_LINEAR_LOG2;
-  const int cdef_unit_row_in_sb = !!(mi_row & index_mask);
-  const int cdef_unit_col_in_sb = !!(mi_col & index_mask);
-  return cdef_unit_col_in_sb + CDEF_IN_SB_STRIDE * cdef_unit_row_in_sb;
+  const int index_mask = (UINT32_MAX << (32 - CDEF_SB_SHIFT)) >>
+                         (32 - CDEF_SB_SHIFT - MI_IN_CDEF_LINEAR_LOG2);
+  const int cdef_unit_row_in_sb =
+      ((mi_row & index_mask) >> MI_IN_CDEF_LINEAR_LOG2);
+  const int cdef_unit_col_in_sb =
+      ((mi_col & index_mask) >> MI_IN_CDEF_LINEAR_LOG2);
+  return CDEF_IN_SB_STRIDE * cdef_unit_row_in_sb + cdef_unit_col_in_sb;
 }
 
+#undef AOM_NO_UNSIGNED_OVERFLOW_CHECK
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/av1/common/common_data.h b/av1/common/common_data.h
index 78dc502..87753dd 100644
--- a/av1/common/common_data.h
+++ b/av1/common/common_data.h
@@ -26,44 +26,70 @@
 
 // Log 2 conversion lookup tables in units of mode info (4x4).
 // The Mi_Width_Log2 table in the spec (Section 9.3. Conversion tables).
-static const uint8_t mi_size_wide_log2[BLOCK_SIZES_ALL] = {
-  0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 0, 2, 1, 3, 2, 4
-};
+static const uint8_t mi_size_wide_log2[BLOCK_SIZES_ALL] = { 0, 0, 1, 1, 1, 2,
+                                                            2, 2, 3, 3, 3, 4,
+                                                            4, 4, 5, 5,
+#if CONFIG_BLOCK_256
+                                                            5, 6, 6,
+#endif  // CONFIG_BLOCK_256
+                                                            0, 2, 1, 3, 2, 4 };
 // The Mi_Height_Log2 table in the spec (Section 9.3. Conversion tables).
-static const uint8_t mi_size_high_log2[BLOCK_SIZES_ALL] = {
-  0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 2, 0, 3, 1, 4, 2
-};
+static const uint8_t mi_size_high_log2[BLOCK_SIZES_ALL] = { 0, 1, 0, 1, 2, 1,
+                                                            2, 3, 2, 3, 4, 3,
+                                                            4, 5, 4, 5,
+#if CONFIG_BLOCK_256
+                                                            6, 5, 6,
+#endif  // CONFIG_BLOCK_256
+                                                            2, 0, 3, 1, 4, 2 };
 
 // Width/height lookup tables in units of mode info (4x4).
 // The Num_4x4_Blocks_Wide table in the spec (Section 9.3. Conversion tables).
-static const uint8_t mi_size_wide[BLOCK_SIZES_ALL] = {
-  1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 1, 4, 2, 8, 4, 16
-};
+static const uint8_t mi_size_wide[BLOCK_SIZES_ALL] = { 1,  1,  2,  2,  2, 4,
+                                                       4,  4,  8,  8,  8, 16,
+                                                       16, 16, 32, 32,
+#if CONFIG_BLOCK_256
+                                                       32, 64, 64,
+#endif  // CONFIG_BLOCK_256
+                                                       1,  4,  2,  8,  4, 16 };
 
 // The Num_4x4_Blocks_High table in the spec (Section 9.3. Conversion tables).
-static const uint8_t mi_size_high[BLOCK_SIZES_ALL] = {
-  1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8, 16, 32, 16, 32, 4, 1, 8, 2, 16, 4
-};
+static const uint8_t mi_size_high[BLOCK_SIZES_ALL] = { 1,  2,  1,  2,  4,  2,
+                                                       4,  8,  4,  8,  16, 8,
+                                                       16, 32, 16, 32,
+#if CONFIG_BLOCK_256
+                                                       64, 32, 64,
+#endif  // CONFIG_BLOCK_256
+                                                       4,  1,  8,  2,  16, 4 };
 
 // Width/height lookup tables in units of samples.
 // The Block_Width table in the spec (Section 9.3. Conversion tables).
-static const uint8_t block_size_wide[BLOCK_SIZES_ALL] = {
-  4,  4,  8,  8,   8,   16, 16, 16, 32, 32, 32,
-  64, 64, 64, 128, 128, 4,  16, 8,  32, 16, 64
+static const uint16_t block_size_wide[BLOCK_SIZES_ALL] = {
+  4,   4,   8,   8,  8,  16, 16, 16, 32, 32, 32, 64, 64, 64, 128, 128,
+#if CONFIG_BLOCK_256
+  128, 256, 256,
+#endif  // CONFIG_BLOCK_256
+  4,   16,  8,   32, 16, 64
 };
 
 // The Block_Height table in the spec (Section 9.3. Conversion tables).
-static const uint8_t block_size_high[BLOCK_SIZES_ALL] = {
-  4,  8,  4,   8,  16,  8,  16, 32, 16, 32, 64,
-  32, 64, 128, 64, 128, 16, 4,  32, 8,  64, 16
+static const uint16_t block_size_high[BLOCK_SIZES_ALL] = {
+  4,   8,   4,   8, 16, 8, 16, 32, 16, 32, 64, 32, 64, 128, 64, 128,
+#if CONFIG_BLOCK_256
+  256, 128, 256,
+#endif  // CONFIG_BLOCK_256
+  16,  4,   32,  8, 64, 16
 };
 
 // Maps a block size to a context.
 // The Size_Group table in the spec (Section 9.3. Conversion tables).
 // AOMMIN(3, AOMMIN(mi_size_wide_log2(bsize), mi_size_high_log2(bsize)))
-static const uint8_t size_group_lookup[BLOCK_SIZES_ALL] = {
-  0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 0, 0, 1, 1, 2, 2
-};
+static const uint8_t size_group_lookup[BLOCK_SIZES_ALL] = { 0, 0, 0, 1, 1, 1,
+                                                            2, 2, 2, 3, 3, 3,
+                                                            3, 3, 3, 3,
+#if CONFIG_BLOCK_256
+                                                            3, 3, 3,
+#endif  // CONFIG_BLOCK_256
+                                                            0, 0, 1, 1, 2, 2 };
 
 #if CONFIG_TX_PARTITION_CTX
 // Maps a block size to a transform partition context.
@@ -73,20 +99,36 @@
 //    rectangular block size
 // 3) For block size >= 64x64, the mapping value is 7
 static const uint8_t size_to_tx_part_group_lookup[BLOCK_SIZES_ALL] = {
-  0, 0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0
+  0, 0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 7, 7, 7,
+#if CONFIG_BLOCK_256
+  7, 7, 7,
+#endif  // CONFIG_BLOCK_256
+  0, 0, 0, 0, 0, 0
 };
 #endif  // CONFIG_TX_PARTITION_CTX
 
 static const uint8_t fsc_bsize_groups[BLOCK_SIZES_ALL] = {
 #if CONFIG_ATC_DCTX_ALIGNED
-  0, 1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 3, 3, 4, 4, 6, 6
+  0, 1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6,
+#if CONFIG_BLOCK_256
+  6, 6, 6,
+#endif  // CONFIG_BLOCK_256
+  3, 3, 4, 4, 6, 6
 #else
-  0, 1, 1, 2, 3, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 5, 5, 5, 5
+  0, 1, 1, 2, 3, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+#if CONFIG_BLOCK_256
+  5, 5, 5,
+#endif  // CONFIG_BLOCK_256
+  3, 3, 5, 5, 5, 5
 #endif  // CONFIG_ATC_DCTX_ALIGNED
 };
 
 static const uint8_t num_pels_log2_lookup[BLOCK_SIZES_ALL] = {
-  4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 13, 13, 14, 6, 6, 8, 8, 10, 10
+  4,  5,  5,  6, 7,  7, 8, 9, 9, 10, 11, 11, 12, 13, 13, 14,
+#if CONFIG_BLOCK_256
+  15, 15, 16,
+#endif  // CONFIG_BLOCK_256
+  6,  6,  8,  8, 10, 10
 };
 
 #if CONFIG_CWP
@@ -101,78 +143,150 @@
 /* clang-format off */
 // This table covers all square blocks and 1:2/2:1 rectangular blocks
 static const BLOCK_SIZE
-    subsize_lookup[EXT_PARTITION_TYPES + 1][BLOCK_SIZES_ALL] = {
-  {     // PARTITION_NONE
-    BLOCK_4X4, BLOCK_4X8, BLOCK_8X4, BLOCK_8X8, BLOCK_8X16, BLOCK_16X8,
-    BLOCK_16X16, BLOCK_16X32, BLOCK_32X16, BLOCK_32X32, BLOCK_32X64,
-    BLOCK_64X32, BLOCK_64X64, BLOCK_64X128, BLOCK_128X64, BLOCK_128X128,
-    BLOCK_4X16, BLOCK_16X4, BLOCK_8X32, BLOCK_32X8, BLOCK_16X64, BLOCK_64X16,
-  }, {  // PARTITION_HORZ
-    BLOCK_INVALID, BLOCK_4X4, BLOCK_INVALID, BLOCK_8X4, BLOCK_8X8, BLOCK_16X4,
-    BLOCK_16X8, BLOCK_16X16, BLOCK_32X8, BLOCK_32X16, BLOCK_32X32, BLOCK_64X16,
-    BLOCK_64X32, BLOCK_64X64, BLOCK_INVALID, BLOCK_128X64,
-    BLOCK_4X8, BLOCK_INVALID, BLOCK_8X16, BLOCK_INVALID, BLOCK_16X32,
-    BLOCK_INVALID,
-  }, {  // PARTITION_VERT
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X4, BLOCK_4X8, BLOCK_4X16, BLOCK_8X8,
-    BLOCK_8X16, BLOCK_8X32, BLOCK_16X16, BLOCK_16X32, BLOCK_16X64, BLOCK_32X32,
-    BLOCK_32X64, BLOCK_INVALID, BLOCK_64X64, BLOCK_64X128,
-    BLOCK_INVALID, BLOCK_8X4, BLOCK_INVALID, BLOCK_16X8, BLOCK_INVALID,
-    BLOCK_32X16,
-  }, {  // PARTITION_HORZ_3
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
-    BLOCK_INVALID, BLOCK_16X4, BLOCK_16X8, BLOCK_INVALID, BLOCK_32X8,
-    BLOCK_32X16, BLOCK_INVALID, BLOCK_64X16, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_4X4, BLOCK_INVALID, BLOCK_8X8, BLOCK_INVALID,
-    BLOCK_16X16, BLOCK_INVALID,
-  }, {  // PARTITION_VERT_3
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_4X8, BLOCK_4X16, BLOCK_INVALID, BLOCK_8X16, BLOCK_8X32, BLOCK_INVALID,
-    BLOCK_16X32, BLOCK_16X64, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_4X4, BLOCK_INVALID, BLOCK_8X8, BLOCK_INVALID,
-    BLOCK_16X16,
+    subsize_lookup[ALL_PARTITION_TYPES][BLOCK_SIZES_ALL] = { {
+    // PARTITION_NONE
+    BLOCK_4X4,                                   // 4
+    BLOCK_4X8,     BLOCK_8X4,     BLOCK_8X8,     // 8
+    BLOCK_8X16,    BLOCK_16X8,    BLOCK_16X16,   // 16
+    BLOCK_16X32,   BLOCK_32X16,   BLOCK_32X32,   // 32
+    BLOCK_32X64,   BLOCK_64X32,   BLOCK_64X64,   // 64
+    BLOCK_64X128,  BLOCK_128X64,  BLOCK_128X128, // 128
+#if CONFIG_BLOCK_256
+    BLOCK_128X256, BLOCK_256X128, BLOCK_256X256, // 256
+#endif  // CONFIG_BLOCK_256
+    BLOCK_4X16,    BLOCK_16X4,                   // 4,16
+    BLOCK_8X32,    BLOCK_32X8,                   // 8,32
+    BLOCK_16X64,   BLOCK_64X16,                  // 32,64
+  }, {
+    // PARTITION_HORZ
+    BLOCK_INVALID,                               // 4
+    BLOCK_4X4,     BLOCK_INVALID, BLOCK_8X4,     // 8
+    BLOCK_8X8,     BLOCK_16X4,    BLOCK_16X8,    // 16
+    BLOCK_16X16,   BLOCK_32X8,    BLOCK_32X16,   // 32
+    BLOCK_32X32,   BLOCK_64X16,   BLOCK_64X32,   // 64
+    BLOCK_64X64,   BLOCK_INVALID, BLOCK_128X64,  // 128
+#if CONFIG_BLOCK_256
+    BLOCK_128X128, BLOCK_INVALID, BLOCK_256X128, // 256
+#endif  // CONFIG_BLOCK_256
+    BLOCK_4X8,     BLOCK_INVALID,                // 4,16
+    BLOCK_8X16,    BLOCK_INVALID,                // 8,32
+    BLOCK_16X32,   BLOCK_INVALID,                // 32,64
+  }, {
+    // PARTITION_VERT
+    BLOCK_INVALID,                               // 4
+    BLOCK_INVALID, BLOCK_4X4,     BLOCK_4X8,     // 8
+    BLOCK_4X16,    BLOCK_8X8,     BLOCK_8X16,    // 16
+    BLOCK_8X32,    BLOCK_16X16,   BLOCK_16X32,   // 32
+    BLOCK_16X64,   BLOCK_32X32,   BLOCK_32X64,   // 64
+    BLOCK_INVALID, BLOCK_64X64,   BLOCK_64X128,  // 128
+#if CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_128X128, BLOCK_128X256, // 256
+#endif  // CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_8X4,                    // 4,16
+    BLOCK_INVALID, BLOCK_16X8,                   // 8,32
+    BLOCK_INVALID, BLOCK_32X16,                  // 32,64
+  }, {
+    // PARTITION_HORZ_3
+    BLOCK_INVALID,                               // 4
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 8
+    BLOCK_8X4,     BLOCK_INVALID, BLOCK_16X4,    // 16
+    BLOCK_16X8,    BLOCK_INVALID, BLOCK_32X8,    // 32
+    BLOCK_32X16,   BLOCK_INVALID, BLOCK_64X16,   // 64
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 128
+#if CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 256
+#endif  // CONFIG_BLOCK_256
+    BLOCK_4X4,     BLOCK_INVALID,                // 4,16
+    BLOCK_8X8,     BLOCK_INVALID,                // 8,32
+    BLOCK_16X16,   BLOCK_INVALID,                // 32,64
+  }, {
+    // PARTITION_VERT_3
+    BLOCK_INVALID,                               // 4
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 8
+    BLOCK_INVALID, BLOCK_4X8,     BLOCK_4X16,    // 16
+    BLOCK_INVALID, BLOCK_8X16,    BLOCK_8X32,    // 32
+    BLOCK_INVALID, BLOCK_16X32,   BLOCK_16X64,   // 64
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 128
+#if CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 256
+#endif  // CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_4X4,                    // 4,16
+    BLOCK_INVALID, BLOCK_8X8,                    // 8,32
+    BLOCK_INVALID, BLOCK_16X16,                  // 32,64
 #if CONFIG_UNEVEN_4WAY
   }, {  // PARTITION_HORZ_4A
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X4, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_32X8, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID,
+    BLOCK_INVALID,                               // 4
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 8
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 16
+    BLOCK_16X4,    BLOCK_INVALID, BLOCK_INVALID, // 32
+    BLOCK_32X8,    BLOCK_INVALID, BLOCK_INVALID, // 64
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 128
+#if CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 256
+#endif  // CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID,                // 4,16
+    BLOCK_INVALID, BLOCK_INVALID,                // 8,32
+    BLOCK_INVALID, BLOCK_INVALID,                // 32,64
   }, {  // PARTITION_HORZ_4B
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X4, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_32X8, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID,
+    BLOCK_INVALID,                               // 4
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 8
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 16
+    BLOCK_16X4,    BLOCK_INVALID, BLOCK_INVALID, // 32
+    BLOCK_32X8,    BLOCK_INVALID, BLOCK_INVALID, // 64
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 128
+#if CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 256
+#endif  // CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID,                // 4,16
+    BLOCK_INVALID, BLOCK_INVALID,                // 8,32
+    BLOCK_INVALID, BLOCK_INVALID,                // 32,64
   }, {  // PARTITION_VERT_4A
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X16, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_8X32, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID,
+    BLOCK_INVALID,                               // 4
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 8
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 16
+    BLOCK_INVALID, BLOCK_4X16,    BLOCK_INVALID, // 32
+    BLOCK_INVALID, BLOCK_8X32,    BLOCK_INVALID, // 64
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 128
+#if CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 256
+#endif  // CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID,                // 4,16
+    BLOCK_INVALID, BLOCK_INVALID,                // 8,32
+    BLOCK_INVALID, BLOCK_INVALID,                // 32,64
   }, {  // PARTITION_VERT_4B
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X16, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_8X32, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID,
+    BLOCK_INVALID,                               // 4
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 8
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 16
+    BLOCK_INVALID, BLOCK_4X16, BLOCK_INVALID,    // 32
+    BLOCK_INVALID, BLOCK_8X32, BLOCK_INVALID,    // 64
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 128
+#if CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, // 256
+#endif  // CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID,                // 4,16
+    BLOCK_INVALID, BLOCK_INVALID,                // 8,32
+    BLOCK_INVALID, BLOCK_INVALID,                // 32,64
 #endif  // CONFIG_UNEVEN_4WAY
-  }, {  // PARTITION_SPLIT
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X4, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_8X8, BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X16,
-    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X32, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_64X64, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
-    BLOCK_INVALID, BLOCK_INVALID,
+  }, {
+    // PARTITION_SPLIT
+    BLOCK_INVALID,                               // 4
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X4,     // 8
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X8,     // 16
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X16,   // 32
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X32,   // 64
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X64,   // 128
+#if CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X128, // 256
+#endif  // CONFIG_BLOCK_256
+    BLOCK_INVALID, BLOCK_INVALID,                // 4,16
+    BLOCK_INVALID, BLOCK_INVALID,                // 8,32
+    BLOCK_INVALID, BLOCK_INVALID,                // 32,64
   },
 };
+/* clang-format on */
 
-static AOM_INLINE PARTITION_TYPE sdp_chroma_part_from_luma(BLOCK_SIZE bsize,
-                                         PARTITION_TYPE luma_part, int ssx,
-                                         int ssy) {
+static AOM_INLINE PARTITION_TYPE sdp_chroma_part_from_luma(
+    BLOCK_SIZE bsize, PARTITION_TYPE luma_part, int ssx, int ssy) {
   const int bh_chr = block_size_high[bsize] >> ssy;
   const int bw_chr = block_size_wide[bsize] >> ssx;
   assert(bh_chr >= 16 && bw_chr >= 16 &&
@@ -226,12 +340,14 @@
         return PARTITION_VERT_3;
       else
         return (bw_chr < 8) ? PARTITION_NONE : PARTITION_VERT;
+    case PARTITION_SPLIT:
+      return (bh_chr < 8 || bw_chr < 8) ? PARTITION_NONE : PARTITION_SPLIT;
     default: assert(0);
   }
   return PARTITION_INVALID;
 }
 
-#else  // CONFIG_EXT_RECUR_PARTITIONS
+#else   // CONFIG_EXT_RECUR_PARTITIONS
 // A compressed version of the Partition_Subsize table in the spec (9.3.
 // Conversion tables), for square block sizes only.
 /* clang-format off */
@@ -268,7 +384,9 @@
     BLOCK_8X32, BLOCK_16X64, BLOCK_INVALID
   }
 };
+/* clang-format on */
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
+/* clang-format off */
 
 static const TX_SIZE max_txsize_lookup[BLOCK_SIZES_ALL] = {
   //                   4X4
@@ -285,6 +403,10 @@
   TX_64X64,
   // 64x128, 128x64,   128x128
   TX_64X64,  TX_64X64, TX_64X64,
+#if CONFIG_BLOCK_256
+  // 128X256,256X128,  256X256
+  TX_64X64,  TX_64X64, TX_64X64,
+#endif  // CONFIG_BLOCK_256
   // 4x16,   16x4,     8x32
   TX_4X4,    TX_4X4,   TX_8X8,
   // 32x8,   16x64     64x16
@@ -306,6 +428,10 @@
       TX_64X64,
       // 64x128, 128x64,   128x128
       TX_64X64,  TX_64X64, TX_64X64,
+#if CONFIG_BLOCK_256
+      // 128X256,256X128,  256X256
+      TX_64X64,  TX_64X64, TX_64X64,
+#endif  // CONFIG_BLOCK_256
       // 4x16,   16x4,
       TX_4X16,   TX_16X4,
       // 8x32,   32x8
@@ -578,6 +704,11 @@
   { { BLOCK_64X128,  BLOCK_64X64 },   { BLOCK_INVALID, BLOCK_32X64 } },
   { { BLOCK_128X64,  BLOCK_INVALID }, { BLOCK_64X64,   BLOCK_64X32 } },
   { { BLOCK_128X128, BLOCK_128X64 },  { BLOCK_64X128,  BLOCK_64X64 } },
+#if CONFIG_BLOCK_256
+  { { BLOCK_128X256, BLOCK_128X128 }, { BLOCK_INVALID, BLOCK_64X128 } },
+  { { BLOCK_256X128, BLOCK_INVALID }, { BLOCK_128X128, BLOCK_128X64 } },
+  { { BLOCK_256X256, BLOCK_256X128 }, { BLOCK_128X256, BLOCK_128X128 } },
+#endif  // CONFIG_BLOCK_256
   { { BLOCK_4X16,    BLOCK_4X8 },     { BLOCK_INVALID, BLOCK_4X8 } },
   { { BLOCK_16X4,    BLOCK_INVALID }, { BLOCK_8X4,     BLOCK_8X4 } },
   { { BLOCK_8X32,    BLOCK_8X16 },    { BLOCK_INVALID, BLOCK_4X16 } },
@@ -605,6 +736,11 @@
   { { BLOCK_64X128,  BLOCK_64X64 },   { BLOCK_INVALID, BLOCK_32X64 } },
   { { BLOCK_128X64,  BLOCK_INVALID }, { BLOCK_64X64,   BLOCK_64X32 } },
   { { BLOCK_128X128, BLOCK_128X64 },  { BLOCK_64X128,  BLOCK_64X64 } },
+#if CONFIG_BLOCK_256
+  { { BLOCK_128X256, BLOCK_128X128 }, { BLOCK_INVALID,  BLOCK_64X128 } },
+  { { BLOCK_256X128, BLOCK_INVALID }, { BLOCK_128X128,  BLOCK_128X64 } },
+  { { BLOCK_256X256, BLOCK_256X128 }, { BLOCK_128X256,  BLOCK_128X128 } },
+#endif  // CONFIG_BLOCK_256
   { { BLOCK_4X16,    BLOCK_4X8 },     { BLOCK_INVALID, BLOCK_4X8 } },
   { { BLOCK_16X4,    BLOCK_INVALID }, { BLOCK_8X4,     BLOCK_8X4 } },
   { { BLOCK_8X32,    BLOCK_8X16 },    { BLOCK_INVALID, BLOCK_4X16 } },
@@ -623,28 +759,33 @@
   PARTITION_CONTEXT above;
   PARTITION_CONTEXT left;
 } partition_context_lookup[BLOCK_SIZES_ALL] = {
-  { 31, 31 },  // 4X4   - {0b11111, 0b11111}
-  { 31, 30 },  // 4X8   - {0b11111, 0b11110}
-  { 30, 31 },  // 8X4   - {0b11110, 0b11111}
-  { 30, 30 },  // 8X8   - {0b11110, 0b11110}
-  { 30, 28 },  // 8X16  - {0b11110, 0b11100}
-  { 28, 30 },  // 16X8  - {0b11100, 0b11110}
-  { 28, 28 },  // 16X16 - {0b11100, 0b11100}
-  { 28, 24 },  // 16X32 - {0b11100, 0b11000}
-  { 24, 28 },  // 32X16 - {0b11000, 0b11100}
-  { 24, 24 },  // 32X32 - {0b11000, 0b11000}
-  { 24, 16 },  // 32X64 - {0b11000, 0b10000}
-  { 16, 24 },  // 64X32 - {0b10000, 0b11000}
-  { 16, 16 },  // 64X64 - {0b10000, 0b10000}
-  { 16, 0 },   // 64X128- {0b10000, 0b00000}
-  { 0, 16 },   // 128X64- {0b00000, 0b10000}
-  { 0, 0 },    // 128X128-{0b00000, 0b00000}
-  { 31, 28 },  // 4X16  - {0b11111, 0b11100}
-  { 28, 31 },  // 16X4  - {0b11100, 0b11111}
-  { 30, 24 },  // 8X32  - {0b11110, 0b11000}
-  { 24, 30 },  // 32X8  - {0b11000, 0b11110}
-  { 28, 16 },  // 16X64 - {0b11100, 0b10000}
-  { 16, 28 },  // 64X16 - {0b10000, 0b11100}
+  { 32 + 31, 32 + 31 },  // 4X4   - {0b111111, 0b111111}
+  { 32 + 31, 32 + 30 },  // 4X8   - {0b111111, 0b111110}
+  { 32 + 30, 32 + 31 },  // 8X4   - {0b111110, 0b111111}
+  { 32 + 30, 32 + 30 },  // 8X8   - {0b111110, 0b111110}
+  { 32 + 30, 32 + 28 },  // 8X16  - {0b111110, 0b111100}
+  { 32 + 28, 32 + 30 },  // 16X8  - {0b111100, 0b111110}
+  { 32 + 28, 32 + 28 },  // 16X16 - {0b111100, 0b111100}
+  { 32 + 28, 32 + 24 },  // 16X32 - {0b111100, 0b111000}
+  { 32 + 24, 32 + 28 },  // 32X16 - {0b111000, 0b111100}
+  { 32 + 24, 32 + 24 },  // 32X32 - {0b111000, 0b111000}
+  { 32 + 24, 32 + 16 },  // 32X64 - {0b111000, 0b110000}
+  { 32 + 16, 32 + 24 },  // 64X32 - {0b110000, 0b111000}
+  { 32 + 16, 32 + 16 },  // 64X64 - {0b110000, 0b110000}
+  { 32 + 16, 32 +  0 },  // 64X128- {0b110000, 0b100000}
+  { 32 +  0, 32 + 16 },  // 128X64- {0b100000, 0b110000}
+  { 32 +  0, 32 +  0 },  // 128X128-{0b100000, 0b100000}
+#if CONFIG_BLOCK_256
+  { 32 +  0,  0 +  0 },  // 128X256-{0b100000, 0b000000}
+  {  0 +  0, 32 +  0 },  // 256X128-{0b000000, 0b100000}
+  {  0 +  0,  0 +  0 },  // 256X256-{0b000000, 0b000000}
+#endif  // CONFIG_BLOCK_256
+  { 32 + 31, 32 + 28 },  // 4X16  - {0b111111, 0b111100}
+  { 32 + 28, 32 + 31 },  // 16X4  - {0b111100, 0b111111}
+  { 32 + 30, 32 + 24 },  // 8X32  - {0b111110, 0b111000}
+  { 32 + 24, 32 + 30 },  // 32X8  - {0b111000, 0b111110}
+  { 32 + 28, 32 + 16 },  // 16X64 - {0b111100, 0b110000}
+  { 32 + 16, 32 + 28 },  // 64X16 - {0b110000, 0b111100}
 };
 /* clang-format on */
 
diff --git a/av1/common/entropy.c b/av1/common/entropy.c
index 8299a19..ebafcb2 100644
--- a/av1/common/entropy.c
+++ b/av1/common/entropy.c
@@ -336,6 +336,14 @@
       RESET_CDF_COUNTER(fc->do_split_cdf[plane_index][i], 2);
     }
   }
+#if CONFIG_BLOCK_256
+  for (int plane_index = 0; plane_index < PARTITION_STRUCTURE_NUM;
+       plane_index++) {
+    for (int i = 0; i < SQUARE_SPLIT_CONTEXTS; i++) {
+      RESET_CDF_COUNTER(fc->do_square_split_cdf[plane_index][i], 2);
+    }
+  }
+#endif  // CONFIG_BLOCK_256
   for (int plane_index = 0; plane_index < PARTITION_STRUCTURE_NUM;
        plane_index++) {
     for (int i = 0; i < PARTITION_CONTEXTS; i++) {
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index ad694cc..41e29fc 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -13,10 +13,12 @@
 #include "aom_mem/aom_mem.h"
 
 #include "av1/common/av1_common_int.h"
+#include "av1/common/enums.h"
 #include "av1/common/reconinter.h"
 #include "av1/common/scan.h"
 #include "av1/common/seg_common.h"
 #include "av1/common/txb_common.h"
+#include "av1/encoder/mcomp.h"
 
 #if !CONFIG_AIMC
 static const aom_cdf_prob
@@ -330,7 +332,15 @@
         // BLOCK_128X64,
         { AOM_CDF2(20677) }, { AOM_CDF2(6167) },  { AOM_CDF2(4062) },  { AOM_CDF2(584) },
         // BLOCK_128X128,
-        { AOM_CDF2(28847) }, { AOM_CDF2(7433) },  { AOM_CDF2(7570) }, { AOM_CDF2(805) }
+        { AOM_CDF2(28847) }, { AOM_CDF2(7433) },  { AOM_CDF2(7570) }, { AOM_CDF2(805) },
+#if CONFIG_BLOCK_256
+        // BLOCK_128X256, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+        // BLOCK_256X128, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+        // BLOCK_256X256, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
       },
       // Chroma
       {
@@ -365,7 +375,15 @@
         // BLOCK_128X64,
         { AOM_CDF2(22207) }, { AOM_CDF2(6060) },  { AOM_CDF2(4607) },  { AOM_CDF2(559) },
         // BLOCK_128X128,
-        { AOM_CDF2(26187) }, { AOM_CDF2(14749) }, { AOM_CDF2(15794) }, { AOM_CDF2(6386) }
+        { AOM_CDF2(26187) }, { AOM_CDF2(14749) }, { AOM_CDF2(15794) }, { AOM_CDF2(6386) },
+#if CONFIG_BLOCK_256
+        // BLOCK_128X256, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+        // BLOCK_256X128, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+        // BLOCK_256X256, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
       }
     };
 
@@ -404,7 +422,15 @@
         // BLOCK_128X64,
         { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
         // BLOCK_128X128,
-        { AOM_CDF2(21467) }, { AOM_CDF2(22207) }, { AOM_CDF2(28266) }, { AOM_CDF2(29969) }
+        { AOM_CDF2(21467) }, { AOM_CDF2(22207) }, { AOM_CDF2(28266) }, { AOM_CDF2(29969) },
+#if CONFIG_BLOCK_256
+        // BLOCK_128X256, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+        // BLOCK_256X128, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+        // BLOCK_256X256, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
       },
       // Chroma
       {
@@ -439,7 +465,15 @@
         // BLOCK_128X64, unused
         { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
         // BLOCK_128X128,
-        { AOM_CDF2(17160) }, { AOM_CDF2(18950) }, { AOM_CDF2(20526) }, { AOM_CDF2(19920) }
+        { AOM_CDF2(17160) }, { AOM_CDF2(18950) }, { AOM_CDF2(20526) }, { AOM_CDF2(19920) },
+#if CONFIG_BLOCK_256
+        // BLOCK_128X256, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+        // BLOCK_256X128, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+        // BLOCK_256X256, retrain needed
+        { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
       }
     };
 
@@ -484,7 +518,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         },
         // VERT
         {
@@ -519,7 +561,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         }
       },
       // Chroma
@@ -557,7 +607,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         },
         // VERT
         {
@@ -592,11 +650,39 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, retrain needed
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         }
       }
     };
 
+#if CONFIG_BLOCK_256
+static aom_cdf_prob
+    default_do_square_split_cdf[PARTITION_STRUCTURE_NUM][SQUARE_SPLIT_CONTEXTS][CDF_SIZE(2)] = {
+      // Luma
+      {
+        // BLOCK_128X128,
+        { AOM_CDF2(28847) }, { AOM_CDF2(7433) },  { AOM_CDF2(7570) }, { AOM_CDF2(805) },
+        // BLOCK_256X256,
+        { AOM_CDF2(28847) }, { AOM_CDF2(7433) },  { AOM_CDF2(7570) }, { AOM_CDF2(805) }
+      },
+      // Chroma
+      {
+        // BLOCK_128X128,
+        { AOM_CDF2(26187) }, { AOM_CDF2(14749) }, { AOM_CDF2(15794) }, { AOM_CDF2(6386) },
+        // BLOCK_256X256,
+        { AOM_CDF2(26187) }, { AOM_CDF2(14749) }, { AOM_CDF2(15794) }, { AOM_CDF2(6386) },
+      },
+    };
+#endif  // CONFIG_BLOCK_256
+
 #if CONFIG_UNEVEN_4WAY
 static aom_cdf_prob default_do_uneven_4way_partition_cdf
     [PARTITION_STRUCTURE_NUM][NUM_RECT_PARTS][PARTITION_CONTEXTS]
@@ -636,7 +722,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         },
         // VERT
         {
@@ -671,7 +765,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         }
       },
       // Chroma
@@ -709,7 +811,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         },
         // VERT
         {
@@ -744,7 +854,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         }
       },
     };
@@ -787,7 +905,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         },
         // VERT
         {
@@ -822,7 +948,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         }
       },
       // Chroma
@@ -860,7 +994,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         },
         // VERT
         {
@@ -895,7 +1037,15 @@
           // BLOCK_128X64, unused
           { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
           // BLOCK_128X128, unused
-          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+          // BLOCK_128X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X128, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+          // BLOCK_256X256, unused
+          { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
         }
       },
     };
@@ -1815,9 +1965,12 @@
       { AOM_CDF2(27530) }, { AOM_CDF2(29564) }, { AOM_CDF2(29444) },
       { AOM_CDF2(26872) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+      { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
-      { AOM_CDF2(16384) }
+      { AOM_CDF2(16384) },
     };
 
 static const aom_cdf_prob default_compound_type_cdf[BLOCK_SIZES_ALL][CDF_SIZE(
@@ -1827,6 +1980,9 @@
   { AOM_CDF2(9770) },  { AOM_CDF2(9100) },  { AOM_CDF2(8233) },
   { AOM_CDF2(6172) },  { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
   { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
   { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
   { AOM_CDF2(11820) }, { AOM_CDF2(7701) },  { AOM_CDF2(16384) },
   { AOM_CDF2(16384) }
@@ -1843,6 +1999,9 @@
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+      { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(16384) },
@@ -1865,6 +2024,11 @@
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
+#if CONFIG_BLOCK_256
+      { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
+      { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
+      { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
+#endif  // CONFIG_BLOCK_256
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
@@ -1890,6 +2054,11 @@
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
+#if CONFIG_BLOCK_256
+      { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
+      { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
+      { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
+#endif  // CONFIG_BLOCK_256
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
       { AOM_CDF10(3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491) },
@@ -1907,6 +2076,10 @@
       { AOM_CDF4(8192, 16384, 24576) }, { AOM_CDF4(8192, 16384, 24576) },
       { AOM_CDF4(8192, 16384, 24576) }, { AOM_CDF4(8192, 16384, 24576) },
       { AOM_CDF4(8192, 16384, 24576) }, { AOM_CDF4(8192, 16384, 24576) },
+#if CONFIG_BLOCK_256
+      { AOM_CDF4(8192, 16384, 24576) }, { AOM_CDF4(8192, 16384, 24576) },
+      { AOM_CDF4(8192, 16384, 24576) },
+#endif  // CONFIG_BLOCK_256
       { AOM_CDF4(8192, 16384, 24576) }, { AOM_CDF4(8192, 16384, 24576) },
       { AOM_CDF4(8192, 16384, 24576) }, { AOM_CDF4(8192, 16384, 24576) },
       { AOM_CDF4(8192, 16384, 24576) }, { AOM_CDF4(8192, 16384, 24576) }
@@ -1921,6 +2094,10 @@
       { AOM_CDF3(10923, 21845) }, { AOM_CDF3(10923, 21845) },
       { AOM_CDF3(10923, 21845) }, { AOM_CDF3(10923, 21845) },
       { AOM_CDF3(10923, 21845) }, { AOM_CDF3(10923, 21845) },
+#if CONFIG_BLOCK_256
+      { AOM_CDF3(10923, 21845) }, { AOM_CDF3(10923, 21845) },
+      { AOM_CDF3(10923, 21845) },
+#endif  // CONFIG_BLOCK_256
       { AOM_CDF3(10923, 21845) }, { AOM_CDF3(10923, 21845) },
       { AOM_CDF3(10923, 21845) }, { AOM_CDF3(10923, 21845) },
       { AOM_CDF3(10923, 21845) }, { AOM_CDF3(10923, 21845) }
@@ -1959,6 +2136,14 @@
                          18432, 20480, 22528, 24576, 26624, 28672, 30720) },
              { AOM_CDF16(2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384,
                          18432, 20480, 22528, 24576, 26624, 28672, 30720) },
+#if CONFIG_BLOCK_256
+             { AOM_CDF16(2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384,
+                         18432, 20480, 22528, 24576, 26624, 28672, 30720) },
+             { AOM_CDF16(2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384,
+                         18432, 20480, 22528, 24576, 26624, 28672, 30720) },
+             { AOM_CDF16(2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384,
+                         18432, 20480, 22528, 24576, 26624, 28672, 30720) },
+#endif  // CONFIG_BLOCK_256
              { AOM_CDF16(2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384,
                          18432, 20480, 22528, 24576, 26624, 28672, 30720) },
              { AOM_CDF16(2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384,
@@ -1980,6 +2165,9 @@
   { AOM_CDF2(25377) }, { AOM_CDF2(14285) }, { AOM_CDF2(20066) },
   { AOM_CDF2(29912) }, { AOM_CDF2(25066) }, { AOM_CDF2(27617) },
   { AOM_CDF2(31583) }, { AOM_CDF2(31269) }, { AOM_CDF2(32311) },
+#if CONFIG_BLOCK_256
+  { AOM_CDF2(32717) }, { AOM_CDF2(31269) }, { AOM_CDF2(32311) },
+#endif  // CONFIG_BLOCK_256
   { AOM_CDF2(32717) }, { AOM_CDF2(21846) }, { AOM_CDF2(21846) },
   { AOM_CDF2(30177) }, { AOM_CDF2(28425) }, { AOM_CDF2(30147) },
   { AOM_CDF2(31307) }
@@ -1991,6 +2179,9 @@
             { AOM_CDF2(28283) }, { AOM_CDF2(17490) }, { AOM_CDF2(22156) },
             { AOM_CDF2(29137) }, { AOM_CDF2(26381) }, { AOM_CDF2(25945) },
             { AOM_CDF2(29190) }, { AOM_CDF2(30434) }, { AOM_CDF2(30786) },
+#if CONFIG_BLOCK_256
+            { AOM_CDF2(31582) }, { AOM_CDF2(30434) }, { AOM_CDF2(30786) },
+#endif  // CONFIG_BLOCK_256
             { AOM_CDF2(31582) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
             { AOM_CDF2(30177) }, { AOM_CDF2(30093) }, { AOM_CDF2(31776) },
             { AOM_CDF2(31514) } };
@@ -2002,6 +2193,9 @@
       { AOM_CDF2(28283) }, { AOM_CDF2(17490) }, { AOM_CDF2(22156) },
       { AOM_CDF2(29137) }, { AOM_CDF2(26381) }, { AOM_CDF2(25945) },
       { AOM_CDF2(29190) }, { AOM_CDF2(30434) }, { AOM_CDF2(30786) },
+#if CONFIG_BLOCK_256
+      { AOM_CDF2(31582) }, { AOM_CDF2(30434) }, { AOM_CDF2(30786) },
+#endif  // CONFIG_BLOCK_256
       { AOM_CDF2(31582) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(30177) }, { AOM_CDF2(30093) }, { AOM_CDF2(31776) },
       { AOM_CDF2(31514) }
@@ -2028,6 +2222,9 @@
             { AOM_CDF2(9806) },  { AOM_CDF2(7405) },  { AOM_CDF2(7949) },
             { AOM_CDF2(14870) }, { AOM_CDF2(18438) }, { AOM_CDF2(16459) },
             { AOM_CDF2(19468) }, { AOM_CDF2(24415) }, { AOM_CDF2(22864) },
+#if CONFIG_BLOCK_256
+            { AOM_CDF2(23527) }, { AOM_CDF2(24415) }, { AOM_CDF2(22864) },
+#endif  // CONFIG_BLOCK_256
             { AOM_CDF2(23527) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
             { AOM_CDF2(19610) }, { AOM_CDF2(16215) }, { AOM_CDF2(25420) },
             { AOM_CDF2(25105) } };
@@ -2047,6 +2244,9 @@
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+      { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
       { AOM_CDF2(16384) }
@@ -2098,6 +2298,10 @@
                        { AOM_CDF3(20360, 28062) }, { AOM_CDF3(21679, 26830) },
                        { AOM_CDF3(29516, 30701) }, { AOM_CDF3(28898, 30397) },
                        { AOM_CDF3(30878, 31335) }, { AOM_CDF3(32507, 32558) },
+#if CONFIG_BLOCK_256
+                       { AOM_CDF3(28898, 30397) }, { AOM_CDF3(30878, 31335) },
+                       { AOM_CDF3(32507, 32558) },
+#endif  // CONFIG_BLOCK_256
                        { AOM_CDF3(10923, 21845) }, { AOM_CDF3(10923, 21845) },
                        { AOM_CDF3(28799, 31390) }, { AOM_CDF3(26431, 30774) },
                        { AOM_CDF3(28973, 31594) }, { AOM_CDF3(29742, 31203) } };
@@ -2108,6 +2312,9 @@
   { AOM_CDF2(17432) }, { AOM_CDF2(14423) }, { AOM_CDF2(15142) },
   { AOM_CDF2(25817) }, { AOM_CDF2(22823) }, { AOM_CDF2(22083) },
   { AOM_CDF2(30128) }, { AOM_CDF2(31014) }, { AOM_CDF2(31560) },
+#if CONFIG_BLOCK_256
+  { AOM_CDF2(32638) }, { AOM_CDF2(31014) }, { AOM_CDF2(31560) },
+#endif  // CONFIG_BLOCK_256
   { AOM_CDF2(32638) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
   { AOM_CDF2(23664) }, { AOM_CDF2(20901) }, { AOM_CDF2(24008) },
   { AOM_CDF2(26879) }
@@ -2857,6 +3064,9 @@
             { AOM_CDF2(12408) }, { AOM_CDF2(14301) }, { AOM_CDF2(12756) },
             { AOM_CDF2(22343) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
             { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#if CONFIG_BLOCK_256
+            { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+#endif  // CONFIG_BLOCK_256
             { AOM_CDF2(16384) }, { AOM_CDF2(12770) }, { AOM_CDF2(10368) },
             { AOM_CDF2(20229) }, { AOM_CDF2(18101) }, { AOM_CDF2(16384) },
             { AOM_CDF2(16384) } };
@@ -3457,6 +3667,9 @@
   av1_copy(fc->switchable_interp_cdf, default_switchable_interp_cdf);
 #if CONFIG_EXT_RECUR_PARTITIONS
   av1_copy(fc->do_split_cdf, default_do_split_cdf);
+#if CONFIG_BLOCK_256
+  av1_copy(fc->do_square_split_cdf, default_do_square_split_cdf);
+#endif  // CONFIG_BLOCK_256
   av1_copy(fc->rect_type_cdf, default_rect_type_cdf);
   av1_copy(fc->do_ext_partition_cdf, default_do_ext_partition_cdf);
 #if CONFIG_UNEVEN_4WAY
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index a35e738..752c3e1 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -15,6 +15,7 @@
 
 #include "av1/common/entropy.h"
 #include "av1/common/entropymv.h"
+#include "av1/common/enums.h"
 #include "av1/common/filter.h"
 #include "av1/common/seg_common.h"
 #include "aom_dsp/aom_filter.h"
@@ -391,6 +392,10 @@
 #if CONFIG_EXT_RECUR_PARTITIONS
   aom_cdf_prob do_split_cdf[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS]
                            [CDF_SIZE(2)];
+#if CONFIG_BLOCK_256
+  aom_cdf_prob do_square_split_cdf[PARTITION_STRUCTURE_NUM]
+                                  [SQUARE_SPLIT_CONTEXTS][CDF_SIZE(2)];
+#endif  // CONFIG_BLOCK_256
   aom_cdf_prob rect_type_cdf[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS]
                             [CDF_SIZE(2)];
   aom_cdf_prob do_ext_partition_cdf[PARTITION_STRUCTURE_NUM][NUM_RECT_PARTS]
diff --git a/av1/common/enums.h b/av1/common/enums.h
index c550978..a9a8c4d 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -115,9 +115,14 @@
 #endif  // CONFIG_IMPROVED_JMVD
 
 // Max superblock size
+#if CONFIG_BLOCK_256
+#define MAX_SB_SIZE_LOG2 8
+#else
 #define MAX_SB_SIZE_LOG2 7
+#endif  // CONFIG_BLOCK_256
 #define MAX_SB_SIZE (1 << MAX_SB_SIZE_LOG2)
 #define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
+#define BLOCK_128_MI_SIZE_LOG2 5
 
 // Min superblock size
 #define MIN_SB_SIZE_LOG2 6
@@ -160,6 +165,7 @@
 
 #define MI_SIZE_64X64 (64 >> MI_SIZE_LOG2)
 #define MI_SIZE_128X128 (128 >> MI_SIZE_LOG2)
+#define MI_SIZE_256X256 (256 >> MI_SIZE_LOG2)
 
 #define MAX_PALETTE_SQUARE (64 * 64)
 // Maximum number of colors in a palette.
@@ -254,6 +260,11 @@
   BLOCK_64X128,
   BLOCK_128X64,
   BLOCK_128X128,
+#if CONFIG_BLOCK_256
+  BLOCK_128X256,
+  BLOCK_256X128,
+  BLOCK_256X256,
+#endif  // CONFIG_BLOCK_256
   BLOCK_4X16,
   BLOCK_16X4,
   BLOCK_8X32,
@@ -261,6 +272,11 @@
   BLOCK_16X64,
   BLOCK_64X16,
   BLOCK_SIZES_ALL,
+#if CONFIG_BLOCK_256
+  BLOCK_MAX = BLOCK_256X256,
+#else
+  BLOCK_MAX = BLOCK_128X128,
+#endif  // CONFIG_BLOCK_256
   BLOCK_SIZES = BLOCK_4X16,
   BLOCK_INVALID = 255,
   BLOCK_LARGEST = (BLOCK_SIZES - 1)
@@ -305,12 +321,13 @@
   TREES_TYPES,
 } UENUM1BYTE(TREE_TYPE);
 
+#if CONFIG_BLOCK_256
+// 4X4, 8X8, 16X16, 32X32, 64X64, 128X128, 256X256
+#define SQR_BLOCK_SIZES 7
+#else
 // 4X4, 8X8, 16X16, 32X32, 64X64, 128X128
 #define SQR_BLOCK_SIZES 6
-
-#if CONFIG_EXT_RECUR_PARTITIONS
-#define KEEP_PARTITION_SPLIT 0
-#endif  // CONFIG_EXT_RECUR_PARTITIONS
+#endif  // CONFIG_BLOCK_256
 
 //  Partition types.  R: Recursive
 //
@@ -381,8 +398,9 @@
   PARTITION_VERT_4A,  // 4 vertical uneven sub-partitions (1:2:4:1).
   PARTITION_VERT_4B,  // 4 vertical uneven sub-partitions (1:4:2:1).
 #endif                // CONFIG_UNEVEN_4WAY
-  EXT_PARTITION_TYPES,
-  PARTITION_SPLIT = EXT_PARTITION_TYPES,
+  PARTITION_SPLIT,
+  EXT_PARTITION_TYPES = PARTITION_SPLIT,
+  ALL_PARTITION_TYPES = EXT_PARTITION_TYPES + 1,
   PARTITION_TYPES = PARTITION_VERT + 1,
 #if !CONFIG_UNEVEN_4WAY
   LIMITED_PARTITION_TYPES = PARTITION_TYPES - 1,
@@ -430,6 +448,7 @@
 
 #if CONFIG_EXT_RECUR_PARTITIONS
 #define PARTITION_BLOCK_SIZES BLOCK_SIZES
+#define SQUARE_SPLIT_CONTEXTS (2 * PARTITION_PLOFFSET)
 #else
 #define PARTITION_BLOCK_SIZES 5
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
@@ -1053,7 +1072,7 @@
 #else
 #define TXFM_PARTITION_CONTEXTS ((TX_SIZES - TX_8X8) * 6 - 3)
 #endif  // CONFIG_NEW_TX_PARTITION
-typedef uint8_t TXFM_CONTEXT;
+typedef uint16_t TXFM_CONTEXT;
 
 #if CONFIG_TIP
 #define TIP_CONTEXTS 3
diff --git a/av1/common/loopfiltermask.c b/av1/common/loopfiltermask.c
index fd350ee..519f164 100644
--- a/av1/common/loopfiltermask.c
+++ b/av1/common/loopfiltermask.c
@@ -80,24 +80,42 @@
 // A loopfilter should be applied to every other 4x4 horizontally.
 #if CONFIG_LPF_MASK
 static const int mask_id_table_tx_4x4[BLOCK_SIZES_ALL] = {
-  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, -1, 13, 14, 15, 16, 17, 18
+  0,  1,  2,  3,  4,  5, 6, 7, 8, 9, 10, 11, 12, -1, -1, -1,
+#if CONFIG_BLOCK_256
+  -1, -1, -1,
+#endif  // CONFIG_BLOCK_256
+  13, 14, 15, 16, 17, 18
 };
 
 static const int mask_id_table_tx_8x8[BLOCK_SIZES_ALL] = {
-  -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, 10, 11, 12, 13
+  -1, -1, -1, 0,  1,  2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1,
+#if CONFIG_BLOCK_256
+  -1, -1, -1,
+#endif  // CONFIG_BLOCK_256
+  -1, -1, 10, 11, 12, 13
 };
 
 static const int mask_id_table_tx_16x16[BLOCK_SIZES_ALL] = {
-  -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, -1, -1, -1, -1, -1, -1, -1, 7, 8
+  -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, -1, -1, -1,
+#if CONFIG_BLOCK_256
+  -1, -1, -1,
+#endif  // CONFIG_BLOCK_256
+  -1, -1, -1, -1, 7,  8
 };
 
 static const int mask_id_table_tx_32x32[BLOCK_SIZES_ALL] = {
-  -1, -1, -1, -1, -1, -1, -1, -1, -1, 0,  1,
-  2,  3,  -1, -1, -1, -1, -1, -1, -1, -1, -1
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, -1, -1, -1,
+#if CONFIG_BLOCK_256
+  -1, -1, -1,
+#endif  // CONFIG_BLOCK_256
+  -1, -1, -1, -1, -1, -1
 };
 static const int mask_id_table_vert_border[BLOCK_SIZES_ALL] = {
-  0,  47, 49, 19, 51, 53, 33, 55, 57, 42, 59,
-  60, 46, -1, -1, -1, 61, 62, 63, 64, 65, 66
+  0,  47, 49, 19, 51, 53, 33, 55, 57, 42, 59, 60, 46, -1, -1, -1,
+#if CONFIG_BLOCK_256
+  -1, -1, -1,
+#endif  // CONFIG_BLOCK_256
+  61, 62, 63, 64, 65, 66
 };
 
 static const FilterMask left_mask_univariant_reordered[67] = {
@@ -918,11 +936,9 @@
   uint8_t *lfl2;
 
   // filter two rows at a time
-  for (r = 0; r < cm->seq_params.mib_size &&
-              ((mi_row + r) << MI_SIZE_LOG2 < cm->height);
+  for (r = 0; r < cm->mib_size && ((mi_row + r) << MI_SIZE_LOG2 < cm->height);
        r += r_step) {
-    for (c = 0; c < cm->seq_params.mib_size &&
-                ((mi_col + c) << MI_SIZE_LOG2 < cm->width);
+    for (c = 0; c < cm->mib_size && ((mi_col + c) << MI_SIZE_LOG2 < cm->width);
          c += MI_SIZE_64X64) {
       dst->buf += ((c << MI_SIZE_LOG2) >> ssx);
       LoopFilterMask *lfm = get_loop_filter_mask(cm, mi_row + r, mi_col + c);
@@ -992,11 +1008,9 @@
   uint64_t mask_4x4 = 0;
   uint8_t *lfl;
 
-  for (r = 0; r < cm->seq_params.mib_size &&
-              ((mi_row + r) << MI_SIZE_LOG2 < cm->height);
+  for (r = 0; r < cm->mib_size && ((mi_row + r) << MI_SIZE_LOG2 < cm->height);
        r += r_step) {
-    for (c = 0; c < cm->seq_params.mib_size &&
-                ((mi_col + c) << MI_SIZE_LOG2 < cm->width);
+    for (c = 0; c < cm->mib_size && ((mi_col + c) << MI_SIZE_LOG2 < cm->width);
          c += MI_SIZE_64X64) {
       if (mi_row + r == 0) continue;
 
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index b7e1caf..bcddcc9 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -880,7 +880,7 @@
   for (int i = 0; i < end_mi;) {
 #if CONFIG_EXT_RECUR_PARTITIONS
     if (xd->mi_col + col_offset + i >= cm->mi_params.mi_cols) break;
-    const int sb_mi_size = mi_size_wide[cm->seq_params.sb_size];
+    const int sb_mi_size = mi_size_wide[cm->sb_size];
     const int mask_row = mi_row & (sb_mi_size - 1);
     const int mask_col = mi_col & (sb_mi_size - 1);
     const int ref_mask_row = mask_row + row_offset;
@@ -1041,7 +1041,7 @@
   for (i = 0; i < end_mi;) {
 #if CONFIG_EXT_RECUR_PARTITIONS
     if (xd->mi_row + row_offset + i >= cm->mi_params.mi_rows) break;
-    const int sb_mi_size = mi_size_wide[cm->seq_params.sb_size];
+    const int sb_mi_size = mi_size_wide[cm->sb_size];
     const int mask_row = mi_row & (sb_mi_size - 1);
     const int mask_col = mi_col & (sb_mi_size - 1);
     const int ref_mask_row = mask_row + row_offset + i;
@@ -1253,7 +1253,7 @@
 #if CONFIG_EXT_RECUR_PARTITIONS
 static int has_top_right(const AV1_COMMON *cm, const MACROBLOCKD *xd,
                          int mi_row, int mi_col, int n4_w) {
-  const int sb_mi_size = mi_size_wide[cm->seq_params.sb_size];
+  const int sb_mi_size = mi_size_wide[cm->sb_size];
   const int mask_row = mi_row & (sb_mi_size - 1);
   const int mask_col = mi_col & (sb_mi_size - 1);
 
@@ -1287,7 +1287,7 @@
 #if CONFIG_MVP_IMPROVEMENT || CONFIG_EXTENDED_WARP_PREDICTION
 static int has_bottom_left(const AV1_COMMON *cm, const MACROBLOCKD *xd,
                            int mi_row, int mi_col, int n4_h) {
-  const int sb_mi_size = mi_size_wide[cm->seq_params.sb_size];
+  const int sb_mi_size = mi_size_wide[cm->sb_size];
   const int mask_row = mi_row & (sb_mi_size - 1);
   const int mask_col = mi_col & (sb_mi_size - 1);
 
@@ -1318,7 +1318,7 @@
 #else
 static int has_top_right(const AV1_COMMON *cm, const MACROBLOCKD *xd,
                          int mi_row, int mi_col, int bs) {
-  const int sb_mi_size = mi_size_wide[cm->seq_params.sb_size];
+  const int sb_mi_size = mi_size_wide[cm->sb_size];
   const int mask_row = mi_row & (sb_mi_size - 1);
   const int mask_col = mi_col & (sb_mi_size - 1);
 
@@ -1373,7 +1373,7 @@
 #if CONFIG_MVP_IMPROVEMENT
 static int has_bottom_left(const AV1_COMMON *cm, const MACROBLOCKD *xd,
                            int mi_row, int mi_col, int bs) {
-  const int sb_mi_size = mi_size_wide[cm->seq_params.sb_size];
+  const int sb_mi_size = mi_size_wide[cm->sb_size];
   const int mask_row = mi_row & (sb_mi_size - 1);
   const int mask_col = mi_col & (sb_mi_size - 1);
 
@@ -1382,7 +1382,7 @@
 
   // bs lareger than 64x64 or equals to sb_size case not allowed
   if (bs > mi_size_wide[BLOCK_64X64]) has_bl = 0;
-  if (bs == mi_size_wide[cm->seq_params.sb_size]) has_bl = 0;
+  if (bs == mi_size_wide[cm->sb_size]) has_bl = 0;
 
   // bs > 0 and bs is a power of 2
   assert(bs > 0 && !(bs & (bs - 1)));
diff --git a/av1/common/mvref_common.h b/av1/common/mvref_common.h
index 2f84d6e..41f3452 100644
--- a/av1/common/mvref_common.h
+++ b/av1/common/mvref_common.h
@@ -904,14 +904,16 @@
   const int sb_size = max_mib_size * MI_SIZE;
   const int src_sb_row = ((src_bottom_edge >> 3) - 1) / sb_size;
   const int src_sb64_col = ((src_right_edge >> 3) - 1) >> 6;
+
   const int total_sb64_per_row =
-      ((tile->mi_col_end - tile->mi_col_start - 1) >> 4) + 1;
+      (((tile->mi_col_end - tile->mi_col_start - 1) >> 4) + 1);
   const int active_sb64 = active_sb_row * total_sb64_per_row + active_sb64_col;
   const int src_sb64 = src_sb_row * total_sb64_per_row + src_sb64_col;
   if (src_sb64 >= active_sb64 - INTRABC_DELAY_SB64) return 0;
 
   // Wavefront constraint: use only top left area of frame for reference.
-  const int gradient = 1 + INTRABC_DELAY_SB64 + (sb_size > 64);
+  const int gradient =
+      1 + INTRABC_DELAY_SB64 + (sb_size > 64) + 2 * (sb_size > 128);
   const int wf_offset = gradient * (active_sb_row - src_sb_row);
   if (src_sb_row > active_sb_row ||
       src_sb64_col >= active_sb64_col - INTRABC_DELAY_SB64 + wf_offset)
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index 1a2c2aa..07c57c3 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -321,6 +321,11 @@
   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },  // not used
   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },  // not used
   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },  // not used
+#if CONFIG_BLOCK_256
+  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },  // not used
+  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },  // not used
+  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },  // not used
+#endif  // CONFIG_BLOCK_256
   { 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, },
   { 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, },
   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },  // not used
@@ -442,6 +447,11 @@
   { 0, NULL, NULL, NULL },
   { 0, NULL, NULL, NULL },
   { 0, NULL, NULL, NULL },
+#if CONFIG_BLOCK_256
+  { 0, NULL, NULL, NULL },
+  { 0, NULL, NULL, NULL },
+  { 0, NULL, NULL, NULL },
+#endif  // CONFIG_BLOCK_256
   { MAX_WEDGE_TYPES, wedge_codebook_16, NULL, wedge_masks[BLOCK_8X32] },
   { MAX_WEDGE_TYPES, wedge_codebook_16, NULL, wedge_masks[BLOCK_32X8] },
   { MAX_WEDGE_TYPES, wedge_codebook_16, NULL, wedge_masks[BLOCK_16X64] },
@@ -474,6 +484,11 @@
   { 0, NULL, NULL, NULL },
   { 0, NULL, NULL, NULL },
   { 0, NULL, NULL, NULL },
+#if CONFIG_BLOCK_256
+  { 0, NULL, NULL, NULL },
+  { 0, NULL, NULL, NULL },
+  { 0, NULL, NULL, NULL },
+#endif  // CONFIG_BLOCK_256
   { MAX_WEDGE_TYPES, wedge_codebook_16_hgtw, wedge_signflip_lookup[BLOCK_8X32],
     wedge_masks[BLOCK_8X32] },
   { MAX_WEDGE_TYPES, wedge_codebook_16_hltw, wedge_signflip_lookup[BLOCK_32X8],
@@ -784,6 +799,9 @@
 static uint8_t ii_size_scales[BLOCK_SIZES_ALL] = {
     32, 16, 16, 16, 8, 8, 8, 4,
     4,  4,  2,  2,  2, 1, 1, 1,
+#if CONFIG_BLOCK_256
+    0,  0,  0,  // unused
+#endif  // CONFIG_BLOCK_256
     8,  8,  4,  4,  2, 2
 };
 /* clang-format on */
@@ -1377,14 +1395,16 @@
 #endif  // CONFIG_REFINEMV
 ) {
   const int target_prec = MV_REFINE_PREC_BITS;
+  const int n = opfl_get_subblock_size(bw, bh, plane
+#if CONFIG_OPTFLOW_ON_TIP
+                                       ,
+                                       use_4x4
+#endif  // CONFIG_OPTFLOW_ON_TIP
+  );
+  int n_blocks = (bw / n) * (bh / n);
   // Convert output MV to 1/16th pel
   assert(MV_REFINE_PREC_BITS >= 3);
-#if CONFIG_OPTFLOW_ON_TIP
-  const int num_mv = (mbmi->ref_frame[0] == TIP_FRAME) ? 4 : N_OF_OFFSETS;
-#else
-  const int num_mv = N_OF_OFFSETS;
-#endif  // CONFIG_OPTFLOW_ON_TIP
-  for (int mvi = 0; mvi < num_mv; mvi++) {
+  for (int mvi = 0; mvi < n_blocks; mvi++) {
     mv_refined[mvi * 2].as_mv.row *= 1 << (MV_REFINE_PREC_BITS - 3);
     mv_refined[mvi * 2].as_mv.col *= 1 << (MV_REFINE_PREC_BITS - 3);
     mv_refined[mvi * 2 + 1].as_mv.row *= 1 << (MV_REFINE_PREC_BITS - 3);
@@ -1446,14 +1466,7 @@
   }
 #endif  // CONFIG_OPTFLOW_ON_TIP
 
-  int n_blocks = 1;
   int grad_prec_bits;
-  int n = opfl_get_subblock_size(bw, bh, plane
-#if CONFIG_OPTFLOW_ON_TIP
-                                 ,
-                                 use_4x4
-#endif  // CONFIG_OPTFLOW_ON_TIP
-  );
 
 #if OPFL_BILINEAR_GRAD || OPFL_BICUBIC_GRAD
   // Compute gradients of P0 and P1 with interpolation
@@ -3551,15 +3564,23 @@
   int vy1[N_OF_OFFSETS] = { 0 };
 
   // Pointers to gradient and dst buffers
-  int16_t *gx0, *gy0, *gx1, *gy1;
-  uint16_t *dst0 = NULL, *dst1 = NULL;
 
   if (use_optflow_refinement && plane == 0) {
     // Allocate gradient and dst buffers
-    gx0 = aom_memalign(32, 2 * MAX_SB_SIZE * MAX_SB_SIZE * sizeof(*gx0));
-    gx1 = aom_memalign(32, 2 * MAX_SB_SIZE * MAX_SB_SIZE * sizeof(*gx1));
-    gy0 = gx0 + (MAX_SB_SIZE * MAX_SB_SIZE);
-    gy1 = gx1 + (MAX_SB_SIZE * MAX_SB_SIZE);
+    const int n = opfl_get_subblock_size(bw, bh, plane
+#if CONFIG_OPTFLOW_ON_TIP
+                                         ,
+                                         1
+#endif  // CONFIG_OPTFLOW_ON_TIP
+    );
+    const int n_blocks = (bw / n) * (bh / n);
+    int16_t *gx0, *gy0, *gx1, *gy1;
+    DECLARE_ALIGNED(32, int16_t, g0_buf[2 * MAX_SB_SQUARE]);
+    DECLARE_ALIGNED(32, int16_t, g1_buf[2 * MAX_SB_SQUARE]);
+    gx0 = g0_buf;
+    gx1 = g1_buf;
+    gy0 = g0_buf + MAX_SB_SQUARE;
+    gy1 = g1_buf + MAX_SB_SQUARE;
 
     // Initialize refined mv
 #if CONFIG_REFINEMV
@@ -3569,14 +3590,13 @@
       const MV mv0 = mi->mv[0].as_mv;
       const MV mv1 = mi->mv[1].as_mv;
 #endif  // CONFIG_REFINEMV
-    for (int mvi = 0; mvi < N_OF_OFFSETS; mvi++) {
+    for (int mvi = 0; mvi < n_blocks; mvi++) {
       mv_refined[mvi * 2].as_mv = mv0;
       mv_refined[mvi * 2 + 1].as_mv = mv1;
     }
     // Refine MV using optical flow. The final output MV will be in 1/16
     // precision.
-    dst0 = aom_calloc(1, MAX_SB_SIZE * MAX_SB_SIZE * sizeof(uint16_t));
-    dst1 = aom_calloc(1, MAX_SB_SIZE * MAX_SB_SIZE * sizeof(uint16_t));
+    uint16_t dst0[MAX_SB_SQUARE], dst1[MAX_SB_SQUARE];
     av1_get_optflow_based_mv_highbd(cm, xd, plane, mi, mv_refined, bw, bh, mi_x,
                                     mi_y, mc_buf, calc_subpel_params_func, gx0,
                                     gy0, gx1, gy1, vx0, vy0, vx1, vy1, dst0,
@@ -3590,10 +3610,6 @@
                                     best_mv_ref, bw, bh
 #endif  // CONFIG_REFINEMV
     );
-    aom_free(dst0);
-    aom_free(dst1);
-    aom_free(gx0);
-    aom_free(gx1);
   }
 #endif  // CONFIG_OPTFLOW_REFINEMENT
 
@@ -3666,10 +3682,10 @@
 
 #if CONFIG_OPTFLOW_REFINEMENT
     if (use_optflow_refinement && plane == 0) {
-      int n = opfl_get_subblock_size(bw, bh, plane
+      const int n = opfl_get_subblock_size(bw, bh, plane
 #if CONFIG_OPTFLOW_ON_TIP
-                                     ,
-                                     1
+                                           ,
+                                           1
 #endif  // CONFIG_OPTFLOW_ON_TIP
       );
       inter_pred_params.interp_filter_params[0] =
diff --git a/av1/common/reconintra.c b/av1/common/reconintra.c
index d2d5e01..dfc240a 100644
--- a/av1/common/reconintra.c
+++ b/av1/common/reconintra.c
@@ -110,7 +110,7 @@
     if (col_off + top_right_count_unit < plane_bw_unit) return 1;
 
     // Handle the top-right intra tx block of the coding block
-    const int sb_mi_size = mi_size_wide[cm->seq_params.sb_size];
+    const int sb_mi_size = mi_size_wide[cm->sb_size];
     const int mi_row_aligned =
         is_bsize_altered_for_chroma
             ? xd->mi[0]->chroma_ref_info.mi_row_chroma_base
@@ -241,6 +241,10 @@
   has_tr_32x64, has_tr_64x32, has_tr_64x64,
   // 64x128,    128x64,         128x128
   has_tr_64x128, has_tr_128x64, has_tr_128x128,
+#if CONFIG_BLOCK_256
+  // 128X256,   256X128,        256X256,
+  NULL, NULL, NULL,
+#endif  // CONFIG_BLOCK_256
   // 4x16,      16x4,            8x32
   has_tr_4x16, has_tr_16x4, has_tr_8x32,
   // 32x8,      16x64,           64x16
@@ -270,15 +274,31 @@
   // 4X4
   NULL,
   // 4X8,      8X4,         8X8
-  has_tr_4x8, NULL, has_tr_vert_8x8,
+  has_tr_4x8,
+  NULL,
+  has_tr_vert_8x8,
   // 8X16,     16X8,        16X16
-  has_tr_8x16, NULL, has_tr_vert_16x16,
+  has_tr_8x16,
+  NULL,
+  has_tr_vert_16x16,
   // 16X32,    32X16,       32X32
-  has_tr_16x32, NULL, has_tr_vert_32x32,
+  has_tr_16x32,
+  NULL,
+  has_tr_vert_32x32,
   // 32X64,    64X32,       64X64
-  has_tr_32x64, NULL, has_tr_vert_64x64,
+  has_tr_32x64,
+  NULL,
+  has_tr_vert_64x64,
   // 64x128,   128x64,      128x128
-  has_tr_64x128, NULL, has_tr_128x128
+  has_tr_64x128,
+  NULL,
+  has_tr_128x128
+#if CONFIG_BLOCK_256
+      // 128X256,   256X128,        256X256,
+      NULL,
+  NULL,
+  NULL,
+#endif  // CONFIG_BLOCK_256
 };
 
 static const uint8_t *get_has_tr_table(PARTITION_TYPE partition,
@@ -325,7 +345,7 @@
 
     const int bw_in_mi_log2 = mi_size_wide_log2[bsize];
     const int bh_in_mi_log2 = mi_size_high_log2[bsize];
-    const int sb_mi_size = mi_size_high[cm->seq_params.sb_size];
+    const int sb_mi_size = mi_size_high[cm->sb_size];
     const int blk_row_in_sb = (mi_row & (sb_mi_size - 1)) >> bh_in_mi_log2;
     const int blk_col_in_sb = (mi_col & (sb_mi_size - 1)) >> bw_in_mi_log2;
 
@@ -397,7 +417,7 @@
 
     // The general case: neither the leftmost column nor the bottom row. The
     // bottom-left mi is in the same SB
-    const int sb_mi_size = mi_size_high[cm->seq_params.sb_size];
+    const int sb_mi_size = mi_size_high[cm->sb_size];
     const int mi_row_aligned =
         is_bsize_altered_for_chroma
             ? xd->mi[0]->chroma_ref_info.mi_row_chroma_base
@@ -411,8 +431,7 @@
     const int bl_mask_col = (mi_col_aligned & (sb_mi_size - 1)) - 1;
 
     if (bl_mask_col < 0) {
-      const int plane_sb_height =
-          block_size_high[cm->seq_params.sb_size] >> ss_y;
+      const int plane_sb_height = block_size_high[cm->sb_size] >> ss_y;
       const int plane_bottom_row =
           (((mi_row_aligned & (sb_mi_size - 1)) << MI_SIZE_LOG2) +
            block_size_high[bsize]) >>
@@ -1866,7 +1885,7 @@
 #endif  // CONFIG_IDIF
 
   const int is_sb_boundary =
-      (mi_row % cm->seq_params.mib_size == 0 && row_off == 0) ? 1 : 0;
+      (mi_row % cm->mib_size == 0 && row_off == 0) ? 1 : 0;
 
   build_intra_predictors_high(
       xd, ref, ref_stride, dst, dst_stride, mode, angle_delta,
diff --git a/av1/common/restoration.c b/av1/common/restoration.c
index 2a91711..c307424 100644
--- a/av1/common/restoration.c
+++ b/av1/common/restoration.c
@@ -2859,7 +2859,7 @@
                                        int *rrow1) {
   assert(rcol0 && rcol1 && rrow0 && rrow1);
 
-  if (bsize != cm->seq_params.sb_size) return 0;
+  if (bsize != cm->sb_size) return 0;
 
   assert(!cm->features.all_lossless);
 
diff --git a/av1/common/thread_common.c b/av1/common/thread_common.c
index 14ab9da..9be67cb 100644
--- a/av1/common/thread_common.c
+++ b/av1/common/thread_common.c
@@ -210,7 +210,7 @@
 #if CONFIG_LPF_MASK
                             int is_decoding,
 #endif
-                            int plane_start, int plane_end) {
+                            int plane_start, int plane_end, int mib_size) {
   int mi_row, plane, dir;
   AV1LfMTInfo *lf_job_queue = lf_sync->job_queue;
   lf_sync->jobs_enqueued = 0;
@@ -229,9 +229,10 @@
       if (is_decoding) {
         step = MI_SIZE_64X64;
       }
+      (void)mib_size;
       for (mi_row = start; mi_row < stop; mi_row += step)
 #else
-      for (mi_row = start; mi_row < stop; mi_row += MAX_MIB_SIZE)
+      for (mi_row = start; mi_row < stop; mi_row += mib_size)
 #endif
       {
         lf_job_queue->mi_row = mi_row;
@@ -268,9 +269,10 @@
     const YV12_BUFFER_CONFIG *const frame_buffer, AV1_COMMON *const cm,
     struct macroblockd_plane *planes, MACROBLOCKD *xd,
     AV1LfSync *const lf_sync) {
+  const int mib_size = cm->mib_size;
+  const int mib_size_log2 = cm->mib_size_log2;
   const int sb_cols =
-      ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, MAX_MIB_SIZE_LOG2) >>
-      MAX_MIB_SIZE_LOG2;
+      ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, mib_size_log2) >> mib_size_log2;
   int mi_row, mi_col, plane, dir;
   int r, c;
 
@@ -281,12 +283,11 @@
       mi_row = cur_job_info->mi_row;
       plane = cur_job_info->plane;
       dir = cur_job_info->dir;
-      r = mi_row >> MAX_MIB_SIZE_LOG2;
+      r = mi_row >> mib_size_log2;
 
       if (dir == 0) {
-        for (mi_col = 0; mi_col < cm->mi_params.mi_cols;
-             mi_col += MAX_MIB_SIZE) {
-          c = mi_col >> MAX_MIB_SIZE_LOG2;
+        for (mi_col = 0; mi_col < cm->mi_params.mi_cols; mi_col += mib_size) {
+          c = mi_col >> mib_size_log2;
 
           av1_setup_dst_planes(planes, frame_buffer, mi_row, mi_col, plane,
                                plane + 1, NULL);
@@ -296,9 +297,8 @@
           sync_write(lf_sync, r, c, sb_cols, plane);
         }
       } else if (dir == 1) {
-        for (mi_col = 0; mi_col < cm->mi_params.mi_cols;
-             mi_col += MAX_MIB_SIZE) {
-          c = mi_col >> MAX_MIB_SIZE_LOG2;
+        for (mi_col = 0; mi_col < cm->mi_params.mi_cols; mi_col += mib_size) {
+          c = mi_col >> mib_size_log2;
 
           // Wait for vertical edge filtering of the top-right block to be
           // completed
@@ -406,6 +406,8 @@
                                 AVxWorker *workers, int nworkers,
                                 AV1LfSync *lf_sync) {
   const AVxWorkerInterface *const winterface = aom_get_worker_interface();
+  const int mib_size = cm->mib_size;
+  const int mib_size_log2 = cm->mib_size_log2;
 #if CONFIG_LPF_MASK
   int sb_rows;
   if (is_decoding) {
@@ -418,8 +420,7 @@
 #else
   // Number of superblock rows and cols
   const int sb_rows =
-      ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, MAX_MIB_SIZE_LOG2) >>
-      MAX_MIB_SIZE_LOG2;
+      ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, mib_size_log2) >> mib_size_log2;
 #endif
   const int num_workers = nworkers;
   int i;
@@ -440,7 +441,7 @@
 #if CONFIG_LPF_MASK
                   is_decoding,
 #endif
-                  plane_start, plane_end);
+                  plane_start, plane_end, mib_size);
 
   // Set up loopfilter thread data.
   for (i = 0; i < num_workers; ++i) {
diff --git a/av1/common/tile_common.c b/av1/common/tile_common.c
index e7c6c8f..1a50ad9 100644
--- a/av1/common/tile_common.c
+++ b/av1/common/tile_common.c
@@ -29,16 +29,15 @@
 }
 
 void av1_get_tile_limits(AV1_COMMON *const cm) {
-  const SequenceHeader *const seq_params = &cm->seq_params;
   CommonTileParams *const tiles = &cm->tiles;
   const int mi_cols =
-      ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, seq_params->mib_size_log2);
+      ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, cm->mib_size_log2);
   const int mi_rows =
-      ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, seq_params->mib_size_log2);
-  const int sb_cols = mi_cols >> seq_params->mib_size_log2;
-  const int sb_rows = mi_rows >> seq_params->mib_size_log2;
+      ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->mib_size_log2);
+  const int sb_cols = mi_cols >> cm->mib_size_log2;
+  const int sb_rows = mi_rows >> cm->mib_size_log2;
 
-  const int sb_size_log2 = seq_params->mib_size_log2 + MI_SIZE_LOG2;
+  const int sb_size_log2 = cm->mib_size_log2 + MI_SIZE_LOG2;
   tiles->max_width_sb = MAX_TILE_WIDTH >> sb_size_log2;
   const int max_tile_area_sb = MAX_TILE_AREA >> (2 * sb_size_log2);
 
@@ -49,13 +48,12 @@
   tiles->min_log2 = AOMMAX(tiles->min_log2, tiles->min_log2_cols);
 }
 
-void av1_calculate_tile_cols(const SequenceHeader *const seq_params,
-                             int cm_mi_rows, int cm_mi_cols,
-                             CommonTileParams *const tiles) {
-  int mi_cols = ALIGN_POWER_OF_TWO(cm_mi_cols, seq_params->mib_size_log2);
-  int mi_rows = ALIGN_POWER_OF_TWO(cm_mi_rows, seq_params->mib_size_log2);
-  int sb_cols = mi_cols >> seq_params->mib_size_log2;
-  int sb_rows = mi_rows >> seq_params->mib_size_log2;
+void av1_calculate_tile_cols(const AV1_COMMON *cm, int cm_mi_rows,
+                             int cm_mi_cols, CommonTileParams *const tiles) {
+  int mi_cols = ALIGN_POWER_OF_TWO(cm_mi_cols, cm->mib_size_log2);
+  int mi_rows = ALIGN_POWER_OF_TWO(cm_mi_rows, cm->mib_size_log2);
+  int sb_cols = mi_cols >> cm->mib_size_log2;
+  int sb_rows = mi_rows >> cm->mib_size_log2;
   int i;
 
   // This will be overridden if there is at least two columns of tiles
@@ -76,7 +74,7 @@
     tiles->min_log2_rows = AOMMAX(tiles->min_log2 - tiles->log2_cols, 0);
     tiles->max_height_sb = sb_rows >> tiles->min_log2_rows;
 
-    tiles->width = size_sb << seq_params->mib_size_log2;
+    tiles->width = size_sb << cm->mib_size_log2;
     tiles->width = AOMMIN(tiles->width, cm_mi_cols);
     if (tiles->cols > 1) {
       tiles->min_inner_width = tiles->width;
@@ -98,16 +96,15 @@
     }
     tiles->max_height_sb = AOMMAX(max_tile_area_sb / widest_tile_sb, 1);
     if (tiles->cols > 1) {
-      tiles->min_inner_width = narrowest_inner_tile_sb
-                               << seq_params->mib_size_log2;
+      tiles->min_inner_width = narrowest_inner_tile_sb << cm->mib_size_log2;
     }
   }
 }
 
-void av1_calculate_tile_rows(const SequenceHeader *const seq_params,
-                             int cm_mi_rows, CommonTileParams *const tiles) {
-  int mi_rows = ALIGN_POWER_OF_TWO(cm_mi_rows, seq_params->mib_size_log2);
-  int sb_rows = mi_rows >> seq_params->mib_size_log2;
+void av1_calculate_tile_rows(const AV1_COMMON *cm, int cm_mi_rows,
+                             CommonTileParams *const tiles) {
+  int mi_rows = ALIGN_POWER_OF_TWO(cm_mi_rows, cm->mib_size_log2);
+  int sb_rows = mi_rows >> cm->mib_size_log2;
   int start_sb, size_sb, i;
 
   if (tiles->uniform_spacing) {
@@ -121,7 +118,7 @@
     tiles->rows = i;
     tiles->row_start_sb[i] = sb_rows;
 
-    tiles->height = size_sb << seq_params->mib_size_log2;
+    tiles->height = size_sb << cm->mib_size_log2;
     tiles->height = AOMMIN(tiles->height, cm_mi_rows);
   } else {
     tiles->log2_rows = tile_log2(1, tiles->rows);
@@ -130,10 +127,8 @@
 
 void av1_tile_set_row(TileInfo *tile, const AV1_COMMON *cm, int row) {
   assert(row < cm->tiles.rows);
-  int mi_row_start = cm->tiles.row_start_sb[row]
-                     << cm->seq_params.mib_size_log2;
-  int mi_row_end = cm->tiles.row_start_sb[row + 1]
-                   << cm->seq_params.mib_size_log2;
+  int mi_row_start = cm->tiles.row_start_sb[row] << cm->mib_size_log2;
+  int mi_row_end = cm->tiles.row_start_sb[row + 1] << cm->mib_size_log2;
   tile->tile_row = row;
   tile->mi_row_start = mi_row_start;
   tile->mi_row_end = AOMMIN(mi_row_end, cm->mi_params.mi_rows);
@@ -142,10 +137,8 @@
 
 void av1_tile_set_col(TileInfo *tile, const AV1_COMMON *cm, int col) {
   assert(col < cm->tiles.cols);
-  int mi_col_start = cm->tiles.col_start_sb[col]
-                     << cm->seq_params.mib_size_log2;
-  int mi_col_end = cm->tiles.col_start_sb[col + 1]
-                   << cm->seq_params.mib_size_log2;
+  int mi_col_start = cm->tiles.col_start_sb[col] << cm->mib_size_log2;
+  int mi_col_end = cm->tiles.col_start_sb[col + 1] << cm->mib_size_log2;
   tile->tile_col = col;
   tile->mi_col_start = mi_col_start;
   tile->mi_col_end = AOMMIN(mi_col_end, cm->mi_params.mi_cols);
@@ -154,16 +147,16 @@
 
 int av1_get_sb_rows_in_tile(AV1_COMMON *cm, TileInfo tile) {
   int mi_rows_aligned_to_sb = ALIGN_POWER_OF_TWO(
-      tile.mi_row_end - tile.mi_row_start, cm->seq_params.mib_size_log2);
-  int sb_rows = mi_rows_aligned_to_sb >> cm->seq_params.mib_size_log2;
+      tile.mi_row_end - tile.mi_row_start, cm->mib_size_log2);
+  int sb_rows = mi_rows_aligned_to_sb >> cm->mib_size_log2;
 
   return sb_rows;
 }
 
 int av1_get_sb_cols_in_tile(AV1_COMMON *cm, TileInfo tile) {
   int mi_cols_aligned_to_sb = ALIGN_POWER_OF_TWO(
-      tile.mi_col_end - tile.mi_col_start, cm->seq_params.mib_size_log2);
-  int sb_cols = mi_cols_aligned_to_sb >> cm->seq_params.mib_size_log2;
+      tile.mi_col_end - tile.mi_col_start, cm->mib_size_log2);
+  int sb_cols = mi_cols_aligned_to_sb >> cm->mib_size_log2;
 
   return sb_cols;
 }
@@ -216,7 +209,7 @@
     for (int i = 0; i < tiles->cols; ++i) {
       const int tile_width_sb =
           tiles->col_start_sb[i + 1] - tiles->col_start_sb[i];
-      const int tile_w = tile_width_sb * cm->seq_params.mib_size;
+      const int tile_w = tile_width_sb * cm->mib_size;
       assert(i == 0 || tile_w == *w);  // ensure all tiles have same dimension
       *w = tile_w;
     }
@@ -224,7 +217,7 @@
     for (int i = 0; i < tiles->rows; ++i) {
       const int tile_height_sb =
           tiles->row_start_sb[i + 1] - tiles->row_start_sb[i];
-      const int tile_h = tile_height_sb * cm->seq_params.mib_size;
+      const int tile_h = tile_height_sb * cm->mib_size;
       assert(i == 0 || tile_h == *h);  // ensure all tiles have same dimension
       *h = tile_h;
     }
diff --git a/av1/common/tile_common.h b/av1/common/tile_common.h
index 5bbea5f..e258e75 100644
--- a/av1/common/tile_common.h
+++ b/av1/common/tile_common.h
@@ -59,11 +59,10 @@
 
 void av1_get_uniform_tile_size(const struct AV1Common *cm, int *w, int *h);
 void av1_get_tile_limits(struct AV1Common *const cm);
-void av1_calculate_tile_cols(const struct SequenceHeader *const seq_params,
-                             int cm_mi_rows, int cm_mi_cols,
+void av1_calculate_tile_cols(const struct AV1Common *cm, int cm_mi_rows,
+                             int cm_mi_cols,
                              struct CommonTileParams *const tiles);
-void av1_calculate_tile_rows(const struct SequenceHeader *const seq_params,
-                             int cm_mi_rows,
+void av1_calculate_tile_rows(const struct AV1Common *cm, int cm_mi_rows,
                              struct CommonTileParams *const tiles);
 
 // Checks if the minimum tile_width requirement is satisfied
diff --git a/av1/common/tip.c b/av1/common/tip.c
index d8eb15d..c427a4e 100644
--- a/av1/common/tip.c
+++ b/av1/common/tip.c
@@ -812,7 +812,8 @@
   const int comp_bw = bw >> ss_x;
   const int comp_bh = bh >> ss_y;
 
-  MB_MODE_INFO *mbmi = aom_calloc(1, sizeof(*mbmi));
+  MB_MODE_INFO mbmi_buf;
+  MB_MODE_INFO *mbmi = &mbmi_buf;
 
   int_mv mv_refined[2 * 4];
 
@@ -982,7 +983,6 @@
   }
 
   xd->tmp_conv_dst = org_buf;
-  aom_free(mbmi);
 }
 #endif  // CONFIG_OPTFLOW_ON_TIP || CONFIG_REFINEMV
 
diff --git a/av1/common/x86/reconinter_avx2.c b/av1/common/x86/reconinter_avx2.c
index d11eb7e..e342787 100644
--- a/av1/common/x86/reconinter_avx2.c
+++ b/av1/common/x86/reconinter_avx2.c
@@ -165,7 +165,7 @@
       mask += 64;
       i += 1;
     } while (i < h);
-  } else {
+  } else if (w == 128) {
     do {
       const __m256i s0A = yy_loadu_256(src0);
       const __m256i s0B = yy_loadu_256(src0 + 16);
@@ -212,6 +212,64 @@
       mask += 128;
       i += 1;
     } while (i < h);
+  } else {
+#if CONFIG_BLOCK_256
+    assert(w == 256);
+    do {
+      const CONV_BUF_TYPE *src0_ptr = src0;
+      const CONV_BUF_TYPE *src1_ptr = src1;
+      for (int loop = 0; loop < 2; loop++) {
+        const __m256i s0A = yy_loadu_256(src0_ptr);
+        const __m256i s0B = yy_loadu_256(src0_ptr + 16);
+        const __m256i s0C = yy_loadu_256(src0_ptr + 32);
+        const __m256i s0D = yy_loadu_256(src0_ptr + 48);
+        const __m256i s0E = yy_loadu_256(src0_ptr + 64);
+        const __m256i s0F = yy_loadu_256(src0_ptr + 80);
+        const __m256i s0G = yy_loadu_256(src0_ptr + 96);
+        const __m256i s0H = yy_loadu_256(src0_ptr + 112);
+        const __m256i s1A = yy_loadu_256(src1_ptr);
+        const __m256i s1B = yy_loadu_256(src1_ptr + 16);
+        const __m256i s1C = yy_loadu_256(src1_ptr + 32);
+        const __m256i s1D = yy_loadu_256(src1_ptr + 48);
+        const __m256i s1E = yy_loadu_256(src1_ptr + 64);
+        const __m256i s1F = yy_loadu_256(src1_ptr + 80);
+        const __m256i s1G = yy_loadu_256(src1_ptr + 96);
+        const __m256i s1H = yy_loadu_256(src1_ptr + 112);
+        const __m256i m16A =
+            calc_mask_d16_avx2(&s0A, &s1A, &_r, &y38, &y64, shift);
+        const __m256i m16B =
+            calc_mask_d16_avx2(&s0B, &s1B, &_r, &y38, &y64, shift);
+        const __m256i m16C =
+            calc_mask_d16_avx2(&s0C, &s1C, &_r, &y38, &y64, shift);
+        const __m256i m16D =
+            calc_mask_d16_avx2(&s0D, &s1D, &_r, &y38, &y64, shift);
+        const __m256i m16E =
+            calc_mask_d16_avx2(&s0E, &s1E, &_r, &y38, &y64, shift);
+        const __m256i m16F =
+            calc_mask_d16_avx2(&s0F, &s1F, &_r, &y38, &y64, shift);
+        const __m256i m16G =
+            calc_mask_d16_avx2(&s0G, &s1G, &_r, &y38, &y64, shift);
+        const __m256i m16H =
+            calc_mask_d16_avx2(&s0H, &s1H, &_r, &y38, &y64, shift);
+        const __m256i m8AB = _mm256_packus_epi16(m16A, m16B);
+        const __m256i m8CD = _mm256_packus_epi16(m16C, m16D);
+        const __m256i m8EF = _mm256_packus_epi16(m16E, m16F);
+        const __m256i m8GH = _mm256_packus_epi16(m16G, m16H);
+        yy_storeu_256(mask, _mm256_permute4x64_epi64(m8AB, 0xd8));
+        yy_storeu_256(mask + 32, _mm256_permute4x64_epi64(m8CD, 0xd8));
+        yy_storeu_256(mask + 64, _mm256_permute4x64_epi64(m8EF, 0xd8));
+        yy_storeu_256(mask + 96, _mm256_permute4x64_epi64(m8GH, 0xd8));
+        src0_ptr += 128;
+        src1_ptr += 128;
+        mask += 128;
+      }
+      src0 += src0_stride;
+      src1 += src1_stride;
+      i += 1;
+    } while (i < h);
+#else
+    assert(0);
+#endif  // CONFIG_BLOCK_256
   }
 }
 
@@ -327,7 +385,7 @@
       mask += 64;
       i += 1;
     } while (i < h);
-  } else {
+  } else if (w == 128) {
     do {
       const __m256i s0A = yy_loadu_256(src0);
       const __m256i s0B = yy_loadu_256(src0 + 16);
@@ -374,6 +432,64 @@
       mask += 128;
       i += 1;
     } while (i < h);
+  } else {
+#if CONFIG_BLOCK_256
+    assert(w == 256);
+    do {
+      const CONV_BUF_TYPE *src0_ptr = src0;
+      const CONV_BUF_TYPE *src1_ptr = src1;
+      for (int loop = 0; loop < 2; loop++) {
+        const __m256i s0A = yy_loadu_256(src0_ptr);
+        const __m256i s0B = yy_loadu_256(src0_ptr + 16);
+        const __m256i s0C = yy_loadu_256(src0_ptr + 32);
+        const __m256i s0D = yy_loadu_256(src0_ptr + 48);
+        const __m256i s0E = yy_loadu_256(src0_ptr + 64);
+        const __m256i s0F = yy_loadu_256(src0_ptr + 80);
+        const __m256i s0G = yy_loadu_256(src0_ptr + 96);
+        const __m256i s0H = yy_loadu_256(src0_ptr + 112);
+        const __m256i s1A = yy_loadu_256(src1_ptr);
+        const __m256i s1B = yy_loadu_256(src1_ptr + 16);
+        const __m256i s1C = yy_loadu_256(src1_ptr + 32);
+        const __m256i s1D = yy_loadu_256(src1_ptr + 48);
+        const __m256i s1E = yy_loadu_256(src1_ptr + 64);
+        const __m256i s1F = yy_loadu_256(src1_ptr + 80);
+        const __m256i s1G = yy_loadu_256(src1_ptr + 96);
+        const __m256i s1H = yy_loadu_256(src1_ptr + 112);
+        const __m256i m16A =
+            calc_mask_d16_inv_avx2(&s0A, &s1A, &_r, &y38, &y64, shift);
+        const __m256i m16B =
+            calc_mask_d16_inv_avx2(&s0B, &s1B, &_r, &y38, &y64, shift);
+        const __m256i m16C =
+            calc_mask_d16_inv_avx2(&s0C, &s1C, &_r, &y38, &y64, shift);
+        const __m256i m16D =
+            calc_mask_d16_inv_avx2(&s0D, &s1D, &_r, &y38, &y64, shift);
+        const __m256i m16E =
+            calc_mask_d16_inv_avx2(&s0E, &s1E, &_r, &y38, &y64, shift);
+        const __m256i m16F =
+            calc_mask_d16_inv_avx2(&s0F, &s1F, &_r, &y38, &y64, shift);
+        const __m256i m16G =
+            calc_mask_d16_inv_avx2(&s0G, &s1G, &_r, &y38, &y64, shift);
+        const __m256i m16H =
+            calc_mask_d16_inv_avx2(&s0H, &s1H, &_r, &y38, &y64, shift);
+        const __m256i m8AB = _mm256_packus_epi16(m16A, m16B);
+        const __m256i m8CD = _mm256_packus_epi16(m16C, m16D);
+        const __m256i m8EF = _mm256_packus_epi16(m16E, m16F);
+        const __m256i m8GH = _mm256_packus_epi16(m16G, m16H);
+        yy_storeu_256(mask, _mm256_permute4x64_epi64(m8AB, 0xd8));
+        yy_storeu_256(mask + 32, _mm256_permute4x64_epi64(m8CD, 0xd8));
+        yy_storeu_256(mask + 64, _mm256_permute4x64_epi64(m8EF, 0xd8));
+        yy_storeu_256(mask + 96, _mm256_permute4x64_epi64(m8GH, 0xd8));
+        src0_ptr += 128;
+        src1_ptr += 128;
+        mask += 128;
+      }
+      src0 += src0_stride;
+      src1 += src1_stride;
+      i += 1;
+    } while (i < h);
+#else
+    assert(0);
+#endif  // CONFIG_BLOCK_256
   }
 }
 
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index a3ce14d..5554240 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -13,6 +13,7 @@
 #include <assert.h>
 #include <stddef.h>
 
+#include "av1/common/av1_common_int.h"
 #include "av1/common/blockd.h"
 #include "av1/common/enums.h"
 #include "config/aom_config.h"
@@ -1811,7 +1812,7 @@
   }
 
   av1_visit_palette(pbi, xd, r, set_color_index_map_offset);
-  av1_mark_block_as_coded(xd, bsize, cm->seq_params.sb_size);
+  av1_mark_block_as_coded(xd, bsize, cm->sb_size);
 }
 
 static AOM_INLINE void set_inter_tx_size(MB_MODE_INFO *mbmi, int stride_log2,
@@ -2227,7 +2228,6 @@
       }
     }
   }
-  // av1_mark_block_as_coded(xd, bsize, cm->seq_params.sb_size);
 }
 
 static AOM_INLINE void set_offsets_for_pred_and_recon(
@@ -2339,10 +2339,6 @@
                                      const PARTITION_TREE *ptree_luma,
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
                                      BLOCK_SIZE bsize) {
-#if CONFIG_EXT_RECUR_PARTITIONS
-  if (!is_partition_point(bsize)) return PARTITION_NONE;
-#endif  // CONFIG_EXT_RECUR_PARTITIONS
-
   const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize);
   assert(ctx >= 0);
   FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
@@ -2353,24 +2349,30 @@
   const int plane = xd->tree_type == CHROMA_PART;
   const int ssx = cm->seq_params.subsampling_x;
   const int ssy = cm->seq_params.subsampling_y;
-  if (plane == 1 && bsize == BLOCK_8X8) {
-    return PARTITION_NONE;
+  const PARTITION_TYPE derived_partition =
+      av1_get_normative_forced_partition_type(
+          &cm->mi_params, xd->tree_type, ssx, ssy, mi_row, mi_col, bsize,
+          ptree_luma, &ptree->chroma_ref_info);
+  if (derived_partition != PARTITION_INVALID) {
+    return derived_partition;
   }
-  if (is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize)) {
-    return sdp_chroma_part_from_luma(bsize, ptree_luma->partition, ssx, ssy);
-  }
-
-  PARTITION_TYPE implied_partition;
-  const bool is_part_implied = is_partition_implied_at_boundary(
-      &cm->mi_params, xd->tree_type, ssx, ssy, mi_row, mi_col, bsize,
-      &ptree->chroma_ref_info, &implied_partition);
-  if (is_part_implied) return implied_partition;
 
   const bool do_split = aom_read_symbol(r, ec_ctx->do_split_cdf[plane][ctx], 2,
                                         ACCT_INFO("do_split"));
   if (!do_split) {
     return PARTITION_NONE;
   }
+#if CONFIG_BLOCK_256
+  const int square_split_ctx = square_split_context(xd, mi_row, mi_col, bsize);
+  if (is_square_split_eligible(bsize, cm->sb_size)) {
+    const bool do_square_split =
+        aom_read_symbol(r, ec_ctx->do_square_split_cdf[plane][square_split_ctx],
+                        2, ACCT_INFO("do_square_split"));
+    if (do_square_split) {
+      return PARTITION_SPLIT;
+    }
+  }
+#endif  // CONFIG_BLOCK_256
 
   RECT_PART_TYPE rect_type = rect_type_implied_by_bsize(bsize, xd->tree_type);
   if (rect_type == RECT_INVALID) {
@@ -2470,7 +2472,7 @@
 #endif
                                         PARTITION_TREE *ptree,
 #if CONFIG_EXT_RECUR_PARTITIONS
-                                        PARTITION_TREE *ptree_luma,
+                                        const PARTITION_TREE *ptree_luma,
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
                                         int parse_decode_flag) {
   assert(bsize < BLOCK_SIZES_ALL);
@@ -2507,7 +2509,7 @@
                                                      decode_block,
                                                      parse_decode_block };
 #if CONFIG_FLEX_MVRES
-  const int is_sb_root = bsize == cm->seq_params.sb_size;
+  const int is_sb_root = bsize == cm->sb_size;
 #endif
 
   if (parse_decode_flag & 1) {
@@ -2558,6 +2560,13 @@
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
                              bsize);
 
+#if CONFIG_EXT_RECUR_PARTITIONS
+    if (!is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma,
+                                             bsize)) {
+      ptree_luma = NULL;
+    }
+#endif  // CONFIG_EXT_RECUR_PARTITIONS
+
     ptree->partition = partition;
 
     switch (partition) {
@@ -2596,8 +2605,10 @@
   const BLOCK_SIZE subsize = get_partition_subsize(bsize, partition);
   if (subsize == BLOCK_INVALID) {
     aom_internal_error(xd->error_info, AOM_CODEC_CORRUPT_FRAME,
-                       "Partition is invalid for block size %dx%d",
-                       block_size_wide[bsize], block_size_high[bsize]);
+                       "Partition %d is invalid for block size %dx%d",
+                       partition, block_size_wide[bsize],
+                       block_size_high[bsize]);
+    assert(0);
   }
   // Check the bitstream is conformant: if there is subsampling on the
   // chroma planes, subsize must subsample to a valid block size.
@@ -2627,9 +2638,6 @@
                        block_size_wide[test_subsize],
                        block_size_high[test_subsize]);
   }
-
-  const int track_ptree_luma =
-      is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize);
 #else
   if (get_plane_block_size(subsize, pd_u->subsampling_x, pd_u->subsampling_y) ==
       BLOCK_INVALID) {
@@ -2646,10 +2654,10 @@
                                  reader, DEC_BLOCK_EPT_ARG(db_subsize), ptree, \
                                  index)
 #if CONFIG_FLEX_MVRES && CONFIG_EXT_RECUR_PARTITIONS
-#define DEC_PARTITION(db_r, db_c, db_subsize, index)                      \
-  decode_partition(pbi, td, DEC_BLOCK_STX_ARG(db_r), (db_c), reader,      \
-                   (db_subsize), sbi, ptree->sub_tree[(index)],           \
-                   track_ptree_luma ? ptree_luma->sub_tree[index] : NULL, \
+#define DEC_PARTITION(db_r, db_c, db_subsize, index)                 \
+  decode_partition(pbi, td, DEC_BLOCK_STX_ARG(db_r), (db_c), reader, \
+                   (db_subsize), sbi, ptree->sub_tree[(index)],      \
+                   get_partition_subtree_const(ptree_luma, index),   \
                    parse_decode_flag)
 #elif CONFIG_FLEX_MVRES
 #define DEC_PARTITION(db_r, db_c, db_subsize, index)                 \
@@ -2657,10 +2665,10 @@
                    (db_subsize), sbi, ptree->sub_tree[(index)],      \
                    parse_decode_flag)
 #elif CONFIG_EXT_RECUR_PARTITIONS
-#define DEC_PARTITION(db_r, db_c, db_subsize, index)                      \
-  decode_partition(pbi, td, DEC_BLOCK_STX_ARG(db_r), (db_c), reader,      \
-                   (db_subsize), ptree->sub_tree[(index)],                \
-                   track_ptree_luma ? ptree_luma->sub_tree[index] : NULL, \
+#define DEC_PARTITION(db_r, db_c, db_subsize, index)                 \
+  decode_partition(pbi, td, DEC_BLOCK_STX_ARG(db_r), (db_c), reader, \
+                   (db_subsize), ptree->sub_tree[(index)],           \
+                   get_partition_subtree_const(ptree_luma, index),   \
                    parse_decode_flag)
 #else
 #define DEC_PARTITION(db_r, db_c, db_subsize, index)                 \
@@ -2770,7 +2778,6 @@
       break;
     }
 #endif  // CONFIG_UNEVEN_4WAY
-
     case PARTITION_HORZ_3:
     case PARTITION_VERT_3: {
       for (int i = 0; i < 4; ++i) {
@@ -2793,6 +2800,12 @@
       }
       break;
     }
+    case PARTITION_SPLIT:
+      DEC_PARTITION(mi_row, mi_col, subsize, 0);
+      DEC_PARTITION(mi_row, mi_col + hbs_w, subsize, 1);
+      DEC_PARTITION(mi_row + hbs_h, mi_col, subsize, 2);
+      DEC_PARTITION(mi_row + hbs_h, mi_col + hbs_w, subsize, 3);
+      break;
 #else   // !CONFIG_EXT_RECUR_PARTITIONS
     case PARTITION_SPLIT:
       DEC_PARTITION(mi_row, mi_col, subsize, 0);
@@ -3166,21 +3179,41 @@
   }
 #else
   if (!all_none) {
-    assert(cm->seq_params.sb_size == BLOCK_64X64 ||
-           cm->seq_params.sb_size == BLOCK_128X128);
-    const int sb_size = cm->seq_params.sb_size == BLOCK_128X128 ? 128 : 64;
+#if CONFIG_BLOCK_256
+    assert(cm->sb_size == BLOCK_64X64 || cm->sb_size == BLOCK_128X128 ||
+           cm->sb_size == BLOCK_256X256);
+#else
+    assert(cm->sb_size == BLOCK_64X64 || cm->sb_size == BLOCK_128X128);
+#endif  // CONFIG_BLOCK_256
+    const int sb_size =
+#if CONFIG_BLOCK_256
+        cm->sb_size == BLOCK_256X256 ? 256 :
+#endif  // CONFIG_BLOCK_256
+        cm->sb_size == BLOCK_128X128 ? 128
+                                     : 64;
 
     for (int p = 0; p < num_planes; ++p)
       cm->rst_info[p].restoration_unit_size = sb_size;
 
     RestorationInfo *rsi = &cm->rst_info[0];
 
+#if CONFIG_BLOCK_256
+    if (sb_size <= 128) {
+      rsi->restoration_unit_size <<= aom_rb_read_bit(rb);
+    }
     if (sb_size == 64) {
       rsi->restoration_unit_size <<= aom_rb_read_bit(rb);
     }
+#else
+    if (sb_size == 64) {
+      rsi->restoration_unit_size <<= aom_rb_read_bit(rb);
+    }
+    // TODO(any): We could save a bit by adding a special case for sb_size ==
+    // 128
     if (rsi->restoration_unit_size > 64) {
       rsi->restoration_unit_size <<= aom_rb_read_bit(rb);
     }
+#endif  // CONFIG_BLOCK_256
   } else {
     const int size = RESTORATION_UNITSIZE_MAX;
     for (int p = 0; p < num_planes; ++p)
@@ -4078,9 +4111,26 @@
   setup_buffer_pool(cm);
 }
 
-static AOM_INLINE void setup_sb_size(SequenceHeader *seq_params,
-                                     struct aom_read_bit_buffer *rb) {
-  set_sb_size(seq_params, aom_rb_read_bit(rb) ? BLOCK_128X128 : BLOCK_64X64);
+static AOM_INLINE void setup_seq_sb_size(SequenceHeader *seq_params,
+                                         struct aom_read_bit_buffer *rb) {
+  BLOCK_SIZE sb_size = BLOCK_INVALID;
+#if CONFIG_BLOCK_256
+  bool is_256 = aom_rb_read_bit(rb);
+  if (is_256) {
+    sb_size = BLOCK_256X256;
+  } else {
+#endif  // CONFIG_BLOCK_256
+    if (aom_rb_read_bit(rb)) {
+      sb_size = BLOCK_128X128;
+    } else {
+      sb_size = BLOCK_64X64;
+    }
+#if CONFIG_BLOCK_256
+  }
+#endif  // CONFIG_BLOCK_256
+  seq_params->sb_size = sb_size;
+  seq_params->mib_size = mi_size_wide[sb_size];
+  seq_params->mib_size_log2 = mi_size_wide_log2[sb_size];
 }
 
 static INLINE int valid_ref_frame_img_fmt(aom_bit_depth_t ref_bit_depth,
@@ -4161,14 +4211,11 @@
 
 static AOM_INLINE void read_tile_info_max_tile(
     AV1_COMMON *const cm, struct aom_read_bit_buffer *const rb) {
-  const SequenceHeader *const seq_params = &cm->seq_params;
   CommonTileParams *const tiles = &cm->tiles;
-  int width_mi =
-      ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, seq_params->mib_size_log2);
-  int height_mi =
-      ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, seq_params->mib_size_log2);
-  int width_sb = width_mi >> seq_params->mib_size_log2;
-  int height_sb = height_mi >> seq_params->mib_size_log2;
+  int width_mi = ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, cm->mib_size_log2);
+  int height_mi = ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->mib_size_log2);
+  int width_sb = width_mi >> cm->mib_size_log2;
+  int height_sb = height_mi >> cm->mib_size_log2;
 
   av1_get_tile_limits(cm);
   tiles->uniform_spacing = aom_rb_read_bit(rb);
@@ -4195,8 +4242,8 @@
     tiles->cols = i;
     tiles->col_start_sb[i] = start_sb + width_sb;
   }
-  av1_calculate_tile_cols(seq_params, cm->mi_params.mi_rows,
-                          cm->mi_params.mi_cols, tiles);
+  av1_calculate_tile_cols(cm, cm->mi_params.mi_rows, cm->mi_params.mi_cols,
+                          tiles);
 
   // Read tile rows
   if (tiles->uniform_spacing) {
@@ -4220,7 +4267,7 @@
     tiles->rows = i;
     tiles->row_start_sb[i] = start_sb + height_sb;
   }
-  av1_calculate_tile_rows(seq_params, cm->mi_params.mi_rows, tiles);
+  av1_calculate_tile_rows(cm, cm->mi_params.mi_rows, tiles);
 }
 
 void av1_set_single_tile_decoding_mode(AV1_COMMON *const cm) {
@@ -4509,7 +4556,7 @@
                                      const int num_planes, int mi_row,
                                      int mi_col) {
   AV1_COMMON *const cm = &pbi->common;
-  int mib_size_log2 = cm->seq_params.mib_size_log2;
+  int mib_size_log2 = cm->mib_size_log2;
   int stride = (cm->mi_params.mi_cols >> mib_size_log2) + 1;
   int offset = (mi_row >> mib_size_log2) * stride + (mi_col >> mib_size_log2);
   CB_BUFFER *cb_buffer = cb_buffer_base + offset;
@@ -4686,12 +4733,12 @@
       pbi->tile_data + tile_info.tile_row * cm->tiles.cols + tile_info.tile_col;
   const int sb_cols_in_tile = av1_get_sb_cols_in_tile(cm, tile_info);
   const int sb_row_in_tile =
-      (mi_row - tile_info.mi_row_start) >> cm->seq_params.mib_size_log2;
+      (mi_row - tile_info.mi_row_start) >> cm->mib_size_log2;
   int sb_col_in_tile = 0;
 
   for (int mi_col = tile_info.mi_col_start; mi_col < tile_info.mi_col_end;
-       mi_col += cm->seq_params.mib_size, sb_col_in_tile++) {
-    av1_reset_is_mi_coded_map(&td->dcb.xd, cm->seq_params.mib_size);
+       mi_col += cm->mib_size, sb_col_in_tile++) {
+    av1_reset_is_mi_coded_map(&td->dcb.xd, cm->mib_size);
     td->dcb.xd.sbi = av1_get_sb_info(cm, mi_row, mi_col);
     set_cb_buffer(pbi, &td->dcb, pbi->cb_buffer_base, num_planes, mi_row,
                   mi_col);
@@ -4712,8 +4759,8 @@
 #endif  // CONFIG_WARP_REF_LIST
 
     // Decoding of the super-block
-    decode_partition_sb(pbi, td, mi_row, mi_col, td->bit_reader,
-                        cm->seq_params.sb_size, 0x2);
+    decode_partition_sb(pbi, td, mi_row, mi_col, td->bit_reader, cm->sb_size,
+                        0x2);
 
     sync_write(&tile_data->dec_row_mt_sync, sb_row_in_tile, sb_col_in_tile,
                sb_cols_in_tile);
@@ -4799,7 +4846,7 @@
   );
 
   for (int mi_row = tile_info.mi_row_start; mi_row < tile_info.mi_row_end;
-       mi_row += cm->seq_params.mib_size) {
+       mi_row += cm->mib_size) {
     av1_zero_left_context(xd);
 #if CONFIG_REF_MV_BANK
     av1_zero(xd->ref_mv_bank);
@@ -4816,8 +4863,8 @@
 #endif  // CONFIG_WARP_REF_LIST
 
     for (int mi_col = tile_info.mi_col_start; mi_col < tile_info.mi_col_end;
-         mi_col += cm->seq_params.mib_size) {
-      av1_reset_is_mi_coded_map(xd, cm->seq_params.mib_size);
+         mi_col += cm->mib_size) {
+      av1_reset_is_mi_coded_map(xd, cm->mib_size);
       av1_set_sb_info(cm, xd, mi_row, mi_col);
       set_cb_buffer(pbi, dcb, &td->cb_buffer_base, num_planes, 0, 0);
 #if CONFIG_REF_MV_BANK
@@ -4836,8 +4883,8 @@
       td->warp_param_bank = xd->warp_param_bank;
 #endif  //! WARP_CU_BANK
 #endif  // CONFIG_WARP_REF_LIST
-      decode_partition_sb(pbi, td, mi_row, mi_col, td->bit_reader,
-                          cm->seq_params.sb_size, 0x3);
+      decode_partition_sb(pbi, td, mi_row, mi_col, td->bit_reader, cm->sb_size,
+                          0x3);
 
       if (aom_reader_has_overflowed(td->bit_reader)) {
         aom_merge_corrupted_flag(&dcb->corrupted, 1);
@@ -4991,7 +5038,7 @@
         continue;
 
       td->bit_reader = &tile_data->bit_reader;
-      av1_zero(td->cb_buffer_base.dqcoeff);
+      // av1_zero(td->cb_buffer_base.dqcoeff);
       av1_tile_init(&td->dcb.xd.tile, cm, row, col);
       td->dcb.xd.current_base_qindex = cm->quant_params.base_qindex;
       setup_bool_decoder(tile_bs_buf->data, data_end, tile_bs_buf->size,
@@ -5179,7 +5226,7 @@
   const int tile_cols_end = frame_row_mt_info->tile_cols_end;
   const int start_tile = frame_row_mt_info->start_tile;
   const int end_tile = frame_row_mt_info->end_tile;
-  const int sb_mi_size = mi_size_wide[cm->seq_params.sb_size];
+  const int sb_mi_size = mi_size_wide[cm->sb_size];
   int num_mis_to_decode, num_threads_working;
   int num_mis_waiting_for_decode;
   int min_threads_working = INT_MAX;
@@ -5297,7 +5344,7 @@
 static AOM_INLINE void parse_tile_row_mt(AV1Decoder *pbi, ThreadData *const td,
                                          TileDataDec *const tile_data) {
   AV1_COMMON *const cm = &pbi->common;
-  const int sb_mi_size = mi_size_wide[cm->seq_params.sb_size];
+  const int sb_mi_size = mi_size_wide[cm->sb_size];
   const int num_planes = av1_num_planes(cm);
   TileInfo tile_info = tile_data->tile_info;
   int tile_row = tile_info.tile_row;
@@ -5320,7 +5367,7 @@
   );
 
   for (int mi_row = tile_info.mi_row_start; mi_row < tile_info.mi_row_end;
-       mi_row += cm->seq_params.mib_size) {
+       mi_row += cm->mib_size) {
     av1_zero_left_context(xd);
 #if CONFIG_REF_MV_BANK
     av1_zero(xd->ref_mv_bank);
@@ -5337,8 +5384,8 @@
 #endif  // CONFIG_WARP_REF_LIST
 
     for (int mi_col = tile_info.mi_col_start; mi_col < tile_info.mi_col_end;
-         mi_col += cm->seq_params.mib_size) {
-      av1_reset_is_mi_coded_map(xd, cm->seq_params.mib_size);
+         mi_col += cm->mib_size) {
+      av1_reset_is_mi_coded_map(xd, cm->mib_size);
       av1_set_sb_info(cm, xd, mi_row, mi_col);
       set_cb_buffer(pbi, dcb, pbi->cb_buffer_base, num_planes, mi_row, mi_col);
 
@@ -5356,8 +5403,8 @@
 #endif  //! WARP_CU_BANK
 #endif  // CONFIG_WARP_REF_LIST
       // Bit-stream parsing of the superblock
-      decode_partition_sb(pbi, td, mi_row, mi_col, td->bit_reader,
-                          cm->seq_params.sb_size, 0x1);
+      decode_partition_sb(pbi, td, mi_row, mi_col, td->bit_reader, cm->sb_size,
+                          0x1);
       if (aom_reader_has_overflowed(td->bit_reader)) {
         aom_merge_corrupted_flag(&dcb->corrupted, 1);
         return;
@@ -5816,8 +5863,8 @@
 
 static AOM_INLINE void dec_alloc_cb_buf(AV1Decoder *pbi) {
   AV1_COMMON *const cm = &pbi->common;
-  int size = ((cm->mi_params.mi_rows >> cm->seq_params.mib_size_log2) + 1) *
-             ((cm->mi_params.mi_cols >> cm->seq_params.mib_size_log2) + 1);
+  int size = ((cm->mi_params.mi_rows >> cm->mib_size_log2) + 1) *
+             ((cm->mi_params.mi_cols >> cm->mib_size_log2) + 1);
 
   if (pbi->cb_buffer_alloc_size < size) {
     av1_dec_free_cb_buf(pbi);
@@ -5859,12 +5906,10 @@
       tile_data->dec_row_mt_sync.mi_rows_parse_done = 0;
       tile_data->dec_row_mt_sync.mi_rows_decode_started = 0;
       tile_data->dec_row_mt_sync.num_threads_working = 0;
-      tile_data->dec_row_mt_sync.mi_rows =
-          ALIGN_POWER_OF_TWO(tile_info.mi_row_end - tile_info.mi_row_start,
-                             cm->seq_params.mib_size_log2);
-      tile_data->dec_row_mt_sync.mi_cols =
-          ALIGN_POWER_OF_TWO(tile_info.mi_col_end - tile_info.mi_col_start,
-                             cm->seq_params.mib_size_log2);
+      tile_data->dec_row_mt_sync.mi_rows = ALIGN_POWER_OF_TWO(
+          tile_info.mi_row_end - tile_info.mi_row_start, cm->mib_size_log2);
+      tile_data->dec_row_mt_sync.mi_cols = ALIGN_POWER_OF_TWO(
+          tile_info.mi_col_end - tile_info.mi_col_start, cm->mib_size_log2);
 
       frame_row_mt_info->mi_rows_to_decode +=
           tile_data->dec_row_mt_sync.mi_rows;
@@ -6387,7 +6432,7 @@
                          "Invalid frame_id_length");
   }
 
-  setup_sb_size(seq_params, rb);
+  setup_seq_sb_size(seq_params, rb);
 
   seq_params->enable_filter_intra = aom_rb_read_bit(rb);
   seq_params->enable_intra_edge_filter = aom_rb_read_bit(rb);
@@ -7109,6 +7154,8 @@
             : aom_rb_read_bit(rb);
   }
 
+  av1_set_frame_sb_size(cm, cm->seq_params.sb_size);
+
   if (current_frame->frame_type == KEY_FRAME && cm->show_frame) {
     /* All frames need to be marked as not valid for referencing */
     for (int i = 0; i < REF_FRAMES; i++) {
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index f0a98c0..50a768f 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -61,7 +61,7 @@
 
   // At the start of a superblock, mark that we haven't yet read CDEF strengths
   // for any of the CDEF units contained in this superblock.
-  const int sb_mask = (cm->seq_params.mib_size - 1);
+  const int sb_mask = (cm->mib_size - 1);
   const int mi_row_in_sb = (xd->mi_row & sb_mask);
   const int mi_col_in_sb = (xd->mi_col & sb_mask);
   if (mi_row_in_sb == 0 && mi_col_in_sb == 0) {
@@ -153,11 +153,11 @@
                              aom_reader *r, MB_MODE_INFO *const mbmi) {
   int sign, abs, reduced_delta_qindex = 0;
   BLOCK_SIZE bsize = mbmi->sb_type[xd->tree_type == CHROMA_PART];
-  const int b_col = xd->mi_col & (cm->seq_params.mib_size - 1);
-  const int b_row = xd->mi_row & (cm->seq_params.mib_size - 1);
+  const int b_col = xd->mi_col & (cm->mib_size - 1);
+  const int b_row = xd->mi_row & (cm->mib_size - 1);
   const int read_delta_q_flag = (b_col == 0 && b_row == 0);
   FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
-  if ((bsize != cm->seq_params.sb_size ||
+  if ((bsize != cm->sb_size ||
        mbmi->skip_txfm[xd->tree_type == CHROMA_PART] == 0) &&
       read_delta_q_flag) {
     abs = aom_read_symbol(r, ec_ctx->delta_q_cdf, DELTA_Q_PROBS + 1,
@@ -187,10 +187,10 @@
   int reduced_delta_lflevel = 0;
   const int plane_type = (tree_type == CHROMA_PART);
   const BLOCK_SIZE bsize = mbmi->sb_type[plane_type];
-  const int b_col = mi_col & (cm->seq_params.mib_size - 1);
-  const int b_row = mi_row & (cm->seq_params.mib_size - 1);
+  const int b_col = mi_col & (cm->mib_size - 1);
+  const int b_row = mi_row & (cm->mib_size - 1);
   const int read_delta_lf_flag = (b_col == 0 && b_row == 0);
-  if ((bsize != cm->seq_params.sb_size || mbmi->skip_txfm[plane_type] == 0) &&
+  if ((bsize != cm->sb_size || mbmi->skip_txfm[plane_type] == 0) &&
       read_delta_lf_flag) {
     int abs = aom_read_symbol(r, cdf, DELTA_LF_PROBS + 1, ACCT_INFO("abs"));
     const int smallval = (abs < DELTA_LF_SMALL);
@@ -1439,7 +1439,7 @@
   mv->as_mv.row = (mv->as_mv.row >> 3) * 8;
   int valid = is_mv_valid(&mv->as_mv) &&
               av1_is_dv_valid(mv->as_mv, cm, xd, mi_row, mi_col, bsize,
-                              cm->seq_params.mib_size_log2);
+                              cm->mib_size_log2);
   return valid;
 }
 
@@ -1558,7 +1558,7 @@
     int_mv dv_ref = nearestmv.as_int == 0 ? nearmv : nearestmv;
 #endif  // CONFIG_IBC_BV_IMPROVEMENT
     if (dv_ref.as_int == 0)
-      av1_find_ref_dv(&dv_ref, &xd->tile, cm->seq_params.mib_size, xd->mi_row);
+      av1_find_ref_dv(&dv_ref, &xd->tile, cm->mib_size, xd->mi_row);
     // Ref DV should not have sub-pel.
     int valid_dv = (dv_ref.as_mv.col & 7) == 0 && (dv_ref.as_mv.row & 7) == 0;
     dv_ref.as_mv.col = (dv_ref.as_mv.col >> 3) * 8;
diff --git a/av1/decoder/decoder.h b/av1/decoder/decoder.h
index 586d84c..cf4499f 100644
--- a/av1/decoder/decoder.h
+++ b/av1/decoder/decoder.h
@@ -73,7 +73,11 @@
    * cb_offset[p] is the offset into the dqcoeff_block[p] for the current coding
    * block, for each plane 'p'.
    */
+#if CONFIG_BLOCK_256
+  uint32_t cb_offset[MAX_MB_PLANE];
+#else
   uint16_t cb_offset[MAX_MB_PLANE];
+#endif  // CONFIG_BLOCK_256
   /*!
    * Pointer to 'eob_data' inside 'td->cb_buffer_base' or 'pbi->cb_buffer_base'
    * with appropriate offset for the current superblock, for each plane.
diff --git a/av1/decoder/obu.c b/av1/decoder/obu.c
index ebbaccf..507752d 100644
--- a/av1/decoder/obu.c
+++ b/av1/decoder/obu.c
@@ -269,6 +269,7 @@
   }
 
   cm->seq_params = *seq_params;
+  av1_set_frame_sb_size(cm, cm->seq_params.sb_size);
   pbi->sequence_header_ready = 1;
 
   return ((rb->bit_offset - saved_bit_offset + 7) >> 3);
diff --git a/av1/encoder/aq_complexity.c b/av1/encoder/aq_complexity.c
index bbf9a1e..1fff321 100644
--- a/av1/encoder/aq_complexity.c
+++ b/av1/encoder/aq_complexity.c
@@ -151,7 +151,7 @@
     // It is converted to bits << AV1_PROB_COST_SHIFT units.
     const int64_t num = (int64_t)(cpi->rc.sb64_target_rate * xmis * ymis)
                         << AV1_PROB_COST_SHIFT;
-    const int denom = cm->seq_params.mib_size * cm->seq_params.mib_size;
+    const int denom = cm->mib_size * cm->mib_size;
     const int target_rate = (int)(num / denom);
     double logvar;
     double low_var_thresh;
diff --git a/av1/encoder/aq_cyclicrefresh.c b/av1/encoder/aq_cyclicrefresh.c
index dec9b59..a7ce0c0 100644
--- a/av1/encoder/aq_cyclicrefresh.c
+++ b/av1/encoder/aq_cyclicrefresh.c
@@ -270,10 +270,8 @@
   int i, block_count, bl_index, sb_rows, sb_cols, sbs_in_frame;
   int xmis, ymis, x, y;
   memset(seg_map, CR_SEGMENT_ID_BASE, mi_params->mi_rows * mi_params->mi_cols);
-  sb_cols = (mi_params->mi_cols + cm->seq_params.mib_size - 1) /
-            cm->seq_params.mib_size;
-  sb_rows = (mi_params->mi_rows + cm->seq_params.mib_size - 1) /
-            cm->seq_params.mib_size;
+  sb_cols = (mi_params->mi_cols + cm->mib_size - 1) / cm->mib_size;
+  sb_rows = (mi_params->mi_rows + cm->mib_size - 1) / cm->mib_size;
   sbs_in_frame = sb_cols * sb_rows;
   // Number of target blocks to get the q delta (segment 1).
   block_count =
@@ -290,8 +288,8 @@
     // Get the mi_row/mi_col corresponding to superblock index i.
     int sb_row_index = (i / sb_cols);
     int sb_col_index = i - sb_row_index * sb_cols;
-    int mi_row = sb_row_index * cm->seq_params.mib_size;
-    int mi_col = sb_col_index * cm->seq_params.mib_size;
+    int mi_row = sb_row_index * cm->mib_size;
+    int mi_col = sb_col_index * cm->mib_size;
     // TODO(any): Ensure the population of
     // cpi->common.features.allow_screen_content_tools and use the same instead
     // of cpi->oxcf.tune_cfg.content == AOM_CONTENT_SCREEN
@@ -305,8 +303,8 @@
     assert(mi_col >= 0 && mi_col < mi_params->mi_cols);
     bl_index = mi_row * mi_params->mi_cols + mi_col;
     // Loop through all MI blocks in superblock and update map.
-    xmis = AOMMIN(mi_params->mi_cols - mi_col, cm->seq_params.mib_size);
-    ymis = AOMMIN(mi_params->mi_rows - mi_row, cm->seq_params.mib_size);
+    xmis = AOMMIN(mi_params->mi_cols - mi_col, cm->mib_size);
+    ymis = AOMMIN(mi_params->mi_rows - mi_row, cm->mib_size);
     for (y = 0; y < ymis; y++) {
       for (x = 0; x < xmis; x++) {
         const int bl_index2 = bl_index + y * mi_params->mi_cols + x;
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 2752709..19d0548 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -22,6 +22,7 @@
 #include "aom_ports/bitops.h"
 #include "aom_ports/mem_ops.h"
 #include "aom_ports/system_state.h"
+#include "av1/common/av1_common_int.h"
 #include "av1/common/blockd.h"
 #include "av1/common/enums.h"
 #if CONFIG_BITSTREAM_DEBUG
@@ -1550,7 +1551,7 @@
 #endif  // CONFIG_FIX_CDEF_SYNTAX
   // At the start of a superblock, mark that we haven't yet written CDEF
   // strengths for any of the CDEF units contained in this superblock.
-  const int sb_mask = (cm->seq_params.mib_size - 1);
+  const int sb_mask = (cm->mib_size - 1);
   const int mi_row_in_sb = (xd->mi_row & sb_mask);
   const int mi_col_in_sb = (xd->mi_col & sb_mask);
   if (mi_row_in_sb == 0 && mi_col_in_sb == 0) {
@@ -1680,11 +1681,10 @@
     const MB_MODE_INFO *const mbmi = xd->mi[0];
     const BLOCK_SIZE bsize = mbmi->sb_type[xd->tree_type == CHROMA_PART];
     const int super_block_upper_left =
-        ((xd->mi_row & (cm->seq_params.mib_size - 1)) == 0) &&
-        ((xd->mi_col & (cm->seq_params.mib_size - 1)) == 0);
+        ((xd->mi_row & (cm->mib_size - 1)) == 0) &&
+        ((xd->mi_col & (cm->mib_size - 1)) == 0);
 
-    if ((bsize != cm->seq_params.sb_size || skip == 0) &&
-        super_block_upper_left) {
+    if ((bsize != cm->sb_size || skip == 0) && super_block_upper_left) {
       assert(mbmi->current_qindex > 0);
       const int reduced_delta_qindex =
           (mbmi->current_qindex - xd->current_base_qindex) /
@@ -2858,7 +2858,7 @@
   const BLOCK_SIZE bsize = mbmi->sb_type[xd->tree_type == CHROMA_PART];
   if (xd->tree_type == SHARED_PART)
     assert(mbmi->sb_type[PLANE_TYPE_Y] == mbmi->sb_type[PLANE_TYPE_UV]);
-  assert(bsize <= cm->seq_params.sb_size ||
+  assert(bsize <= cm->sb_size ||
          (bsize >= BLOCK_SIZES && bsize < BLOCK_SIZES_ALL));
 
   const int bh = mi_size_high[bsize];
@@ -2970,7 +2970,7 @@
   }
 #endif  // CONFIG_PC_WIENER
 
-  av1_mark_block_as_coded(xd, bsize, cm->seq_params.sb_size);
+  av1_mark_block_as_coded(xd, bsize, cm->sb_size);
 }
 
 static AOM_INLINE void write_partition(const AV1_COMMON *const cm,
@@ -2982,27 +2982,21 @@
                                        const PARTITION_TREE *ptree_luma,
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
                                        aom_writer *w) {
-  if (!is_partition_point(bsize)) return;
-
   const int plane = xd->tree_type == CHROMA_PART;
+#if !CONFIG_EXT_RECUR_PARTITIONS
+  if (!is_partition_point(bsize)) return;
   if (bsize == BLOCK_8X8 && plane > 0) return;
+#endif  // !CONFIG_EXT_RECUR_PARTITIONS
 
 #if CONFIG_EXT_RECUR_PARTITIONS
   const int ssx = cm->seq_params.subsampling_x;
   const int ssy = cm->seq_params.subsampling_y;
-  if (is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize)) {
-    assert(ptree_luma);
-    assert(p ==
-           sdp_chroma_part_from_luma(bsize, ptree_luma->partition, ssx, ssy));
-    return;
-  }
-
-  PARTITION_TYPE implied_partition;
-  const bool is_part_implied = is_partition_implied_at_boundary(
-      &cm->mi_params, xd->tree_type, ssx, ssy, mi_row, mi_col, bsize,
-      &ptree->chroma_ref_info, &implied_partition);
-  if (is_part_implied) {
-    assert(p == implied_partition);
+  const PARTITION_TYPE derived_partition =
+      av1_get_normative_forced_partition_type(
+          &cm->mi_params, xd->tree_type, ssx, ssy, mi_row, mi_col, bsize,
+          ptree_luma, &ptree->chroma_ref_info);
+  if (derived_partition != PARTITION_INVALID) {
+    assert(p == derived_partition);
     return;
   }
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
@@ -3016,6 +3010,19 @@
   if (!do_split) {
     return;
   }
+#if CONFIG_BLOCK_256
+  const bool do_square_split = p == PARTITION_SPLIT;
+  if (is_square_split_eligible(bsize, cm->sb_size)) {
+    const int square_split_ctx =
+        square_split_context(xd, mi_row, mi_col, bsize);
+    aom_write_symbol(w, do_square_split,
+                     ec_ctx->do_square_split_cdf[plane][square_split_ctx], 2);
+  }
+  if (do_square_split) {
+    assert(p == PARTITION_SPLIT);
+    return;
+  }
+#endif  // CONFIG_BLOCK_256
   RECT_PART_TYPE rect_type = get_rect_part_type(p);
   if (rect_type_implied_by_bsize(bsize, xd->tree_type) == RECT_INVALID) {
     aom_write_symbol(w, rect_type, ec_ctx->rect_type_cdf[plane][ctx],
@@ -3096,7 +3103,7 @@
     const TokenExtra **tok, const TokenExtra *const tok_end,
     PARTITION_TREE *ptree,
 #if CONFIG_EXT_RECUR_PARTITIONS
-    PARTITION_TREE *ptree_luma,
+    const PARTITION_TREE *ptree_luma,
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
     int mi_row, int mi_col, BLOCK_SIZE bsize) {
   const AV1_COMMON *const cm = &cpi->common;
@@ -3151,6 +3158,9 @@
                   w);
   const int track_ptree_luma =
       is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize);
+  if (!track_ptree_luma) {
+    ptree_luma = NULL;
+  }
   assert(IMPLIES(track_ptree_luma, ptree_luma));
 #else
   write_partition(cm, xd, mi_row, mi_col, partition, bsize, w);
@@ -3162,11 +3172,11 @@
     case PARTITION_HORZ:
 #if CONFIG_EXT_RECUR_PARTITIONS
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
-                     track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
-                     mi_col, subsize);
+                     get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+                     subsize);
       if (mi_row + hbs_h < mi_params->mi_rows) {
         write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
-                       track_ptree_luma ? ptree_luma->sub_tree[1] : NULL,
+                       get_partition_subtree_const(ptree_luma, 1),
                        mi_row + hbs_h, mi_col, subsize);
       }
 #else   // CONFIG_EXT_RECUR_PARTITIONS
@@ -3178,12 +3188,12 @@
     case PARTITION_VERT:
 #if CONFIG_EXT_RECUR_PARTITIONS
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
-                     track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
-                     mi_col, subsize);
+                     get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+                     subsize);
       if (mi_col + hbs_w < mi_params->mi_cols) {
         write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
-                       track_ptree_luma ? ptree_luma->sub_tree[1] : NULL,
-                       mi_row, mi_col + hbs_w, subsize);
+                       get_partition_subtree_const(ptree_luma, 1), mi_row,
+                       mi_col + hbs_w, subsize);
       }
 #else  // CONFIG_EXT_RECUR_PARTITIONS
       write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col);
@@ -3199,19 +3209,19 @@
           get_partition_subsize(bsize_big, PARTITION_HORZ);
       assert(subsize == get_partition_subsize(bsize_med, PARTITION_HORZ));
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
-                     track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
-                     mi_col, subsize);
+                     get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+                     subsize);
       if (mi_row + ebs_h >= mi_params->mi_rows) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
-                     track_ptree_luma ? ptree_luma->sub_tree[1] : NULL,
-                     mi_row + ebs_h, mi_col, bsize_med);
+                     get_partition_subtree_const(ptree_luma, 1), mi_row + ebs_h,
+                     mi_col, bsize_med);
       if (mi_row + 3 * ebs_h >= mi_params->mi_rows) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[2],
-                     track_ptree_luma ? ptree_luma->sub_tree[2] : NULL,
+                     get_partition_subtree_const(ptree_luma, 2),
                      mi_row + 3 * ebs_h, mi_col, bsize_big);
       if (mi_row + 7 * ebs_h >= mi_params->mi_rows) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[3],
-                     track_ptree_luma ? ptree_luma->sub_tree[3] : NULL,
+                     get_partition_subtree_const(ptree_luma, 3),
                      mi_row + 7 * ebs_h, mi_col, subsize);
       break;
     }
@@ -3221,19 +3231,19 @@
           get_partition_subsize(bsize_big, PARTITION_HORZ);
       assert(subsize == get_partition_subsize(bsize_med, PARTITION_HORZ));
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
-                     track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
-                     mi_col, subsize);
+                     get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+                     subsize);
       if (mi_row + ebs_h >= mi_params->mi_rows) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
-                     track_ptree_luma ? ptree_luma->sub_tree[1] : NULL,
-                     mi_row + ebs_h, mi_col, bsize_big);
+                     get_partition_subtree_const(ptree_luma, 1), mi_row + ebs_h,
+                     mi_col, bsize_big);
       if (mi_row + 5 * ebs_h >= mi_params->mi_rows) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[2],
-                     track_ptree_luma ? ptree_luma->sub_tree[2] : NULL,
+                     get_partition_subtree_const(ptree_luma, 2),
                      mi_row + 5 * ebs_h, mi_col, bsize_med);
       if (mi_row + 7 * ebs_h >= mi_params->mi_rows) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[3],
-                     track_ptree_luma ? ptree_luma->sub_tree[3] : NULL,
+                     get_partition_subtree_const(ptree_luma, 3),
                      mi_row + 7 * ebs_h, mi_col, subsize);
       break;
     }
@@ -3243,19 +3253,19 @@
           get_partition_subsize(bsize_big, PARTITION_VERT);
       assert(subsize == get_partition_subsize(bsize_med, PARTITION_VERT));
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
-                     track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
-                     mi_col, subsize);
+                     get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+                     subsize);
       if (mi_col + ebs_w >= mi_params->mi_cols) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
-                     track_ptree_luma ? ptree_luma->sub_tree[1] : NULL, mi_row,
+                     get_partition_subtree_const(ptree_luma, 1), mi_row,
                      mi_col + ebs_w, bsize_med);
       if (mi_col + 3 * ebs_w >= mi_params->mi_cols) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[2],
-                     track_ptree_luma ? ptree_luma->sub_tree[2] : NULL, mi_row,
+                     get_partition_subtree_const(ptree_luma, 2), mi_row,
                      mi_col + 3 * ebs_w, bsize_big);
       if (mi_col + 7 * ebs_w >= mi_params->mi_cols) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[3],
-                     track_ptree_luma ? ptree_luma->sub_tree[3] : NULL, mi_row,
+                     get_partition_subtree_const(ptree_luma, 3), mi_row,
                      mi_col + 7 * ebs_w, subsize);
       break;
     }
@@ -3265,19 +3275,19 @@
           get_partition_subsize(bsize_big, PARTITION_VERT);
       assert(subsize == get_partition_subsize(bsize_med, PARTITION_VERT));
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
-                     track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, mi_row,
-                     mi_col, subsize);
+                     get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+                     subsize);
       if (mi_col + ebs_w >= mi_params->mi_cols) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
-                     track_ptree_luma ? ptree_luma->sub_tree[1] : NULL, mi_row,
+                     get_partition_subtree_const(ptree_luma, 1), mi_row,
                      mi_col + ebs_w, bsize_big);
       if (mi_col + 5 * ebs_w >= mi_params->mi_cols) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[2],
-                     track_ptree_luma ? ptree_luma->sub_tree[2] : NULL, mi_row,
+                     get_partition_subtree_const(ptree_luma, 2), mi_row,
                      mi_col + 5 * ebs_w, bsize_med);
       if (mi_col + 7 * ebs_w >= mi_params->mi_cols) break;
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[3],
-                     track_ptree_luma ? ptree_luma->sub_tree[3] : NULL, mi_row,
+                     get_partition_subtree_const(ptree_luma, 3), mi_row,
                      mi_col + 7 * ebs_w, subsize);
       break;
     }
@@ -3301,10 +3311,26 @@
         }
 
         write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[i],
-                       track_ptree_luma ? ptree_luma->sub_tree[i] : NULL,
-                       this_mi_row, this_mi_col, this_bsize);
+                       get_partition_subtree_const(ptree_luma, i), this_mi_row,
+                       this_mi_col, this_bsize);
       }
       break;
+#if CONFIG_BLOCK_256
+    case PARTITION_SPLIT:
+      write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0],
+                     get_partition_subtree_const(ptree_luma, 0), mi_row, mi_col,
+                     subsize);
+      write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[1],
+                     get_partition_subtree_const(ptree_luma, 1), mi_row,
+                     mi_col + hbs_w, subsize);
+      write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[2],
+                     get_partition_subtree_const(ptree_luma, 2), mi_row + hbs_h,
+                     mi_col, subsize);
+      write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[3],
+                     get_partition_subtree_const(ptree_luma, 3), mi_row + hbs_h,
+                     mi_col + hbs_w, subsize);
+      break;
+#endif  // CONFIG_BLOCK_256
 #else   // CONFIG_EXT_RECUR_PARTITIONS
     case PARTITION_SPLIT:
       write_modes_sb(cpi, tile, w, tok, tok_end, ptree->sub_tree[0], mi_row,
@@ -3380,10 +3406,9 @@
     }
   }
 
-  for (int mi_row = mi_row_start; mi_row < mi_row_end;
-       mi_row += cm->seq_params.mib_size) {
+  for (int mi_row = mi_row_start; mi_row < mi_row_end; mi_row += cm->mib_size) {
     const int sb_row_in_tile =
-        (mi_row - tile->mi_row_start) >> cm->seq_params.mib_size_log2;
+        (mi_row - tile->mi_row_start) >> cm->mib_size_log2;
     const TokenExtra *tok =
         cpi->token_info.tplist[tile_row][tile_col][sb_row_in_tile].start;
     const TokenExtra *tok_end =
@@ -3392,8 +3417,8 @@
     av1_zero_left_context(xd);
 
     for (int mi_col = mi_col_start; mi_col < mi_col_end;
-         mi_col += cm->seq_params.mib_size) {
-      av1_reset_is_mi_coded_map(xd, cm->seq_params.mib_size);
+         mi_col += cm->mib_size) {
+      av1_reset_is_mi_coded_map(xd, cm->mib_size);
       xd->sbi = av1_get_sb_info(cm, mi_row, mi_col);
       cpi->td.mb.cb_coef_buff = av1_get_cb_coeff_buffer(cpi, mi_row, mi_col);
       const int total_loop_num =
@@ -3407,7 +3432,7 @@
 #if CONFIG_EXT_RECUR_PARTITIONS
                      NULL,
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
-                     mi_row, mi_col, cm->seq_params.sb_size);
+                     mi_row, mi_col, cm->sb_size);
       if (total_loop_num == 2) {
         xd->tree_type = CHROMA_PART;
         write_modes_sb(cpi, tile, w, &tok, tok_end,
@@ -3415,7 +3440,7 @@
 #if CONFIG_EXT_RECUR_PARTITIONS
                        xd->sbi->ptree_root[0],
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
-                       mi_row, mi_col, cm->seq_params.sb_size);
+                       mi_row, mi_col, cm->sb_size);
         xd->tree_type = SHARED_PART;
       }
     }
@@ -3584,20 +3609,38 @@
   }
 #else
   if (!all_none) {
-    assert(cm->seq_params.sb_size == BLOCK_64X64 ||
-           cm->seq_params.sb_size == BLOCK_128X128);
-    const int sb_size = cm->seq_params.sb_size == BLOCK_128X128 ? 128 : 64;
+#if CONFIG_BLOCK_256
+    assert(cm->sb_size == BLOCK_64X64 || cm->sb_size == BLOCK_128X128 ||
+           cm->sb_size == BLOCK_256X256);
+#else
+    assert(cm->sb_size == BLOCK_64X64 || cm->sb_size == BLOCK_128X128);
+#endif  // CONFIG_BLOCK_256
+    const int sb_size =
+#if CONFIG_BLOCK_256
+        cm->sb_size == BLOCK_256X256 ? 256 :
+#endif  // CONFIG_BLOCK_256
+        cm->sb_size == BLOCK_128X128 ? 128
+                                     : 64;
 
     RestorationInfo *rsi = &cm->rst_info[0];
 
     assert(rsi->restoration_unit_size >= sb_size);
     assert(RESTORATION_UNITSIZE_MAX == 256);
+#if CONFIG_BLOCK_256
+    if (sb_size <= 128) {
+      aom_wb_write_bit(wb, rsi->restoration_unit_size > 128);
+    }
+    if (sb_size == 64) {
+      aom_wb_write_bit(wb, rsi->restoration_unit_size > 64);
+    }
+#else
     if (sb_size == 64) {
       aom_wb_write_bit(wb, rsi->restoration_unit_size > 64);
     }
     if (rsi->restoration_unit_size > 64) {
       aom_wb_write_bit(wb, rsi->restoration_unit_size > 128);
     }
+#endif  // CONFIG_BLOCK_256
   }
 
   if (num_planes > 1) {
@@ -4301,12 +4344,10 @@
 
 static AOM_INLINE void write_tile_info_max_tile(
     const AV1_COMMON *const cm, struct aom_write_bit_buffer *wb) {
-  int width_mi =
-      ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, cm->seq_params.mib_size_log2);
-  int height_mi =
-      ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->seq_params.mib_size_log2);
-  int width_sb = width_mi >> cm->seq_params.mib_size_log2;
-  int height_sb = height_mi >> cm->seq_params.mib_size_log2;
+  int width_mi = ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, cm->mib_size_log2);
+  int height_mi = ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->mib_size_log2);
+  int width_sb = width_mi >> cm->mib_size_log2;
+  int height_sb = height_mi >> cm->mib_size_log2;
   int size_sb, i;
   const CommonTileParams *const tiles = &cm->tiles;
 
@@ -4766,9 +4807,21 @@
   (void)wb;
   assert(seq_params->mib_size == mi_size_wide[seq_params->sb_size]);
   assert(seq_params->mib_size == 1 << seq_params->mib_size_log2);
+
+#if CONFIG_BLOCK_256
+  assert(seq_params->sb_size == BLOCK_256X256 ||
+         seq_params->sb_size == BLOCK_128X128 ||
+         seq_params->sb_size == BLOCK_64X64);
+  const bool is_256 = seq_params->sb_size == BLOCK_256X256;
+  aom_wb_write_bit(wb, is_256);
+  if (is_256) {
+    return;
+  }
+#else
   assert(seq_params->sb_size == BLOCK_128X128 ||
          seq_params->sb_size == BLOCK_64X64);
-  aom_wb_write_bit(wb, seq_params->sb_size == BLOCK_128X128 ? 1 : 0);
+#endif  // CONFIG_BLOCK_256
+  aom_wb_write_bit(wb, seq_params->sb_size == BLOCK_128X128);
 }
 
 static AOM_INLINE void write_sequence_header(
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 1db8135..c04d0c3 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -534,8 +534,28 @@
 } SimpleMotionData;
 
 /*!\cond */
+#if CONFIG_BLOCK_256
+
+#define BLOCK_256_COUNT 1
+#define BLOCK_128_COUNT 3
+#define BLOCK_64_COUNT 7
+
+#if CONFIG_UNEVEN_4WAY
+#define BLOCK_32_COUNT 31
+#define BLOCK_16_COUNT 63
+#define BLOCK_8_COUNT 64
+#else
+#define BLOCK_32_COUNT 15
+#define BLOCK_16_COUNT 31
+#define BLOCK_8_COUNT 63
+#endif  // CONFIG_UNEVEN_4WAY
+
+#define BLOCK_4_COUNT 64
+
+#else
 #define BLOCK_128_COUNT 1
 #define BLOCK_64_COUNT 3
+
 #if CONFIG_UNEVEN_4WAY
 #define BLOCK_32_COUNT 15
 #define BLOCK_16_COUNT 31
@@ -545,7 +565,9 @@
 #define BLOCK_16_COUNT 15
 #define BLOCK_8_COUNT 31
 #endif  // CONFIG_UNEVEN_4WAY
+
 #define BLOCK_4_COUNT 32
+#endif  // CONFIG_BLOCK_256
 
 #define MAKE_SM_DATA_BUF(width, height) \
   SimpleMotionData                      \
@@ -557,6 +579,9 @@
 typedef struct SimpleMotionDataBufs {
   /*!\cond */
   // Square blocks
+#if CONFIG_BLOCK_256
+  MAKE_SM_DATA_BUF(256, 256);
+#endif  // CONFIG_BLOCK_256
   MAKE_SM_DATA_BUF(128, 128);
   MAKE_SM_DATA_BUF(64, 64);
   MAKE_SM_DATA_BUF(32, 32);
@@ -565,6 +590,9 @@
   MAKE_SM_DATA_BUF(4, 4);
 
   // 1:2 blocks
+#if CONFIG_BLOCK_256
+  MAKE_SM_DATA_BUF(128, 256);
+#endif  // CONFIG_BLOCK_256
   MAKE_SM_DATA_BUF(64, 128);
   MAKE_SM_DATA_BUF(32, 64);
   MAKE_SM_DATA_BUF(16, 32);
@@ -572,6 +600,9 @@
   MAKE_SM_DATA_BUF(4, 8);
 
   // 2:1 blocks
+#if CONFIG_BLOCK_256
+  MAKE_SM_DATA_BUF(256, 128);
+#endif  // CONFIG_BLOCK_256
   MAKE_SM_DATA_BUF(128, 64);
   MAKE_SM_DATA_BUF(64, 32);
   MAKE_SM_DATA_BUF(32, 16);
@@ -785,12 +816,13 @@
    * \name Partition Costs
    ****************************************************************************/
   /**@{*/
-  //! Cost for coding the partition.
-  int partition_cost[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS]
-                    [EXT_PARTITION_TYPES];
 #if CONFIG_EXT_RECUR_PARTITIONS
   /*! Cost for sending split token. */
   int do_split_cost[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS][2];
+#if CONFIG_BLOCK_256
+  /*! Cost for sending square split token. */
+  int do_square_split_cost[PARTITION_STRUCTURE_NUM][SQUARE_SPLIT_CONTEXTS][2];
+#endif  // CONFIG_BLOCK_256
   /*! Cost for sending rectangular type token. */
   int rect_type_cost[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS][2];
   /*! Cost for sending do_ext_partition token. */
@@ -805,6 +837,13 @@
                                      [PARTITION_CONTEXTS]
                                      [NUM_UNEVEN_4WAY_PARTS];
 #endif  // CONFIG_UNEVEN_4WAY
+  //! Cost for coding the partition.
+  int partition_cost[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS]
+                    [ALL_PARTITION_TYPES];
+#else
+  //! Cost for coding the partition.
+  int partition_cost[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS]
+                    [EXT_PARTITION_TYPES];
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
   /**@}*/
 
@@ -1706,6 +1745,11 @@
     1,  // BLOCK_64X128
     1,  // BLOCK_128X64
     1,  // BLOCK_128X128
+#if CONFIG_BLOCK_256
+    1,  // BLOCK_128X256
+    1,  // BLOCK_256X128
+    1,  // BLOCK_256X256
+#endif  // CONFIG_BLOCK_256
     1,  // BLOCK_4X16
     1,  // BLOCK_16X4
     1,  // BLOCK_8X32
@@ -1729,6 +1773,11 @@
     0,  // BLOCK_64X128
     0,  // BLOCK_128X64
     0,  // BLOCK_128X128
+#if CONFIG_BLOCK_256
+    0,  // BLOCK_128X256
+    0,  // BLOCK_256X128
+    0,  // BLOCK_256X256
+#endif  // CONFIG_BLOCK_256
     1,  // BLOCK_4X16
     1,  // BLOCK_16X4
     1,  // BLOCK_8X32
diff --git a/av1/encoder/compound_type.c b/av1/encoder/compound_type.c
index a165d82..90a4edc 100644
--- a/av1/encoder/compound_type.c
+++ b/av1/encoder/compound_type.c
@@ -131,6 +131,7 @@
                                   const BLOCK_SIZE bsize, const uint16_t *pred0,
                                   int stride0, const uint16_t *pred1,
                                   int stride1) {
+  /* clang-format off */
   static const BLOCK_SIZE split_qtr[BLOCK_SIZES_ALL] = {
     //                            4X4
     BLOCK_INVALID,
@@ -144,11 +145,16 @@
     BLOCK_16X32, BLOCK_32X16, BLOCK_32X32,
     // 64x128,     128x64,        128x128
     BLOCK_32X64, BLOCK_64X32, BLOCK_64X64,
+#if CONFIG_BLOCK_256
+    // 128X256,    256X128,       256X256
+    BLOCK_64X128, BLOCK_128X64, BLOCK_128X128,
+#endif  // CONFIG_BLOCK_256
     // 4X16,       16X4,          8X32
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X16,
     // 32X8,       16X64,         64X16
     BLOCK_16X4, BLOCK_8X32, BLOCK_32X8
   };
+  /* clang-format on */
   const struct macroblock_plane *const p = &x->plane[0];
   const uint16_t *src = p->src.buf;
   int src_stride = p->src.stride;
diff --git a/av1/encoder/context_tree.c b/av1/encoder/context_tree.c
index e436eff..c63b274 100644
--- a/av1/encoder/context_tree.c
+++ b/av1/encoder/context_tree.c
@@ -11,20 +11,25 @@
  */
 
 #include "av1/encoder/context_tree.h"
+#include "av1/common/av1_common_int.h"
 #include "av1/encoder/encoder.h"
 #include "av1/encoder/rd.h"
 
 static const BLOCK_SIZE square[MAX_SB_SIZE_LOG2 - 1] = {
-  BLOCK_4X4, BLOCK_8X8, BLOCK_16X16, BLOCK_32X32, BLOCK_64X64, BLOCK_128X128,
+  BLOCK_4X4,     BLOCK_8X8,   BLOCK_16X16,
+  BLOCK_32X32,   BLOCK_64X64, BLOCK_128X128,
+#if CONFIG_BLOCK_256
+  BLOCK_256X256,
+#endif  // CONFIG_BLOCK_256
 };
 
 void av1_copy_tree_context(PICK_MODE_CONTEXT *dst_ctx,
                            PICK_MODE_CONTEXT *src_ctx) {
   dst_ctx->mic = src_ctx->mic;
 #if CONFIG_C071_SUBBLK_WARPMV
-  if (is_warp_mode(src_ctx->mic.motion_mode))
-    memcpy(dst_ctx->submic, src_ctx->submic,
-           MAX_MIB_SIZE * MAX_MIB_SIZE * sizeof(*src_ctx->submic));
+  if (is_warp_mode(src_ctx->mic.motion_mode)) {
+    av1_copy_array(dst_ctx->submic, src_ctx->submic, src_ctx->num_4x4_blk);
+  }
 #endif  // CONFIG_C071_SUBBLK_WARPMV
   dst_ctx->mbmi_ext_best = src_ctx->mbmi_ext_best;
 
@@ -48,12 +53,15 @@
   dst_ctx->rd_stats = src_ctx->rd_stats;
   dst_ctx->rd_mode_is_ready = src_ctx->rd_mode_is_ready;
 #if CONFIG_EXT_RECUR_PARTITIONS
-  for (int i = 0; i < 2; ++i) {
-    const int num_blk =
-        (i == 0) ? src_ctx->num_4x4_blk : src_ctx->num_4x4_blk_chroma;
-    const int color_map_size = num_blk * 16;
-    memcpy(dst_ctx->color_index_map[i], src_ctx->color_index_map[i],
-           sizeof(src_ctx->color_index_map[i][0]) * color_map_size);
+  const int num_pix = src_ctx->num_4x4_blk * 16;
+  if (num_pix <= MAX_PALETTE_SQUARE) {
+    for (int i = 0; i < 2; ++i) {
+      const int num_blk =
+          (i == 0) ? src_ctx->num_4x4_blk : src_ctx->num_4x4_blk_chroma;
+      const int color_map_size = num_blk * 16;
+      memcpy(dst_ctx->color_index_map[i], src_ctx->color_index_map[i],
+             sizeof(src_ctx->color_index_map[i][0]) * color_map_size);
+    }
   }
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 }
@@ -123,6 +131,11 @@
                       aom_calloc(num_blk, sizeof(*ctx->blk_skip)));
   AOM_CHECK_MEM_ERROR(&error, ctx->tx_type_map,
                       aom_calloc(num_blk, sizeof(*ctx->tx_type_map)));
+#if CONFIG_C071_SUBBLK_WARPMV
+  if (!frame_is_intra_only(cm)) {
+    ctx->submic = malloc(num_blk * sizeof(*ctx->submic));
+  }
+#endif  // CONFIG_C071_SUBBLK_WARPMV
 #if CONFIG_CROSS_CHROMA_TX
   AOM_CHECK_MEM_ERROR(&error, ctx->cctx_type_map,
                       aom_calloc(num_blk, sizeof(*ctx->cctx_type_map)));
@@ -160,6 +173,11 @@
 void av1_free_pmc(PICK_MODE_CONTEXT *ctx, int num_planes) {
   if (ctx == NULL) return;
 
+#if CONFIG_C071_SUBBLK_WARPMV
+  if (ctx->submic) {
+    free(ctx->submic);
+  }
+#endif  // CONFIG_C071_SUBBLK_WARPMV
   aom_free(ctx->blk_skip);
   ctx->blk_skip = NULL;
   aom_free(ctx->tx_type_map);
@@ -640,9 +658,18 @@
 }
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 
-static AOM_INLINE int get_pc_tree_nodes(const int is_sb_size_128,
+static AOM_INLINE int get_pc_tree_nodes(const BLOCK_SIZE sb_size,
                                         int stat_generation_stage) {
-  const int tree_nodes_inc = is_sb_size_128 ? 1024 : 0;
+  const int is_sb_size_128 = sb_size == BLOCK_128X128;
+#if CONFIG_BLOCK_256
+  const int is_sb_size_256 = sb_size == BLOCK_256X256;
+#endif  // CONFIG_BLOCK_256
+  const int tree_nodes_inc =
+#if CONFIG_BLOCK_256
+      is_sb_size_256 ? (1024 + 4 * 1024) :
+#endif  // CONFIG_BLOCK_256
+      is_sb_size_128 ? 1024
+                     : 0;
   const int tree_nodes =
       stat_generation_stage ? 1 : (tree_nodes_inc + 256 + 64 + 16 + 4 + 1);
   return tree_nodes;
@@ -651,9 +678,11 @@
 void av1_setup_sms_tree(AV1_COMP *const cpi, ThreadData *td) {
   AV1_COMMON *const cm = &cpi->common;
   const int stat_generation_stage = is_stat_generation_stage(cpi);
-  const int is_sb_size_128 = cm->seq_params.sb_size == BLOCK_128X128;
-  const int tree_nodes =
-      get_pc_tree_nodes(is_sb_size_128, stat_generation_stage);
+  const int is_sb_size_128 = cm->sb_size == BLOCK_128X128;
+#if CONFIG_BLOCK_256
+  const int is_sb_size_256 = cm->sb_size == BLOCK_256X256;
+#endif  // CONFIG_BLOCK_256
+  const int tree_nodes = get_pc_tree_nodes(cm->sb_size, stat_generation_stage);
   int sms_tree_index = 0;
   SIMPLE_MOTION_DATA_TREE *this_sms;
   int square_index = 1;
@@ -665,7 +694,13 @@
   this_sms = &td->sms_tree[0];
 
   if (!stat_generation_stage) {
-    const int leaf_factor = is_sb_size_128 ? 4 : 1;
+    const int leaf_factor =
+#if CONFIG_BLOCK_256
+        is_sb_size_256 ? 16 :
+#endif  // CONFIG_BLOCK_256
+        is_sb_size_128 ? 4
+                       : 1;
+
     const int leaf_nodes = 256 * leaf_factor;
 
     // Sets up all the leaf nodes in the tree.
diff --git a/av1/encoder/context_tree.h b/av1/encoder/context_tree.h
index 3aaafe5..d99cb98 100644
--- a/av1/encoder/context_tree.h
+++ b/av1/encoder/context_tree.h
@@ -36,7 +36,7 @@
 typedef struct PICK_MODE_CONTEXT {
   MB_MODE_INFO mic;
 #if CONFIG_C071_SUBBLK_WARPMV
-  SUBMB_INFO submic[MAX_MIB_SIZE * MAX_MIB_SIZE];
+  SUBMB_INFO *submic;
 #endif  // CONFIG_C071_SUBBLK_WARPMV
   MB_MODE_INFO_EXT_FRAME mbmi_ext_best;
   uint8_t *color_index_map[2];
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index d755568..ecd0ee6 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -234,7 +234,7 @@
   const DeltaQInfo *const delta_q_info = &cm->delta_q_info;
   assert(delta_q_info->delta_q_present_flag);
 
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
   // Delta-q modulation based on variance
   av1_setup_src_planes(x, cpi->source, mi_row, mi_col, num_planes, NULL);
 
@@ -299,7 +299,7 @@
         (int8_t)clamp(delta_lf_from_base, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
     const int frame_lf_count =
         av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
-    const int mib_size = cm->seq_params.mib_size;
+    const int mib_size = cm->mib_size;
 
     // pre-set the delta lf for loop filter. Note that this value is set
     // before mi is assigned for each block in current superblock
@@ -345,7 +345,7 @@
   const int tpl_stride = tpl_frame->stride;
   int64_t inter_cost[INTER_REFS_PER_FRAME] = { 0 };
   const int step = 1 << block_mis_log2;
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
 
   const int mi_row_end =
       AOMMIN(mi_size_high[sb_size] + mi_row, mi_params->mi_rows);
@@ -420,7 +420,7 @@
 
 static AOM_INLINE void adjust_rdmult_tpl_model(AV1_COMP *cpi, MACROBLOCK *x,
                                                int mi_row, int mi_col) {
-  const BLOCK_SIZE sb_size = cpi->common.seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cpi->common.sb_size;
   const int orig_rdmult = cpi->rd.RDMULT;
 
   assert(IMPLIES(cpi->gf_group.size > 0,
@@ -498,7 +498,7 @@
   if (gather_tpl_data) {
     if (cm->delta_q_info.delta_q_present_flag) {
       const int num_planes = av1_num_planes(cm);
-      const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+      const BLOCK_SIZE sb_size = cm->sb_size;
       setup_delta_q(cpi, td, x, tile_info, mi_row, mi_col, num_planes);
       av1_tpl_rdmult_setup_sb(cpi, x, sb_size, mi_row, mi_col);
     }
@@ -514,8 +514,7 @@
 #if CONFIG_EXT_RECUR_PARTITIONS
   SimpleMotionDataBufs *data_bufs = x->sms_bufs;
   av1_init_sms_data_bufs(data_bufs);
-  fill_sms_buf(data_bufs, sms_root, mi_row, mi_col, cm->seq_params.sb_size,
-               cm->seq_params.sb_size);
+  fill_sms_buf(data_bufs, sms_root, mi_row, mi_col, cm->sb_size, cm->sb_size);
 
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
   if (x->e_mbd.tree_type == CHROMA_PART) {
@@ -551,7 +550,7 @@
   MACROBLOCKD *const xd = &x->e_mbd;
   SuperBlockEnc *sb_enc = &x->sb_enc;
   SIMPLE_MOTION_DATA_TREE *const sms_root = td->sms_root;
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
   const int ss_x = cm->seq_params.subsampling_x;
   const int ss_y = cm->seq_params.subsampling_y;
   RD_STATS dummy_rdc;
@@ -612,7 +611,7 @@
     const int mi_row, const int mi_col) {
   SIMPLE_MOTION_DATA_TREE *const sms_root = td->sms_root;
   AV1_COMMON *const cm = &cpi->common;
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
 
   // First pass
   SB_FIRST_PASS_STATS sb_fp_stats;
@@ -676,6 +675,7 @@
 #endif  // CONFIG_UNEVEN_4WAY
     case PARTITION_HORZ_3:
     case PARTITION_VERT_3: num_subtrees = 4; break;
+    case PARTITION_SPLIT: num_subtrees = 4; break;
     default:
       assert(0 && "Invalid partition type in set_min_none_to_invalid!");
       return;
@@ -703,7 +703,7 @@
   MACROBLOCK *const x = &td->mb;
   MACROBLOCKD *const xd = &x->e_mbd;
 
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
   assert(!frame_is_intra_only(cm));
 
   // First pass to estimate  partition structures
@@ -750,7 +750,7 @@
   const TileInfo *const tile_info = &tile_data->tile_info;
   MB_MODE_INFO **mi = cm->mi_params.mi_grid_base +
                       get_mi_grid_idx(&cm->mi_params, mi_row, mi_col);
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
   const int num_planes = av1_num_planes(cm);
   int dummy_rate;
   int64_t dummy_dist;
@@ -920,9 +920,9 @@
   MACROBLOCK *const x = &td->mb;
   MACROBLOCKD *const xd = &x->e_mbd;
   const int sb_cols_in_tile = av1_get_sb_cols_in_tile(cm, tile_data->tile_info);
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
-  const int mib_size = cm->seq_params.mib_size;
-  const int mib_size_log2 = cm->seq_params.mib_size_log2;
+  const BLOCK_SIZE sb_size = cm->sb_size;
+  const int mib_size = cm->mib_size;
+  const int mib_size_log2 = cm->mib_size_log2;
   const int sb_row = (mi_row - tile_info->mi_row_start) >> mib_size_log2;
 
 #if CONFIG_COLLECT_COMPONENT_TIMING
@@ -947,7 +947,7 @@
   for (int mi_col = tile_info->mi_col_start, sb_col_in_tile = 0;
        mi_col < tile_info->mi_col_end; mi_col += mib_size, sb_col_in_tile++) {
     (*(enc_row_mt->sync_read_ptr))(row_mt_sync, sb_row, sb_col_in_tile);
-    av1_reset_is_mi_coded_map(xd, cm->seq_params.mib_size);
+    av1_reset_is_mi_coded_map(xd, cm->mib_size);
     av1_set_sb_info(cm, xd, mi_row, mi_col);
 
     if (tile_data->allow_update_cdf && row_mt_enabled &&
@@ -1064,9 +1064,8 @@
       if (pre_tok != NULL && tplist != NULL) {
         token_info->tile_tok[tile_row][tile_col] = pre_tok + tile_tok;
         pre_tok = token_info->tile_tok[tile_row][tile_col];
-        tile_tok = allocated_tokens(*tile_info,
-                                    cm->seq_params.mib_size_log2 + MI_SIZE_LOG2,
-                                    num_planes);
+        tile_tok = allocated_tokens(
+            *tile_info, cm->mib_size_log2 + MI_SIZE_LOG2, num_planes);
         token_info->tplist[tile_row][tile_col] = tplist + tplist_count;
         tplist = token_info->tplist[tile_row][tile_col];
         tplist_count = av1_get_sb_rows_in_tile(cm, tile_data->tile_info);
@@ -1093,14 +1092,14 @@
   TokenExtra *tok = NULL;
   TokenList *const tplist = cpi->token_info.tplist[tile_row][tile_col];
   const int sb_row_in_tile =
-      (mi_row - tile_info->mi_row_start) >> cm->seq_params.mib_size_log2;
+      (mi_row - tile_info->mi_row_start) >> cm->mib_size_log2;
   const int tile_mb_cols =
       (tile_info->mi_col_end - tile_info->mi_col_start + 2) >> 2;
   const int num_mb_rows_in_sb =
-      ((1 << (cm->seq_params.mib_size_log2 + MI_SIZE_LOG2)) + 8) >> 4;
+      ((1 << (cm->mib_size_log2 + MI_SIZE_LOG2)) + 8) >> 4;
 
   get_start_tok(cpi, tile_row, tile_col, mi_row, &tok,
-                cm->seq_params.mib_size_log2 + MI_SIZE_LOG2, num_planes);
+                cm->mib_size_log2 + MI_SIZE_LOG2, num_planes);
   tplist[sb_row_in_tile].start = tok;
 
   encode_sb_row(cpi, td, this_tile, mi_row, &tok);
@@ -1110,8 +1109,7 @@
 
   assert((unsigned int)(tok - tplist[sb_row_in_tile].start) <=
          get_token_alloc(num_mb_rows_in_sb, tile_mb_cols,
-                         cm->seq_params.mib_size_log2 + MI_SIZE_LOG2,
-                         num_planes));
+                         cm->mib_size_log2 + MI_SIZE_LOG2, num_planes));
 
   (void)tile_mb_cols;
   (void)num_mb_rows_in_sb;
@@ -1142,7 +1140,7 @@
       &td->mb.txfm_search_info.mb_rd_record.crc_calculator);
 
   for (int mi_row = tile_info->mi_row_start; mi_row < tile_info->mi_row_end;
-       mi_row += cm->seq_params.mib_size) {
+       mi_row += cm->mib_size) {
 #if CONFIG_REF_MV_BANK
     av1_zero(td->mb.e_mbd.ref_mv_bank);
 #if !CONFIG_MVP_IMPROVEMENT
@@ -1582,8 +1580,7 @@
                                       block_hash_values[0], is_block_same[0]);
     // Hash data generated for screen contents is used for intraBC ME
     const int min_alloc_size = block_size_wide[mi_params->mi_alloc_bsize];
-    const int max_sb_size =
-        (1 << (cm->seq_params.mib_size_log2 + MI_SIZE_LOG2));
+    const int max_sb_size = (1 << (cm->mib_size_log2 + MI_SIZE_LOG2));
     int src_idx = 0;
     for (int size = 4; size <= max_sb_size; size *= 2, src_idx = !src_idx) {
       const int dst_idx = !src_idx;
diff --git a/av1/encoder/encodeframe_utils.c b/av1/encoder/encodeframe_utils.c
index 4405d12..d38dbac 100644
--- a/av1/encoder/encodeframe_utils.c
+++ b/av1/encoder/encodeframe_utils.c
@@ -67,13 +67,13 @@
 static int get_superblock_tpl_column_end(const AV1_COMMON *const cm, int mi_col,
                                          int num_mi_w) {
   // Find the start column of this superblock.
-  const int sb_mi_col_start = (mi_col >> cm->seq_params.mib_size_log2)
-                              << cm->seq_params.mib_size_log2;
+  const int sb_mi_col_start = (mi_col >> cm->mib_size_log2)
+                              << cm->mib_size_log2;
   // Same but in superres upscaled dimension.
   const int sb_mi_col_start_sr =
       coded_to_superres_mi(sb_mi_col_start, cm->superres_scale_denominator);
   // Width of this superblock in mi units.
-  const int sb_mi_width = mi_size_wide[cm->seq_params.sb_size];
+  const int sb_mi_width = mi_size_wide[cm->sb_size];
   // Same but in superres upscaled dimension.
   const int sb_mi_width_sr =
       coded_to_superres_mi(sb_mi_width, cm->superres_scale_denominator);
@@ -134,7 +134,7 @@
   rdmult = AOMMAX(rdmult, 0);
   av1_set_error_per_bit(&x->mv_costs, rdmult);
   aom_clear_system_state();
-  if (bsize == cm->seq_params.sb_size) {
+  if (bsize == cm->sb_size) {
     const int rdmult_sb = set_deltaq_rdmult(cpi, x);
     assert(rdmult_sb == rdmult);
     (void)rdmult_sb;
@@ -759,8 +759,7 @@
   memcpy(xd->left_txfm_context, ctx->tl,
          sizeof(*xd->left_txfm_context) * mi_height);
 #endif  // !CONFIG_TX_PARTITION_CTX
-  av1_mark_block_as_not_coded(xd, mi_row, mi_col, bsize,
-                              cm->seq_params.sb_size);
+  av1_mark_block_as_not_coded(xd, mi_row, mi_col, bsize, cm->sb_size);
 }
 
 void av1_save_context(const MACROBLOCK *x, RD_SEARCH_MACROBLOCK_CONTEXT *ctx,
@@ -805,9 +804,9 @@
                                      MB_MODE_INFO **mib) {
   int bh = bh_in;
   int r, c;
-  for (r = 0; r < cm->seq_params.mib_size; r += bh) {
+  for (r = 0; r < cm->mib_size; r += bh) {
     int bw = bw_in;
-    for (c = 0; c < cm->seq_params.mib_size; c += bw) {
+    for (c = 0; c < cm->mib_size; c += bw) {
       const int grid_index = get_mi_grid_idx(&cm->mi_params, r, c);
       const int mi_index = get_alloc_mi_idx(&cm->mi_params, r, c);
       mib[grid_index] = mi + mi_index;
@@ -840,12 +839,10 @@
   assert((mi_rows_remaining > 0) && (mi_cols_remaining > 0));
 
   // Apply the requested partition size to the SB if it is all "in image"
-  if ((mi_cols_remaining >= cm->seq_params.mib_size) &&
-      (mi_rows_remaining >= cm->seq_params.mib_size)) {
-    for (int block_row = 0; block_row < cm->seq_params.mib_size;
-         block_row += bh) {
-      for (int block_col = 0; block_col < cm->seq_params.mib_size;
-           block_col += bw) {
+  if ((mi_cols_remaining >= cm->mib_size) &&
+      (mi_rows_remaining >= cm->mib_size)) {
+    for (int block_row = 0; block_row < cm->mib_size; block_row += bh) {
+      for (int block_col = 0; block_col < cm->mib_size; block_col += bw) {
         const int grid_index = get_mi_grid_idx(mi_params, block_row, block_col);
         const int mi_index = get_alloc_mi_idx(mi_params, block_row, block_col);
         mib[grid_index] = mi_upper_left + mi_index;
@@ -1479,6 +1476,15 @@
                   ctx_tr->do_split_cdf[plane_index][i], 2);
     }
   }
+#if CONFIG_BLOCK_256
+  for (int plane_index = 0; plane_index < PARTITION_STRUCTURE_NUM;
+       plane_index++) {
+    for (int i = 0; i < SQUARE_SPLIT_CONTEXTS; i++) {
+      AVERAGE_CDF(ctx_left->do_square_split_cdf[plane_index][i],
+                  ctx_tr->do_square_split_cdf[plane_index][i], 2);
+    }
+  }
+#endif  // CONFIG_BLOCK_256
   for (int plane_index = 0; plane_index < PARTITION_STRUCTURE_NUM;
        plane_index++) {
     for (int i = 0; i < PARTITION_CONTEXTS; i++) {
@@ -1665,7 +1671,7 @@
 
   const AV1_COMMON *cm = &cpi->common;
   const int num_planes = av1_num_planes(cm);
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
 
 #if !CONFIG_TX_PARTITION_CTX
   xd->above_txfm_context =
@@ -1707,7 +1713,7 @@
 
   const AV1_COMMON *cm = &cpi->common;
   const int num_planes = av1_num_planes(cm);
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
 
   av1_restore_context(cm, x, &sb_fp_stats->x_ctx, mi_row, mi_col, sb_size,
                       num_planes);
diff --git a/av1/encoder/encodeframe_utils.h b/av1/encoder/encodeframe_utils.h
index 5fc666f..abe641e 100644
--- a/av1/encoder/encodeframe_utils.h
+++ b/av1/encoder/encodeframe_utils.h
@@ -151,14 +151,13 @@
   // RD cost summed across all blocks of partition type.
   RD_STATS sum_rdc;
 
+#if !CONFIG_EXT_RECUR_PARTITIONS
   // Array holding partition type cost.
   int tmp_partition_cost[PARTITION_TYPES];
-#if CONFIG_EXT_RECUR_PARTITIONS
-  int partition_cost_table[EXT_PARTITION_TYPES];
-#endif
+#endif  // CONFIG_EXT_RECUR_PARTITIONS
 
   // Pointer to partition cost buffer
-  int *partition_cost;
+  const int *partition_cost;
 
   // RD costs for different partition types.
   int64_t none_rd;
@@ -304,6 +303,9 @@
     case 32: return BLOCK_32X32;
     case 64: return BLOCK_64X64;
     case 128: return BLOCK_128X128;
+#if CONFIG_BLOCK_256
+    case 256: return BLOCK_256X256;
+#endif  // CONFIG_BLOCK_256
     default: assert(0); return 0;
   }
 }
@@ -321,10 +323,8 @@
   sb_enc->min_partition_size =
       AOMMAX(sf->part_sf.default_min_partition_size,
              dim_to_size(cpi->oxcf.part_cfg.min_partition_size));
-  sb_enc->max_partition_size =
-      AOMMIN(sb_enc->max_partition_size, cm->seq_params.sb_size);
-  sb_enc->min_partition_size =
-      AOMMIN(sb_enc->min_partition_size, cm->seq_params.sb_size);
+  sb_enc->max_partition_size = AOMMIN(sb_enc->max_partition_size, cm->sb_size);
+  sb_enc->min_partition_size = AOMMIN(sb_enc->min_partition_size, cm->sb_size);
 
   if (use_auto_max_partition(cpi, sb_size, mi_row, mi_col)) {
     float features[FEATURE_SIZE_MAX_MIN_PART_PRED] = { 0.0f };
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 28c4263..d9c66b4 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "av1/common/av1_common_int.h"
 #include "config/aom_config.h"
 #include "config/aom_dsp_rtcd.h"
 
@@ -245,59 +246,6 @@
   return uncompressed_frame_size / (double)encoded_frame_size;
 }
 
-static void set_tile_info(AV1_COMMON *const cm,
-                          const TileConfig *const tile_cfg) {
-  const CommonModeInfoParams *const mi_params = &cm->mi_params;
-  const SequenceHeader *const seq_params = &cm->seq_params;
-  CommonTileParams *const tiles = &cm->tiles;
-  int i, start_sb;
-
-  av1_get_tile_limits(cm);
-
-  // configure tile columns
-  if (tile_cfg->tile_width_count == 0 || tile_cfg->tile_height_count == 0) {
-    tiles->uniform_spacing = 1;
-    tiles->log2_cols = AOMMAX(tile_cfg->tile_columns, tiles->min_log2_cols);
-    tiles->log2_cols = AOMMIN(tiles->log2_cols, tiles->max_log2_cols);
-  } else {
-    int mi_cols =
-        ALIGN_POWER_OF_TWO(mi_params->mi_cols, seq_params->mib_size_log2);
-    int sb_cols = mi_cols >> seq_params->mib_size_log2;
-    int size_sb, j = 0;
-    tiles->uniform_spacing = 0;
-    for (i = 0, start_sb = 0; start_sb < sb_cols && i < MAX_TILE_COLS; i++) {
-      tiles->col_start_sb[i] = start_sb;
-      size_sb = tile_cfg->tile_widths[j++];
-      if (j >= tile_cfg->tile_width_count) j = 0;
-      start_sb += AOMMIN(size_sb, tiles->max_width_sb);
-    }
-    tiles->cols = i;
-    tiles->col_start_sb[i] = sb_cols;
-  }
-  av1_calculate_tile_cols(seq_params, mi_params->mi_rows, mi_params->mi_cols,
-                          tiles);
-
-  // configure tile rows
-  if (tiles->uniform_spacing) {
-    tiles->log2_rows = AOMMAX(tile_cfg->tile_rows, tiles->min_log2_rows);
-    tiles->log2_rows = AOMMIN(tiles->log2_rows, tiles->max_log2_rows);
-  } else {
-    int mi_rows =
-        ALIGN_POWER_OF_TWO(mi_params->mi_rows, seq_params->mib_size_log2);
-    int sb_rows = mi_rows >> seq_params->mib_size_log2;
-    int size_sb, j = 0;
-    for (i = 0, start_sb = 0; start_sb < sb_rows && i < MAX_TILE_ROWS; i++) {
-      tiles->row_start_sb[i] = start_sb;
-      size_sb = tile_cfg->tile_heights[j++];
-      if (j >= tile_cfg->tile_height_count) j = 0;
-      start_sb += AOMMIN(size_sb, tiles->max_height_sb);
-    }
-    tiles->rows = i;
-    tiles->row_start_sb[i] = sb_rows;
-  }
-  av1_calculate_tile_rows(seq_params, mi_params->mi_rows, tiles);
-}
-
 static void update_frame_size(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
@@ -314,10 +262,15 @@
   if (!is_stat_generation_stage(cpi))
     alloc_context_buffers_ext(cm, &cpi->mbmi_ext_info);
 
-  if (!cpi->seq_params_locked)
-    set_sb_size(&cm->seq_params, av1_select_sb_size(cpi));
+  const BLOCK_SIZE sb_size = av1_select_sb_size(cpi);
+  if (!cpi->seq_params_locked) {
+    set_sb_size(cm, sb_size);
+  } else {
+    av1_set_frame_sb_size(cm, sb_size);
+  }
+  cpi->td.sb_size = cm->sb_size;
 
-  set_tile_info(cm, &cpi->oxcf.tile_cfg);
+  av1_set_tile_info(cm, &cpi->oxcf.tile_cfg);
 }
 
 static INLINE int does_level_match(int width, int height, double fps,
@@ -645,8 +598,10 @@
 
   cm->width = oxcf->frm_dim_cfg.width;
   cm->height = oxcf->frm_dim_cfg.height;
-  set_sb_size(seq_params,
-              av1_select_sb_size(cpi));  // set sb size before allocations
+  // set sb size before allocations
+  const BLOCK_SIZE sb_size = av1_select_sb_size(cpi);
+  set_sb_size(cm, sb_size);
+  cpi->td.sb_size = cm->sb_size;
   alloc_compressor_data(cpi);
 
   av1_update_film_grain_parameters(cpi, oxcf);
@@ -909,18 +864,21 @@
   cm->width = frm_dim_cfg->width;
   cm->height = frm_dim_cfg->height;
 
-  int sb_size = seq_params->sb_size;
+  BLOCK_SIZE sb_size = cm->sb_size;
+  BLOCK_SIZE new_sb_size = av1_select_sb_size(cpi);
   // Superblock size should not be updated after the first key frame.
   if (!cpi->seq_params_locked) {
-    set_sb_size(&cm->seq_params, av1_select_sb_size(cpi));
+    set_sb_size(cm, new_sb_size);
     for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i)
       seq_params->tier[i] = (oxcf->tier_mask >> i) & 1;
+  } else {
+    av1_set_frame_sb_size(cm, new_sb_size);
   }
+  cpi->td.sb_size = cm->sb_size;
 
-  if (initial_dimensions->width || sb_size != seq_params->sb_size) {
+  if (initial_dimensions->width || sb_size != cm->sb_size) {
     if (cm->width > initial_dimensions->width ||
-        cm->height > initial_dimensions->height ||
-        seq_params->sb_size != sb_size) {
+        cm->height > initial_dimensions->height || cm->sb_size != sb_size) {
       av1_free_context_buffers(cm);
       av1_free_shared_coeff_buffer(&cpi->td.shared_coeff_buf);
       av1_free_sms_tree(&cpi->td);
@@ -938,7 +896,7 @@
 
   rc->is_src_frame_alt_ref = 0;
 
-  set_tile_info(cm, &cpi->oxcf.tile_cfg);
+  av1_set_tile_info(cm, &cpi->oxcf.tile_cfg);
 
   cpi->ext_flags.refresh_frame.update_pending = 0;
   cpi->ext_flags.refresh_frame_context_pending = 0;
@@ -2341,6 +2299,7 @@
     if (cm->cdef_info.cdef_frame_enable)
 #endif  // CONFIG_FIX_CDEF_SYNTAX
       av1_cdef_frame(&cm->cur_frame->buf, cm, xd);
+
 #if CONFIG_COLLECT_COMPONENT_TIMING
     end_timing(cpi, cdef_time);
 #endif
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index f481bd9..0e62818 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -235,12 +235,12 @@
    * Indicates the minimum partition size that should be allowed. Both width and
    * height of a partition cannot be smaller than the min_partition_size.
    */
-  BLOCK_SIZE min_partition_size;
+  unsigned int min_partition_size;
   /*!
    * Indicates the maximum partition size that should be allowed. Both width and
    * height of a partition cannot be larger than the max_partition_size.
    */
-  BLOCK_SIZE max_partition_size;
+  unsigned int max_partition_size;
 } PartitionCfg;
 
 /*!
@@ -1270,6 +1270,8 @@
                                      [PALETTE_COLORS];
 #if CONFIG_EXT_RECUR_PARTITIONS
   unsigned int do_split[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS][2];
+  unsigned int do_square_split[PARTITION_STRUCTURE_NUM][SQUARE_SPLIT_CONTEXTS]
+                              [2];
   unsigned int rect_type[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS][2];
   unsigned int do_ext_partition[PARTITION_STRUCTURE_NUM][NUM_RECT_PARTS]
                                [PARTITION_CONTEXTS][2];
@@ -1703,6 +1705,7 @@
   SIMPLE_MOTION_DATA_TREE *sms_root;
 #if CONFIG_EXT_RECUR_PARTITIONS
   struct SimpleMotionDataBufs *sms_bufs;
+  BLOCK_SIZE sb_size;
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
   InterModesInfo *inter_modes_info;
   uint32_t *hash_value_buffer[2][2];
diff --git a/av1/encoder/encoder_alloc.h b/av1/encoder/encoder_alloc.h
index d40a3a8..2b6e702 100644
--- a/av1/encoder/encoder_alloc.h
+++ b/av1/encoder/encoder_alloc.h
@@ -333,7 +333,7 @@
 
 static AOM_INLINE void variance_partition_alloc(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
-  const int num_64x64_blocks = (cm->seq_params.sb_size == BLOCK_64X64) ? 1 : 4;
+  const int num_64x64_blocks = (cm->sb_size == BLOCK_64X64) ? 1 : 4;
   if (cpi->td.vt64x64) {
     if (num_64x64_blocks != cpi->td.num_64x64_blocks) {
       aom_free(cpi->td.vt64x64);
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c
index e18009c..3822b43 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -168,19 +168,171 @@
     { 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
 };
 
-const int default_obmc_probs[FRAME_UPDATE_TYPES][BLOCK_SIZES_ALL] = {
-  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
-  { 0,  0,  0,  106, 90, 90, 97, 67, 59, 70, 28,
-    30, 38, 16, 16,  16, 0,  0,  44, 50, 26, 25 },
-  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
-  { 0,  0,  0,  98, 93, 97, 68, 82, 85, 33, 30,
-    33, 16, 16, 16, 16, 0,  0,  43, 37, 26, 16 },
-  { 0,  0,  0,  91, 80, 76, 78, 55, 49, 24, 16,
-    16, 16, 16, 16, 16, 0,  0,  29, 45, 16, 38 },
-  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
-  { 0,  0,  0,  103, 89, 89, 89, 62, 63, 76, 34,
-    35, 32, 19, 16,  16, 0,  0,  49, 55, 29, 19 }
+/* clang-format off */
+const int default_obmc_probs[FRAME_UPDATE_TYPES][BLOCK_SIZES_ALL] = { {
+    // BLOCK_4X4
+    0,
+    // BLOCK_4X8 .. BLOCK_8X8
+    0, 0, 0,
+    // BLOCK_8X16 .. BLOCK_16X16
+    0, 0, 0,
+    // BLOCK_16X32 .. BLOCK_32X32
+    0, 0, 0,
+    // BLOCK_32X64 .. BLOCK_64X64
+    0, 0, 0,
+    // BLOCK_64X128 .. BLOCK_128X128
+    0, 0, 0,
+#if CONFIG_BLOCK_256
+    // BLOCK_128X256 .. BLOCK_256X256
+    0, 0, 0,
+#endif  // CONFIG_BLOCK_256
+    // BLOCK_4X16, BLOCK_16X4
+    0, 0,
+    // BLOCK_8X32, BLOCK_32X8
+    0, 0,
+    // BLOCK_16X64, BLOCK_64X16
+    0, 0
+  }, {
+    // BLOCK_4X4
+    0,
+    // BLOCK_4X8 .. BLOCK_8X8
+    0,  0,  106,
+    // BLOCK_8X16 .. BLOCK_16X16
+    90, 90, 97,
+    // BLOCK_16X32 .. BLOCK_32X32
+    67, 59, 70,
+    // BLOCK_32X64 .. BLOCK_64X64
+    28, 30, 38,
+    // BLOCK_64X128 .. BLOCK_128X128
+    16, 16,  16,
+#if CONFIG_BLOCK_256
+    // BLOCK_128X256 .. BLOCK_256X256
+    16, 16,  16,
+#endif  // CONFIG_BLOCK_256
+    // BLOCK_4X16, BLOCK_16X4
+    0,  0,
+    // BLOCK_8X32, BLOCK_32X8
+    44, 50,
+    // BLOCK_16X64, BLOCK_64X16
+    26, 25
+  }, {
+    // BLOCK_4X4
+    0,
+    // BLOCK_4X8 .. BLOCK_8X8
+    0, 0, 0,
+    // BLOCK_8X16 .. BLOCK_16X16
+    0, 0, 0,
+    // BLOCK_16X32 .. BLOCK_32X32
+    0, 0, 0,
+    // BLOCK_32X64 .. BLOCK_64X64
+    0, 0, 0,
+    // BLOCK_64X128 .. BLOCK_128X128
+    0, 0, 0,
+#if CONFIG_BLOCK_256
+    // BLOCK_128X256 .. BLOCK_256X256
+    0, 0, 0,
+#endif  // CONFIG_BLOCK_256
+    // BLOCK_4X16, BLOCK_16X4
+    0, 0,
+    // BLOCK_8X32, BLOCK_32X8
+    0, 0,
+    // BLOCK_16X64, BLOCK_64X16
+    0, 0
+  }, {
+    // BLOCK_4X4
+    0,
+    // BLOCK_4X8 .. BLOCK_8X8
+    0,  0,  98,
+    // BLOCK_8X16 .. BLOCK_16X16
+    93, 97, 68,
+    // BLOCK_16X32 .. BLOCK_32X32
+    82, 85, 33,
+    // BLOCK_32X64 .. BLOCK_64X64
+    30, 33, 16,
+    // BLOCK_64X128 .. BLOCK_128X128
+    16, 16, 16,
+#if CONFIG_BLOCK_256
+    // BLOCK_128X256 .. BLOCK_256X256
+    16, 16, 16,
+#endif  // CONFIG_BLOCK_256
+    // BLOCK_4X16, BLOCK_16X4
+    0,  0,
+    // BLOCK_8X32, BLOCK_32X8
+    43, 37,
+    // BLOCK_16X64, BLOCK_64X16
+    26, 16
+  }, {
+    // BLOCK_4X4
+    0,
+    // BLOCK_4X8 .. BLOCK_8X8
+    0,  0,  91,
+    // BLOCK_8X16 .. BLOCK_16X16
+    80, 76, 78,
+    // BLOCK_16X32 .. BLOCK_32X32
+    55, 49, 24,
+    // BLOCK_32X64 .. BLOCK_64X64
+    16, 16, 16,
+    // BLOCK_64X128 .. BLOCK_128X128
+    16, 16, 16,
+    // BLOCK_128X256 .. BLOCK_256X256
+#if CONFIG_BLOCK_256
+    16, 16, 16,
+#endif  // CONFIG_BLOCK_256
+    // BLOCK_4X16, BLOCK_16X4
+    0,  0,
+    // BLOCK_8X32, BLOCK_32X8
+    29, 45,
+    // BLOCK_16X64, BLOCK_64X16
+    16, 38
+  }, {
+    // BLOCK_4X4
+    0,
+    // BLOCK_4X8 .. BLOCK_8X8
+    0, 0, 0,
+    // BLOCK_8X16 .. BLOCK_16X16
+    0, 0, 0,
+    // BLOCK_16X32 .. BLOCK_32X32
+    0, 0, 0,
+    // BLOCK_32X64 .. BLOCK_64X64
+    0, 0, 0,
+    // BLOCK_64X128 .. BLOCK_128X128
+    0, 0, 0,
+#if CONFIG_BLOCK_256
+    // BLOCK_128X256 .. BLOCK_256X256
+    0, 0, 0,
+#endif  // CONFIG_BLOCK_256
+    // BLOCK_4X16, BLOCK_16X4
+    0, 0,
+    // BLOCK_8X32, BLOCK_32X8
+    0, 0,
+    // BLOCK_16X64, BLOCK_64X16
+    0, 0
+  }, {
+    // BLOCK_4X4
+    0,
+    // BLOCK_4X8 .. BLOCK_8X8
+    0,  0,  103,
+    // BLOCK_8X16 .. BLOCK_16X16
+    89, 89, 89,
+    // BLOCK_16X32 .. BLOCK_32X32
+    62, 63, 76,
+    // BLOCK_32X64 .. BLOCK_64X64
+    34, 35, 32,
+    // BLOCK_64X128 .. BLOCK_128X128
+    19, 16,  16,
+#if CONFIG_BLOCK_256
+    // BLOCK_128X256 .. BLOCK_256X256
+    19, 16,  16,
+#endif  // CONFIG_BLOCK_256
+    // BLOCK_4X16, BLOCK_16X4
+    0,  0,
+    // BLOCK_8X32, BLOCK_32X8
+    49, 55,
+    // BLOCK_16X64, BLOCK_64X16
+    29, 19
+  }
 };
+/* clang-format on */
 
 const int default_warped_probs[FRAME_UPDATE_TYPES] = { 64, 64, 64, 64,
                                                        64, 64, 64 };
@@ -601,8 +753,53 @@
       oxcf->resize_cfg.resize_mode == RESIZE_NONE && oxcf->speed >= 1) {
     return AOMMIN(cm->width, cm->height) > 480 ? BLOCK_128X128 : BLOCK_64X64;
   }
-
+#if CONFIG_BLOCK_256
+  return AOMMIN(oxcf->frm_dim_cfg.width, oxcf->frm_dim_cfg.height) >= 720
+             ? BLOCK_256X256
+             : BLOCK_128X128;
+#else
   return BLOCK_128X128;
+#endif  // CONFIG_BLOCK_256
+}
+
+static AOM_INLINE void reallocate_sb_size_dependent_buffers(AV1_COMP *cpi) {
+  // Note: this is heavier than it needs to be. We can avoid reallocating some
+  // of the buffers.
+  AV1_COMMON *const cm = &cpi->common;
+  const int num_planes = av1_num_planes(cm);
+
+  av1_set_tile_info(cm, &cpi->oxcf.tile_cfg);
+  av1_free_context_buffers(cm);
+  av1_free_shared_coeff_buffer(&cpi->td.shared_coeff_buf);
+  av1_free_sms_tree(&cpi->td);
+#if CONFIG_EXT_RECUR_PARTITIONS
+  av1_free_sms_bufs(&cpi->td);
+#endif  // CONFIG_EXT_RECUR_PARTITIONS
+  av1_free_pmc(cpi->td.firstpass_ctx, num_planes);
+  cpi->td.firstpass_ctx = NULL;
+  alloc_compressor_data(cpi);
+  if (av1_alloc_above_context_buffers(&cm->above_contexts, cm->tiles.rows,
+                                      cm->mi_params.mi_cols, num_planes)) {
+    aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
+                       "Failed to allocate context buffers");
+  }
+
+  const int old_restoration_unit_size = cm->rst_info[0].restoration_unit_size;
+
+  const SequenceHeader *const seq_params = &cm->seq_params;
+  const int frame_width = cm->superres_upscaled_width;
+  const int frame_height = cm->superres_upscaled_height;
+
+  set_restoration_unit_size(frame_width, frame_height,
+                            seq_params->subsampling_x,
+                            seq_params->subsampling_y, cm->rst_info);
+
+  if (old_restoration_unit_size != cm->rst_info[0].restoration_unit_size) {
+    for (int i = 0; i < num_planes; ++i)
+      cm->rst_info[i].frame_restoration_type = RESTORE_NONE;
+
+    av1_alloc_restoration_buffers(cm);
+  }
 }
 
 void av1_setup_frame(AV1_COMP *cpi) {
@@ -618,10 +815,11 @@
     av1_setup_past_independence(cm);
   }
 
+  const BLOCK_SIZE old_sb_size = cm->sb_size;
   if ((cm->current_frame.frame_type == KEY_FRAME && cm->show_frame) ||
       frame_is_sframe(cm)) {
     if (!cpi->seq_params_locked) {
-      set_sb_size(&cm->seq_params, av1_select_sb_size(cpi));
+      set_sb_size(cm, av1_select_sb_size(cpi));
     }
   } else {
     const RefCntBuffer *const primary_ref_buf = get_primary_ref_frame_buf(cm);
@@ -633,6 +831,31 @@
       *cm->fc = primary_ref_buf->frame_context;
     }
   }
+  av1_set_frame_sb_size(cm, cm->seq_params.sb_size);
+  cpi->td.sb_size = cm->sb_size;
+  av1_set_tile_info(cm, &cpi->oxcf.tile_cfg);
+  if (cm->sb_size != old_sb_size) {
+    av1_free_context_buffers(cm);
+    av1_free_shared_coeff_buffer(&cpi->td.shared_coeff_buf);
+    av1_free_sms_tree(&cpi->td);
+#if CONFIG_EXT_RECUR_PARTITIONS
+    av1_free_sms_bufs(&cpi->td);
+#endif  // CONFIG_EXT_RECUR_PARTITIONS
+    av1_free_pmc(cpi->td.firstpass_ctx, av1_num_planes(cm));
+    cpi->td.firstpass_ctx = NULL;
+    alloc_compressor_data(cpi);
+    if (av1_alloc_above_context_buffers(&cm->above_contexts, cm->tiles.rows,
+                                        cm->mi_params.mi_cols,
+                                        av1_num_planes(cm))) {
+      aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
+                         "Failed to allocate context buffers");
+    }
+  }
+
+  if (cm->seq_params.sb_size != old_sb_size) {
+    // Reallocate sb_size-dependent buffers if the sb_size has changed.
+    reallocate_sb_size_dependent_buffers(cpi);
+  }
 
   av1_zero(cm->cur_frame->interp_filter_selected);
   cm->prev_frame = get_primary_ref_frame_buf(cm);
diff --git a/av1/encoder/encoder_utils.h b/av1/encoder/encoder_utils.h
index 612bde5..5399797 100644
--- a/av1/encoder/encoder_utils.h
+++ b/av1/encoder/encoder_utils.h
@@ -248,6 +248,19 @@
            4;                                                               \
   }
 
+#if CONFIG_BLOCK_256
+MAKE_BFP_SAD_WRAPPER(aom_highbd_sad256x256)
+MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad256x256_avg)
+MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad256x256x4d)
+
+MAKE_BFP_SAD_WRAPPER(aom_highbd_sad256x128)
+MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad256x128_avg)
+MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad256x128x4d)
+
+MAKE_BFP_SAD_WRAPPER(aom_highbd_sad128x256)
+MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad128x256_avg)
+MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad128x256x4d)
+#endif  // CONFIG_BLOCK_256
 MAKE_BFP_SAD_WRAPPER(aom_highbd_sad128x128)
 MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad128x128_avg)
 MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad128x128x4d)
@@ -316,6 +329,11 @@
 MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad64x16_avg)
 MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x16x4d)
 
+#if CONFIG_BLOCK_256
+MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad256x256_avg)
+MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad256x128_avg)
+MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad128x256_avg)
+#endif  // CONFIG_BLOCK_256
 MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad128x128_avg)
 MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad128x64_avg)
 MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad64x128_avg)
@@ -373,6 +391,11 @@
            4;                                                              \
   }
 
+#if CONFIG_BLOCK_256
+MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad256x256)
+MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad256x128)
+MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad128x256)
+#endif  // CONFIG_BLOCK_256
 MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad128x128)
 MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad128x64)
 MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad64x128)
@@ -440,6 +463,11 @@
     for (i = 0; i < 4; i++) sad_array[i] >>= 4;                                \
   }
 
+#if CONFIG_BLOCK_256
+MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_256x256)
+MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_256x128)
+MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_128x256)
+#endif  // CONFIG_BLOCK_256
 MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_128x128)
 MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_128x64)
 MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_64x128)
@@ -460,6 +488,11 @@
 MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_4x8)
 MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_8x32)
 
+#if CONFIG_BLOCK_256
+MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_256x256x4d)
+MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_256x128x4d)
+MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_128x256x4d)
+#endif  // CONFIG_BLOCK_256
 MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_128x128x4d)
 MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_128x64x4d)
 MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_64x128x4d)
@@ -514,6 +547,11 @@
     return fnname(ref, ref_stride, wsrc, msk) >> 4;                        \
   }
 
+#if CONFIG_BLOCK_256
+MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad256x256)
+MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad256x128)
+MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad128x256)
+#endif  // CONFIG_BLOCK_256
 MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad128x128)
 MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad128x64)
 MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad64x128)
@@ -563,7 +601,15 @@
       HIGHBD_BFP_WRAPPER(128, 128, 8)
       HIGHBD_BFP_WRAPPER(128, 64, 8)
       HIGHBD_BFP_WRAPPER(64, 128, 8)
+#if CONFIG_BLOCK_256
+      HIGHBD_BFP_WRAPPER(128, 256, 8)
+      HIGHBD_BFP_WRAPPER(256, 128, 8)
+      HIGHBD_BFP_WRAPPER(256, 256, 8)
 
+      HIGHBD_MBFP_WRAPPER(256, 256, 8)
+      HIGHBD_MBFP_WRAPPER(256, 128, 8)
+      HIGHBD_MBFP_WRAPPER(128, 256, 8)
+#endif  // CONFIG_BLOCK_128
       HIGHBD_MBFP_WRAPPER(128, 128, 8)
       HIGHBD_MBFP_WRAPPER(128, 64, 8)
       HIGHBD_MBFP_WRAPPER(64, 128, 8)
@@ -587,6 +633,11 @@
       HIGHBD_MBFP_WRAPPER(16, 4, 8)
       HIGHBD_MBFP_WRAPPER(4, 16, 8)
 
+#if CONFIG_BLOCK_256
+      LOWBD_OBFP_WRAPPER(256, 256)
+      LOWBD_OBFP_WRAPPER(256, 128)
+      LOWBD_OBFP_WRAPPER(128, 256)
+#endif  // CONFIG_BLOCK_128
       LOWBD_OBFP_WRAPPER(128, 128)
       LOWBD_OBFP_WRAPPER(128, 64)
       LOWBD_OBFP_WRAPPER(64, 128)
@@ -610,6 +661,11 @@
       LOWBD_OBFP_WRAPPER(16, 4)
       LOWBD_OBFP_WRAPPER(4, 16)
 
+#if CONFIG_BLOCK_256
+      HIGHBD_SDSFP_WRAPPER(256, 256, 8)
+      HIGHBD_SDSFP_WRAPPER(256, 128, 8)
+      HIGHBD_SDSFP_WRAPPER(128, 256, 8)
+#endif  // CONFIG_BLOCK_128
       HIGHBD_SDSFP_WRAPPER(128, 128, 8);
       HIGHBD_SDSFP_WRAPPER(128, 64, 8);
       HIGHBD_SDSFP_WRAPPER(64, 128, 8);
@@ -654,7 +710,15 @@
       HIGHBD_BFP_WRAPPER(128, 128, 10)
       HIGHBD_BFP_WRAPPER(128, 64, 10)
       HIGHBD_BFP_WRAPPER(64, 128, 10)
+#if CONFIG_BLOCK_256
+      HIGHBD_BFP_WRAPPER(128, 256, 10)
+      HIGHBD_BFP_WRAPPER(256, 128, 10)
+      HIGHBD_BFP_WRAPPER(256, 256, 10)
 
+      HIGHBD_MBFP_WRAPPER(256, 256, 10)
+      HIGHBD_MBFP_WRAPPER(256, 128, 10)
+      HIGHBD_MBFP_WRAPPER(128, 256, 10)
+#endif  // CONFIG_BLOCK_128
       HIGHBD_MBFP_WRAPPER(128, 128, 10)
       HIGHBD_MBFP_WRAPPER(128, 64, 10)
       HIGHBD_MBFP_WRAPPER(64, 128, 10)
@@ -678,6 +742,11 @@
       HIGHBD_MBFP_WRAPPER(16, 4, 10)
       HIGHBD_MBFP_WRAPPER(4, 16, 10)
 
+#if CONFIG_BLOCK_256
+      HIGHBD_OBFP_WRAPPER(256, 256, 10)
+      HIGHBD_OBFP_WRAPPER(256, 128, 10)
+      HIGHBD_OBFP_WRAPPER(128, 256, 10)
+#endif  // CONFIG_BLOCK_128
       HIGHBD_OBFP_WRAPPER(128, 128, 10)
       HIGHBD_OBFP_WRAPPER(128, 64, 10)
       HIGHBD_OBFP_WRAPPER(64, 128, 10)
@@ -701,6 +770,11 @@
       HIGHBD_OBFP_WRAPPER(16, 4, 10)
       HIGHBD_OBFP_WRAPPER(4, 16, 10)
 
+#if CONFIG_BLOCK_256
+      HIGHBD_SDSFP_WRAPPER(256, 256, 10)
+      HIGHBD_SDSFP_WRAPPER(256, 128, 10)
+      HIGHBD_SDSFP_WRAPPER(128, 256, 10)
+#endif  // CONFIG_BLOCK_128
       HIGHBD_SDSFP_WRAPPER(128, 128, 10);
       HIGHBD_SDSFP_WRAPPER(128, 64, 10);
       HIGHBD_SDSFP_WRAPPER(64, 128, 10);
@@ -745,7 +819,15 @@
       HIGHBD_BFP_WRAPPER(128, 128, 12)
       HIGHBD_BFP_WRAPPER(128, 64, 12)
       HIGHBD_BFP_WRAPPER(64, 128, 12)
+#if CONFIG_BLOCK_256
+      HIGHBD_BFP_WRAPPER(128, 256, 12)
+      HIGHBD_BFP_WRAPPER(256, 128, 12)
+      HIGHBD_BFP_WRAPPER(256, 256, 12)
 
+      HIGHBD_MBFP_WRAPPER(128, 256, 12)
+      HIGHBD_MBFP_WRAPPER(256, 128, 12)
+      HIGHBD_MBFP_WRAPPER(256, 256, 12)
+#endif  // CONFIG_BLOCK_128
       HIGHBD_MBFP_WRAPPER(128, 128, 12)
       HIGHBD_MBFP_WRAPPER(128, 64, 12)
       HIGHBD_MBFP_WRAPPER(64, 128, 12)
@@ -769,6 +851,11 @@
       HIGHBD_MBFP_WRAPPER(16, 4, 12)
       HIGHBD_MBFP_WRAPPER(4, 16, 12)
 
+#if CONFIG_BLOCK_256
+      HIGHBD_OBFP_WRAPPER(256, 256, 12)
+      HIGHBD_OBFP_WRAPPER(256, 128, 12)
+      HIGHBD_OBFP_WRAPPER(128, 256, 12)
+#endif  // CONFIG_BLOCK_128
       HIGHBD_OBFP_WRAPPER(128, 128, 12)
       HIGHBD_OBFP_WRAPPER(128, 64, 12)
       HIGHBD_OBFP_WRAPPER(64, 128, 12)
@@ -792,6 +879,11 @@
       HIGHBD_OBFP_WRAPPER(16, 4, 12)
       HIGHBD_OBFP_WRAPPER(4, 16, 12)
 
+#if CONFIG_BLOCK_256
+      HIGHBD_SDSFP_WRAPPER(256, 256, 12)
+      HIGHBD_SDSFP_WRAPPER(256, 128, 12)
+      HIGHBD_SDSFP_WRAPPER(128, 256, 12)
+#endif  // CONFIG_BLOCK_128
       HIGHBD_SDSFP_WRAPPER(128, 128, 12);
       HIGHBD_SDSFP_WRAPPER(128, 64, 12);
       HIGHBD_SDSFP_WRAPPER(64, 128, 12);
@@ -996,6 +1088,54 @@
 
 void av1_save_all_coding_context(AV1_COMP *cpi);
 
+static AOM_INLINE void av1_set_tile_info(AV1_COMMON *const cm,
+                                         const TileConfig *const tile_cfg) {
+  const CommonModeInfoParams *const mi_params = &cm->mi_params;
+  CommonTileParams *const tiles = &cm->tiles;
+  int i, start_sb;
+
+  av1_get_tile_limits(cm);
+
+  // configure tile columns
+  if (tile_cfg->tile_width_count == 0 || tile_cfg->tile_height_count == 0) {
+    tiles->uniform_spacing = 1;
+    tiles->log2_cols = AOMMAX(tile_cfg->tile_columns, tiles->min_log2_cols);
+    tiles->log2_cols = AOMMIN(tiles->log2_cols, tiles->max_log2_cols);
+  } else {
+    int mi_cols = ALIGN_POWER_OF_TWO(mi_params->mi_cols, cm->mib_size_log2);
+    int sb_cols = mi_cols >> cm->mib_size_log2;
+    int size_sb, j = 0;
+    tiles->uniform_spacing = 0;
+    for (i = 0, start_sb = 0; start_sb < sb_cols && i < MAX_TILE_COLS; i++) {
+      tiles->col_start_sb[i] = start_sb;
+      size_sb = tile_cfg->tile_widths[j++];
+      if (j >= tile_cfg->tile_width_count) j = 0;
+      start_sb += AOMMIN(size_sb, tiles->max_width_sb);
+    }
+    tiles->cols = i;
+    tiles->col_start_sb[i] = sb_cols;
+  }
+  av1_calculate_tile_cols(cm, mi_params->mi_rows, mi_params->mi_cols, tiles);
+
+  // configure tile rows
+  if (tiles->uniform_spacing) {
+    tiles->log2_rows = AOMMAX(tile_cfg->tile_rows, tiles->min_log2_rows);
+    tiles->log2_rows = AOMMIN(tiles->log2_rows, tiles->max_log2_rows);
+  } else {
+    int mi_rows = ALIGN_POWER_OF_TWO(mi_params->mi_rows, cm->mib_size_log2);
+    int sb_rows = mi_rows >> cm->mib_size_log2;
+    int size_sb, j = 0;
+    for (i = 0, start_sb = 0; start_sb < sb_rows && i < MAX_TILE_ROWS; i++) {
+      tiles->row_start_sb[i] = start_sb;
+      size_sb = tile_cfg->tile_heights[j++];
+      if (j >= tile_cfg->tile_height_count) j = 0;
+      start_sb += AOMMIN(size_sb, tiles->max_height_sb);
+    }
+    tiles->rows = i;
+    tiles->row_start_sb[i] = sb_rows;
+  }
+  av1_calculate_tile_rows(cm, mi_params->mi_rows, tiles);
+}
 #ifdef __cplusplus
 }  // extern "C"
 #endif
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index b841090..0a14dff 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -96,8 +96,11 @@
 
 void av1_alloc_txb_buf(AV1_COMP *cpi) {
   AV1_COMMON *cm = &cpi->common;
-  int size = ((cm->mi_params.mi_rows >> cm->seq_params.mib_size_log2) + 1) *
-             ((cm->mi_params.mi_cols >> cm->seq_params.mib_size_log2) + 1);
+  // We use the frame level sb size here instead of the seq level sb size. This
+  // is because fr_sb_size <= seq_sb_size, and we want to avoid repeated
+  // allocations. So we prefer to to allocate a larger memory in one go here.
+  int size = ((cm->mi_params.mi_rows >> cm->mib_size_log2) + 1) *
+             ((cm->mi_params.mi_cols >> cm->mib_size_log2) + 1);
 
   av1_free_txb_buf(cpi);
   // TODO(jingning): This should be further reduced.
@@ -4760,7 +4763,7 @@
 CB_COEFF_BUFFER *av1_get_cb_coeff_buffer(const struct AV1_COMP *cpi, int mi_row,
                                          int mi_col) {
   const AV1_COMMON *const cm = &cpi->common;
-  const int mib_size_log2 = cm->seq_params.mib_size_log2;
+  const int mib_size_log2 = cm->mib_size_log2;
   const int stride = (cm->mi_params.mi_cols >> mib_size_log2) + 1;
   const int offset =
       (mi_row >> mib_size_log2) * stride + (mi_col >> mib_size_log2);
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index f606924..a1d0de8 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -50,7 +50,7 @@
 static AOM_INLINE void update_delta_lf_for_row_mt(AV1_COMP *cpi) {
   AV1_COMMON *cm = &cpi->common;
   MACROBLOCKD *xd = &cpi->td.mb.e_mbd;
-  const int mib_size = cm->seq_params.mib_size;
+  const int mib_size = cm->mib_size;
   const int frame_lf_count =
       av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
   for (int row = 0; row < cm->tiles.rows; row++) {
@@ -67,8 +67,7 @@
           MB_MODE_INFO **mi = cm->mi_params.mi_grid_base + idx_str;
           MB_MODE_INFO *mbmi = mi[0];
           if (mbmi->skip_txfm[xd->tree_type == CHROMA_PART] == 1 &&
-              (mbmi->sb_type[xd->tree_type == CHROMA_PART] ==
-               cm->seq_params.sb_size)) {
+              (mbmi->sb_type[xd->tree_type == CHROMA_PART] == cm->sb_size)) {
             for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id)
               mbmi->delta_lf[lf_id] = xd->delta_lf[lf_id];
             mbmi->delta_lf_from_base = xd->delta_lf_from_base;
@@ -351,7 +350,7 @@
     // which will be the least processed tile.
     *cur_tile_id = tile_id;
     get_next_job(&tile_data[tile_id], current_mi_row,
-                 is_firstpass ? FP_MIB_SIZE : cm->seq_params.mib_size);
+                 is_firstpass ? FP_MIB_SIZE : cm->mib_size);
   }
 }
 
@@ -428,7 +427,7 @@
     pthread_mutex_lock(enc_row_mt_mutex_);
 #endif
     if (!get_next_job(&cpi->tile_data[cur_tile_id], &current_mi_row,
-                      cm->seq_params.mib_size)) {
+                      cm->mib_size)) {
       // No jobs are available for the current tile. Query for the status of
       // other tiles and get the next job if available
       switch_tile_and_get_next_job(cm, cpi->tile_data, &cur_tile_id,
@@ -553,6 +552,7 @@
     thread_data->thread_id = i;
 
     if (i > 0) {
+      thread_data->td->sb_size = cpi->td.sb_size;
       // Set up sms_tree.
       av1_setup_sms_tree(cpi, thread_data->td);
 #if CONFIG_EXT_RECUR_PARTITIONS
@@ -788,6 +788,10 @@
     if (thread_data->td->counts != &cpi->counts) {
       memcpy(thread_data->td->counts, &cpi->counts, sizeof(cpi->counts));
     }
+    if (thread_data->td->sb_size != cpi->common.sb_size) {
+      av1_free_sms_tree(thread_data->td);
+      av1_setup_sms_tree(cpi, thread_data->td);
+    }
 
     if (i > 0) {
       thread_data->td->mb.palette_buffer = thread_data->td->palette_buffer;
diff --git a/av1/encoder/hash.h b/av1/encoder/hash.h
index 143947a..a06a149 100644
--- a/av1/encoder/hash.h
+++ b/av1/encoder/hash.h
@@ -45,7 +45,7 @@
 // init table for software version crc32c
 void av1_crc32c_calculator_init(CRC32C *p_crc32c);
 
-#define AOM_BUFFER_SIZE_FOR_BLOCK_HASH (4096)
+#define AOM_BUFFER_SIZE_FOR_BLOCK_HASH (1 << (2 * (MAX_SB_SIZE_LOG2 - 1)))
 
 #ifdef __cplusplus
 }  // extern "C"
diff --git a/av1/encoder/hash_motion.c b/av1/encoder/hash_motion.c
index 1d501c5..879c4fe 100644
--- a/av1/encoder/hash_motion.c
+++ b/av1/encoder/hash_motion.c
@@ -50,7 +50,7 @@
 }
 
 // the hash value (hash_value1 consists two parts, the first 3 bits relate to
-// the block size and the remaining 16 bits are the crc values. This fuction
+// the block size and the remaining 16 bits are the crc values. This function
 // is used to get the first 3 bits.
 static int hash_block_size_to_index(int block_size) {
   switch (block_size) {
@@ -60,6 +60,9 @@
     case 32: return 3;
     case 64: return 4;
     case 128: return 5;
+#if CONFIG_BLOCK_256
+    case 256: return 6;
+#endif  // CONFIG_BLOCK_256
     default: return -1;
   }
 }
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index dd5ab29..6ab4fcb 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -147,12 +147,18 @@
   init_ms_buffers(&ms_params->ms_buffers, x);
 
   SEARCH_METHODS search_method = mv_sf->search_method;
+  const int min_dim = AOMMIN(block_size_wide[bsize], block_size_high[bsize]);
   if (mv_sf->use_bsize_dependent_search_method) {
-    const int min_dim = AOMMIN(block_size_wide[bsize], block_size_high[bsize]);
     if (min_dim >= 32) {
       search_method = get_faster_search_method(search_method);
     }
   }
+#if CONFIG_BLOCK_256
+  const int max_dim = AOMMAX(block_size_wide[bsize], block_size_high[bsize]);
+  if (cpi->sf.mv_sf.fast_motion_estimation_on_block_256 && max_dim >= 256) {
+    search_method = get_faster_search_method(search_method);
+  }
+#endif  // CONFIG_BLOCK_256
 #if CONFIG_FLEX_MVRES
   // MV search of flex MV precision is supported only for NSTEP or DIAMOND
   // search
@@ -307,6 +313,13 @@
   ms_params->var_params.subpel_search_type =
       cpi->sf.mv_sf.use_accurate_subpel_search;
 #endif
+#if CONFIG_BLOCK_256
+  if (cpi->sf.mv_sf.fast_motion_estimation_on_block_256 &&
+      AOMMAX(block_size_wide[bsize], block_size_high[bsize]) >= 256) {
+    ms_params->var_params.subpel_search_type =
+        AOMMIN(ms_params->var_params.subpel_search_type, USE_2_TAPS);
+  }
+#endif  // CONFIG_BLOCK_256
 
   ms_params->var_params.w = block_size_wide[bsize];
   ms_params->var_params.h = block_size_high[bsize];
@@ -2738,8 +2751,13 @@
   // Should we allow a follow on exhaustive search?
   if (!run_mesh_search && search_method == NSTEP) {
     int exhaustive_thr = ms_params->force_mesh_thresh;
-    exhaustive_thr >>=
+    const int right_shift =
         10 - (mi_size_wide_log2[bsize] + mi_size_high_log2[bsize]);
+    if (right_shift >= 0) {
+      exhaustive_thr >>= right_shift;
+    } else {
+      exhaustive_thr <<= (-right_shift);
+    }
     // Threshold variance for an exhaustive full search.
     if (var > exhaustive_thr) run_mesh_search = 1;
   }
@@ -2855,7 +2873,7 @@
   const FullMvLimits *mv_limits = &ms_params->mv_limits;
   const MV *dv = ms_params->mv_cost_params.ref_mv;
   if (!av1_is_dv_valid(*dv, &cpi->common, xd, mi_row, mi_col, bsize,
-                       cpi->common.seq_params.mib_size_log2))
+                       cpi->common.mib_size_log2))
     return INT_MAX;
 
   FULLPEL_MV cur_mv = get_fullmv_from_mv(dv);
@@ -2890,7 +2908,7 @@
     const TileInfo *const tile = &fullms_params->xd->tile;
     const AV1_COMMON *cm = fullms_params->cm;
     const int mi_row = fullms_params->mi_row;
-    av1_find_ref_dv(cur_ref_bv, tile, cm->seq_params.mib_size, mi_row);
+    av1_find_ref_dv(cur_ref_bv, tile, cm->mib_size, mi_row);
   }
   // Ref DV should not have sub-pel.
   assert((cur_ref_bv->as_mv.col & 7) == 0);
@@ -3041,7 +3059,7 @@
       const MV dv = { GET_MV_SUBPEL(ref_block_hash.y - y_pos),
                       GET_MV_SUBPEL(ref_block_hash.x - x_pos) };
       if (!av1_is_dv_valid(dv, &cpi->common, xd, mi_row, mi_col, bsize,
-                           cpi->common.seq_params.mib_size_log2))
+                           cpi->common.mib_size_log2))
         continue;
 
       FULLPEL_MV hash_mv;
diff --git a/av1/encoder/motion_search_facade.c b/av1/encoder/motion_search_facade.c
index 891fa86..b6481a4 100644
--- a/av1/encoder/motion_search_facade.c
+++ b/av1/encoder/motion_search_facade.c
@@ -163,8 +163,8 @@
       const int nh = mi_size_high[bsize] / tplh;
 
       if (nw >= 1 && nh >= 1) {
-        const int of_h = mi_row % mi_size_high[cm->seq_params.sb_size];
-        const int of_w = mi_col % mi_size_wide[cm->seq_params.sb_size];
+        const int of_h = mi_row % mi_size_high[cm->sb_size];
+        const int of_w = mi_col % mi_size_wide[cm->sb_size];
         const int start = of_h / tplh * sb_enc->tpl_stride + of_w / tplw;
         int valid = 1;
 
diff --git a/av1/encoder/mv_prec.c b/av1/encoder/mv_prec.c
index 3746342..2b0f175 100644
--- a/av1/encoder/mv_prec.c
+++ b/av1/encoder/mv_prec.c
@@ -682,15 +682,16 @@
       collect_mv_stats_b(mv_stats, cpi, mi_row, mi_col + hbs_w);
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
       break;
-#if !CONFIG_EXT_RECUR_PARTITIONS
     case PARTITION_SPLIT:
-      collect_mv_stats_sb(mv_stats, cpi, mi_row, mi_col, subsize);
-      collect_mv_stats_sb(mv_stats, cpi, mi_row, mi_col + hbs_w, subsize);
-      collect_mv_stats_sb(mv_stats, cpi, mi_row + hbs_h, mi_col, subsize);
+      collect_mv_stats_sb(mv_stats, cpi, mi_row, mi_col, subsize,
+                          ptree->sub_tree[0]);
+      collect_mv_stats_sb(mv_stats, cpi, mi_row, mi_col + hbs_w, subsize,
+                          ptree->sub_tree[1]);
+      collect_mv_stats_sb(mv_stats, cpi, mi_row + hbs_h, mi_col, subsize,
+                          ptree->sub_tree[2]);
       collect_mv_stats_sb(mv_stats, cpi, mi_row + hbs_h, mi_col + hbs_w,
-                          subsize);
+                          subsize, ptree->sub_tree[3]);
       break;
-#endif  // !CONFIG_EXT_RECUR_PARTITIONS
 #if CONFIG_EXT_RECUR_PARTITIONS
 #if CONFIG_UNEVEN_4WAY
     case PARTITION_HORZ_4A: {
@@ -815,8 +816,8 @@
   const int mi_row_end = tile_info->mi_row_end;
   const int mi_col_start = tile_info->mi_col_start;
   const int mi_col_end = tile_info->mi_col_end;
-  const int sb_size_mi = cm->seq_params.mib_size;
-  BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const int sb_size_mi = cm->mib_size;
+  BLOCK_SIZE sb_size = cm->sb_size;
   for (int mi_row = mi_row_start; mi_row < mi_row_end; mi_row += sb_size_mi) {
     for (int mi_col = mi_col_start; mi_col < mi_col_end; mi_col += sb_size_mi) {
 #if CONFIG_EXT_RECUR_PARTITIONS
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c
index 8758d6b..75de5fa 100644
--- a/av1/encoder/partition_search.c
+++ b/av1/encoder/partition_search.c
@@ -613,7 +613,7 @@
     }
   }
 
-  av1_mark_block_as_coded(xd, bsize, cm->seq_params.sb_size);
+  av1_mark_block_as_coded(xd, bsize, cm->sb_size);
 }
 
 void setup_block_rdmult(const AV1_COMP *const cpi, MACROBLOCK *const x,
@@ -1251,12 +1251,11 @@
 
 #if CONFIG_ENTROPY_STATS
   // delta quant applies to both intra and inter
-  const int super_block_upper_left =
-      ((xd->mi_row & (cm->seq_params.mib_size - 1)) == 0) &&
-      ((xd->mi_col & (cm->seq_params.mib_size - 1)) == 0);
+  const int super_block_upper_left = ((xd->mi_row & (cm->mib_size - 1)) == 0) &&
+                                     ((xd->mi_col & (cm->mib_size - 1)) == 0);
   const DeltaQInfo *const delta_q_info = &cm->delta_q_info;
   if (delta_q_info->delta_q_present_flag &&
-      (bsize != cm->seq_params.sb_size ||
+      (bsize != cm->sb_size ||
        !mbmi->skip_txfm[xd->tree_type == CHROMA_PART]) &&
       super_block_upper_left) {
     const int dq = (mbmi->current_qindex - xd->current_base_qindex) /
@@ -2034,7 +2033,7 @@
     for (int plane = plane_start; plane < plane_end; plane++) {
       x->mbmi_ext_frame->cb_offset[plane] = x->cb_offset[plane];
       assert(x->cb_offset[plane] <
-             (1 << num_pels_log2_lookup[cpi->common.seq_params.sb_size]));
+             (1 << num_pels_log2_lookup[cpi->common.sb_size]));
     }
 #if CONFIG_PC_WIENER
     av1_init_txk_skip_array(&cpi->common, mi_row, mi_col, bsize, 0,
@@ -2056,7 +2055,7 @@
             block_size_wide[bsize_base] * block_size_high[bsize_base];
       }
     }
-    if (bsize == cpi->common.seq_params.sb_size &&
+    if (bsize == cpi->common.sb_size &&
         mbmi->skip_txfm[xd->tree_type == CHROMA_PART] == 1 &&
         cm->delta_q_info.delta_lf_present_flag) {
       const int frame_lf_count =
@@ -2073,12 +2072,11 @@
     }
 
     // delta quant applies to both intra and inter
-    const int super_block_upper_left =
-        ((mi_row & (cm->seq_params.mib_size - 1)) == 0) &&
-        ((mi_col & (cm->seq_params.mib_size - 1)) == 0);
+    const int super_block_upper_left = ((mi_row & (cm->mib_size - 1)) == 0) &&
+                                       ((mi_col & (cm->mib_size - 1)) == 0);
     const DeltaQInfo *const delta_q_info = &cm->delta_q_info;
     if (delta_q_info->delta_q_present_flag &&
-        (bsize != cm->seq_params.sb_size ||
+        (bsize != cm->sb_size ||
          !mbmi->skip_txfm[xd->tree_type == CHROMA_PART]) &&
         super_block_upper_left) {
       xd->current_base_qindex = mbmi->current_qindex;
@@ -2243,36 +2241,25 @@
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
                                    PARTITION_TYPE partition, const int mi_row,
                                    const int mi_col, BLOCK_SIZE bsize,
-                                   const int ctx) {
-  const int plane_index = xd->tree_type == CHROMA_PART;
+                                   const int ctx, BLOCK_SIZE sb_size) {
+#if !CONFIG_BLOCK_256
+  (void)sb_size;
+#endif  // !CONFIG_BLOCK_256
+  const TREE_TYPE tree_type = xd->tree_type;
+  const int plane_index = tree_type == CHROMA_PART;
   FRAME_CONTEXT *fc = xd->tile_ctx;
 
 #if CONFIG_EXT_RECUR_PARTITIONS
-  if (!is_partition_point(bsize)) {
-    return;
-  }
-  if (xd->tree_type == CHROMA_PART && bsize == BLOCK_8X8) {
-    return;
-  }
+  const bool ss_x = xd->plane[1].subsampling_x;
+  const bool ss_y = xd->plane[1].subsampling_y;
 
-  const int ss_x = xd->plane[1].subsampling_x;
-  const int ss_y = xd->plane[1].subsampling_y;
-  if (is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize)) {
-    PARTITION_TYPE derived_partition_mode =
-        sdp_chroma_part_from_luma(bsize, ptree_luma->partition, ss_x, ss_y);
-    assert(partition == derived_partition_mode &&
-           "Chroma partition does not match the derived mode.");
-    (void)derived_partition_mode;
-    return;
-  }
-
-  PARTITION_TYPE implied_partition;
-  const bool is_part_implied = is_partition_implied_at_boundary(
-      mi_params, xd->tree_type, ss_x, ss_y, mi_row, mi_col, bsize,
-      chroma_ref_info, &implied_partition);
-  if (is_part_implied) {
-    assert(partition == implied_partition &&
-           "Partition doesn't match the implied partition at boundary.");
+  const PARTITION_TYPE derived_partition =
+      av1_get_normative_forced_partition_type(mi_params, tree_type, ss_x, ss_y,
+                                              mi_row, mi_col, bsize, ptree_luma,
+                                              chroma_ref_info);
+  if (derived_partition != PARTITION_INVALID) {
+    assert(partition == derived_partition &&
+           "Partition does not match normatively derived partition.");
     return;
   }
 
@@ -2286,16 +2273,34 @@
   if (!do_split) {
     return;
   }
+
+#if CONFIG_BLOCK_256
+  const bool do_square_split = partition == PARTITION_SPLIT;
+  if (is_square_split_eligible(bsize, sb_size)) {
+    const int square_split_ctx =
+        square_split_context(xd, mi_row, mi_col, bsize);
+#if CONFIG_ENTROPY_STATS
+    counts->do_sqaure_split[plane_index][square_split_ctx][do_square_split]++;
+#endif  // CONFIG_ENTROPY_STATS
+    update_cdf(fc->do_square_split_cdf[plane_index][square_split_ctx],
+               do_square_split, 2);
+  }
+  if (do_square_split) {
+    return;
+  }
+#endif  // CONFIG_BLOCK_256
+
   RECT_PART_TYPE rect_type = get_rect_part_type(partition);
-  if (rect_type_implied_by_bsize(bsize, xd->tree_type) == RECT_INVALID) {
+  if (rect_type_implied_by_bsize(bsize, tree_type) == RECT_INVALID) {
 #if CONFIG_ENTROPY_STATS
     counts->rect_type[plane_index][ctx][rect_type]++;
 #endif  // CONFIG_ENTROPY_STATS
     update_cdf(fc->rect_type_cdf[plane_index][ctx], rect_type, 2);
   }
+
   const bool ext_partition_allowed =
       !disable_ext_part &&
-      is_ext_partition_allowed(bsize, rect_type, xd->tree_type);
+      is_ext_partition_allowed(bsize, rect_type, tree_type);
   if (ext_partition_allowed) {
     const bool do_ext_partition = (partition >= PARTITION_HORZ_3);
 #if CONFIG_ENTROPY_STATS
@@ -2306,7 +2311,7 @@
 #if CONFIG_UNEVEN_4WAY
     if (do_ext_partition) {
       const bool uneven_4way_partition_allowed =
-          is_uneven_4way_partition_allowed(bsize, rect_type, xd->tree_type);
+          is_uneven_4way_partition_allowed(bsize, rect_type, tree_type);
       if (uneven_4way_partition_allowed) {
         const bool do_uneven_4way_partition = (partition >= PARTITION_HORZ_4A);
 #if CONFIG_ENTROPY_STATS
@@ -2341,8 +2346,7 @@
   if (has_rows && has_cols) {
     int luma_split_flag = 0;
     int parent_block_width = block_size_wide[bsize];
-    if (xd->tree_type == CHROMA_PART &&
-        parent_block_width >= SHARED_PART_SIZE) {
+    if (tree_type == CHROMA_PART && parent_block_width >= SHARED_PART_SIZE) {
       luma_split_flag = get_luma_split_flag(bsize, mi_params, mi_row, mi_col);
     }
     if (luma_split_flag <= 3) {
@@ -2397,7 +2401,7 @@
                       TileDataEnc *tile_data, TokenExtra **tp, int mi_row,
                       int mi_col, RUN_TYPE dry_run, BLOCK_SIZE bsize,
                       const PC_TREE *pc_tree, PARTITION_TREE *ptree,
-                      PARTITION_TREE *ptree_luma, int *rate) {
+                      const PARTITION_TREE *ptree_luma, int *rate) {
 #else
 /*!\brief Reconstructs a partition (may contain multiple coding blocks)
  *
@@ -2468,9 +2472,6 @@
 #endif  // !CONFIG_EXT_RECUR_PARTITIONS
 
   if (subsize == BLOCK_INVALID) return;
-#if CONFIG_EXT_RECUR_PARTITIONS
-  assert(partition != PARTITION_SPLIT);
-#endif  // CONFIG_EXT_RECUR_PARTITIONS
 
   if (!dry_run && ctx >= 0)
     update_partition_stats(xd,
@@ -2482,7 +2483,7 @@
                            disable_ext_part, ptree_luma,
                            &pc_tree->chroma_ref_info,
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
-                           partition, mi_row, mi_col, bsize, ctx);
+                           partition, mi_row, mi_col, bsize, ctx, cm->sb_size);
 
   PARTITION_TREE *sub_tree[4] = { NULL, NULL, NULL, NULL };
 #if CONFIG_EXT_RECUR_PARTITIONS
@@ -2543,8 +2544,15 @@
   const int track_ptree_luma =
       is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize);
 
-  if (track_ptree_luma && partition != PARTITION_NONE) {
-    assert(ptree_luma);
+  if (track_ptree_luma) {
+    assert(partition ==
+           sdp_chroma_part_from_luma(bsize, ptree_luma->partition,
+                                     cm->seq_params.subsampling_x,
+                                     cm->seq_params.subsampling_x));
+    if (partition != PARTITION_NONE) {
+      assert(ptree_luma);
+      assert(ptree_luma->sub_tree);
+    }
   }
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
   switch (partition) {
@@ -2705,6 +2713,20 @@
       }
       break;
     }
+    case PARTITION_SPLIT:
+      encode_sb(cpi, td, tile_data, tp, mi_row, mi_col, dry_run, subsize,
+                pc_tree->split[0], sub_tree[0],
+                track_ptree_luma ? ptree_luma->sub_tree[0] : NULL, rate);
+      encode_sb(cpi, td, tile_data, tp, mi_row, mi_col + hbs_w, dry_run,
+                subsize, pc_tree->split[1], sub_tree[1],
+                track_ptree_luma ? ptree_luma->sub_tree[1] : NULL, rate);
+      encode_sb(cpi, td, tile_data, tp, mi_row + hbs_h, mi_col, dry_run,
+                subsize, pc_tree->split[2], sub_tree[2],
+                track_ptree_luma ? ptree_luma->sub_tree[2] : NULL, rate);
+      encode_sb(cpi, td, tile_data, tp, mi_row + hbs_h, mi_col + hbs_w, dry_run,
+                subsize, pc_tree->split[3], sub_tree[3],
+                track_ptree_luma ? ptree_luma->sub_tree[3] : NULL, rate);
+      break;
 #else   // CONFIG_EXT_RECUR_PARTITIONS
     case PARTITION_SPLIT:
       encode_sb(cpi, td, tile_data, tp, mi_row, mi_col, dry_run, subsize,
@@ -2829,18 +2851,36 @@
     first_partition = PARTITION_VERT;
   }
   assert(first_partition != PARTITION_INVALID);
-  const PARTITION_TYPE second_partition =
-      (first_partition == PARTITION_HORZ) ? PARTITION_VERT : PARTITION_HORZ;
 
+  const BLOCK_SIZE subsize = subsize_lookup[PARTITION_SPLIT][bsize];
   const int hbs_w = mi_size_wide[bsize] >> 1;
   const int hbs_h = mi_size_high[bsize] >> 1;
 
-  const BLOCK_SIZE subsize = subsize_lookup[PARTITION_SPLIT][bsize];
-
   ptree->partition = first_partition;
+
+  if (first_partition == PARTITION_SPLIT) {
+    ptree->partition = first_partition;
+    ptree->sub_tree[0] = av1_alloc_ptree_node(ptree, 0);
+    ptree->sub_tree[1] = av1_alloc_ptree_node(ptree, 1);
+    ptree->sub_tree[2] = av1_alloc_ptree_node(ptree, 2);
+    ptree->sub_tree[3] = av1_alloc_ptree_node(ptree, 3);
+    build_one_split_tree(cm, tree_type, mi_row, mi_col, subsize, final_bsize,
+                         ptree->sub_tree[0]);
+    build_one_split_tree(cm, tree_type, mi_row, mi_col + hbs_w, subsize,
+                         final_bsize, ptree->sub_tree[1]);
+    build_one_split_tree(cm, tree_type, mi_row + hbs_h, mi_col, subsize,
+                         final_bsize, ptree->sub_tree[2]);
+    build_one_split_tree(cm, tree_type, mi_row + hbs_h, mi_col + hbs_w, subsize,
+                         final_bsize, ptree->sub_tree[3]);
+    return;
+  }
+
   ptree->sub_tree[0] = av1_alloc_ptree_node(ptree, 0);
   ptree->sub_tree[1] = av1_alloc_ptree_node(ptree, 1);
 
+  const PARTITION_TYPE second_partition =
+      (first_partition == PARTITION_HORZ) ? PARTITION_VERT : PARTITION_HORZ;
+
 #ifndef NDEBUG
   // Boundary sanity checks for 2nd partitions.
   {
@@ -2905,7 +2945,7 @@
                                                  int mi_row, int mi_col,
                                                  BLOCK_SIZE bsize,
                                                  PARTITION_TREE *ptree) {
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
 
   build_one_split_tree(cm, tree_type, mi_row, mi_col, sb_size, bsize, ptree);
 }
@@ -2918,13 +2958,14 @@
   if (ptree) {
 #ifndef NDEBUG
 #if CONFIG_EXT_RECUR_PARTITIONS
-    const bool ssx = cm->cur_frame->buf.subsampling_x;
-    const bool ssy = cm->cur_frame->buf.subsampling_y;
-    PARTITION_TYPE implied_partition;
-    const bool is_part_implied = is_partition_implied_at_boundary(
-        &cm->mi_params, tree_type, ssx, ssy, mi_row, mi_col, bsize,
-        &ptree->chroma_ref_info, &implied_partition);
-    assert(IMPLIES(is_part_implied, ptree->partition == implied_partition));
+    const bool ss_x = cm->cur_frame->buf.subsampling_x;
+    const bool ss_y = cm->cur_frame->buf.subsampling_y;
+    const PARTITION_TYPE derived_partition =
+        av1_get_normative_forced_partition_type(
+            &cm->mi_params, tree_type, ss_x, ss_y, mi_row, mi_col, bsize,
+            /* ptree_luma= */ NULL, &ptree->chroma_ref_info);
+    assert(IMPLIES(derived_partition != PARTITION_INVALID,
+                   ptree->partition == derived_partition));
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 #endif  // NDEBUG
     return ptree->partition;
@@ -3159,6 +3200,37 @@
       }
       break;
 #if CONFIG_EXT_RECUR_PARTITIONS
+    case PARTITION_SPLIT:
+      last_part_rdc.rate = 0;
+      last_part_rdc.dist = 0;
+      last_part_rdc.rdcost = 0;
+      for (int i = 0; i < SUB_PARTITIONS_SPLIT; i++) {
+        int x_idx = (i & 1) * hbs;
+        int y_idx = (i >> 1) * hbs;
+        int jj = i >> 1, ii = i & 0x01;
+        RD_STATS tmp_rdc;
+        if ((mi_row + y_idx >= mi_params->mi_rows) ||
+            (mi_col + x_idx >= mi_params->mi_cols))
+          continue;
+        pc_tree->split[i] = av1_alloc_pc_tree_node(
+            xd->tree_type, mi_row + y_idx, mi_col + x_idx, subsize, pc_tree,
+            PARTITION_SPLIT, i, i == 3, ss_x, ss_y);
+
+        av1_init_rd_stats(&tmp_rdc);
+        av1_rd_use_partition(
+            cpi, td, tile_data,
+            mib + jj * hbs * mi_params->mi_stride + ii * hbs, tp,
+            mi_row + y_idx, mi_col + x_idx, subsize, &tmp_rdc.rate,
+            &tmp_rdc.dist, i != (SUB_PARTITIONS_SPLIT - 1),
+            ptree ? ptree->sub_tree[1] : NULL, pc_tree->split[i]);
+        if (tmp_rdc.rate == INT_MAX || tmp_rdc.dist == INT64_MAX) {
+          av1_invalid_rd_stats(&last_part_rdc);
+          break;
+        }
+        last_part_rdc.rate += tmp_rdc.rate;
+        last_part_rdc.dist += tmp_rdc.dist;
+      }
+      break;
 #if CONFIG_UNEVEN_4WAY
     case PARTITION_HORZ_4A:
     case PARTITION_HORZ_4B:
@@ -3222,11 +3294,11 @@
 
   // We must have chosen a partitioning and encoding or we'll fail later on.
   // No other opportunities for success.
-  if (bsize == cm->seq_params.sb_size)
+  if (bsize == cm->sb_size)
     assert(last_part_rdc.rate < INT_MAX && last_part_rdc.dist < INT64_MAX);
 
   if (do_recon) {
-    if (bsize == cm->seq_params.sb_size) {
+    if (bsize == cm->sb_size) {
       // NOTE: To get estimate for rate due to the tokens, use:
       // int rate_coeffs = 0;
       // encode_sb(cpi, td, tile_data, tp, mi_row, mi_col, DRY_RUN_COSTCOEFFS,
@@ -3397,29 +3469,25 @@
     BLOCK_SIZE bsize, const PARTITION_TREE *ptree_luma,
     const PARTITION_TREE *template_tree,
     const CHROMA_REF_INFO *chroma_ref_info) {
-  const MACROBLOCKD *const xd = &x->e_mbd;
-  const int ss_x = cm->seq_params.subsampling_x;
-  const int ss_y = cm->seq_params.subsampling_y;
-
   // Partition types forced by bitstream syntax.
-  if (is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize)) {
-    return sdp_chroma_part_from_luma(bsize, ptree_luma->partition, ss_x, ss_y);
+  const MACROBLOCKD *xd = &x->e_mbd;
+  const bool ss_x = cm->seq_params.subsampling_x;
+  const bool ss_y = cm->seq_params.subsampling_y;
+  const PARTITION_TYPE derived_partition =
+      av1_get_normative_forced_partition_type(&cm->mi_params, xd->tree_type,
+                                              ss_x, ss_y, mi_row, mi_col, bsize,
+                                              ptree_luma, chroma_ref_info);
+  if (derived_partition != PARTITION_INVALID) {
+    return derived_partition;
   }
 
-  PARTITION_TYPE implied_partition;
-  const bool is_part_implied = is_partition_implied_at_boundary(
-      &cm->mi_params, xd->tree_type, ss_x, ss_y, mi_row, mi_col, bsize,
-      chroma_ref_info, &implied_partition);
-  if (is_part_implied) return implied_partition;
-
   // Partition types forced by speed_features.
   if (template_tree) {
     return template_tree->partition;
   }
 
   if (should_reuse_mode(x, REUSE_PARTITION_MODE_FLAG)) {
-    return av1_get_prev_partition(x, mi_row, mi_col, bsize,
-                                  cm->seq_params.sb_size);
+    return av1_get_prev_partition(x, mi_row, mi_col, bsize, cm->sb_size);
   }
   return PARTITION_INVALID;
 }
@@ -3531,6 +3599,8 @@
   // than the bound best_rdc has been found.
   part_search_state->found_best_partition = false;
 }
+
+static const int kZeroPartitionCosts[ALL_PARTITION_TYPES];
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 // Initialize state variables of partition search used in
 // av1_rd_pick_partition().
@@ -3545,6 +3615,7 @@
   const AV1_COMMON *const cm = &cpi->common;
   PartitionBlkParams *blk_params = &part_search_state->part_blk_params;
   const CommonModeInfoParams *const mi_params = &cpi->common.mi_params;
+  const TREE_TYPE tree_type = xd->tree_type;
 
   assert(bsize < BLOCK_SIZES_ALL);
 
@@ -3577,6 +3648,10 @@
 #endif  // !CONFIG_EXT_RECUR_PARTITIONS
   blk_params->bsize = bsize;
 
+  // Chroma subsampling.
+  part_search_state->ss_x = x->e_mbd.plane[1].subsampling_x;
+  part_search_state->ss_y = x->e_mbd.plane[1].subsampling_y;
+
   // Check if the partition corresponds to edge block.
   blk_params->has_rows = (blk_params->mi_row_edge < mi_params->mi_rows);
   blk_params->has_cols = (blk_params->mi_col_edge < mi_params->mi_cols);
@@ -3607,8 +3682,16 @@
   // Partition cost buffer update
   ModeCosts *mode_costs = &x->mode_costs;
   part_search_state->partition_cost =
-      mode_costs->partition_cost[xd->tree_type == CHROMA_PART]
+      mode_costs->partition_cost[tree_type == CHROMA_PART]
                                 [part_search_state->pl_ctx_idx];
+#if CONFIG_EXT_RECUR_PARTITIONS
+  if (av1_get_normative_forced_partition_type(
+          mi_params, tree_type, part_search_state->ss_x,
+          part_search_state->ss_y, mi_row, mi_col, bsize, ptree_luma,
+          &pc_tree->chroma_ref_info) != PARTITION_INVALID) {
+    part_search_state->partition_cost = kZeroPartitionCosts;
+  }
+#endif  // CONFIG_EXT_RECUR_PARTITIONS
 
   // Initialize HORZ and VERT win flags as true for all split partitions.
   for (int i = 0; i < SUB_PARTITIONS_SPLIT; i++) {
@@ -3629,10 +3712,6 @@
   // Initialize HORZ and VERT partitions to be not ready.
   av1_zero(part_search_state->is_rect_ctx_is_ready);
 
-  // Chroma subsampling.
-  part_search_state->ss_x = x->e_mbd.plane[1].subsampling_x;
-  part_search_state->ss_y = x->e_mbd.plane[1].subsampling_y;
-
   // Initialize partition search flags to defaults.
   part_search_state->terminate_partition_search = 0;
 
@@ -3652,7 +3731,7 @@
                                 template_tree, &pc_tree->chroma_ref_info);
 
   init_allowed_partitions(part_search_state, &cpi->oxcf.part_cfg,
-                          &pc_tree->chroma_ref_info, xd->tree_type);
+                          &pc_tree->chroma_ref_info, tree_type);
 
   if (max_recursion_depth == 0) {
     part_search_state->prune_rect_part[HORZ] =
@@ -3669,10 +3748,10 @@
 #else
   part_search_state->do_square_split =
       blk_params->bsize_at_least_8x8 &&
-      (xd->tree_type != CHROMA_PART || bsize > BLOCK_8X8);
+      (tree_type != CHROMA_PART || bsize > BLOCK_8X8);
   part_search_state->do_rectangular_split =
       cpi->oxcf.part_cfg.enable_rect_partitions &&
-      (xd->tree_type != CHROMA_PART || bsize > BLOCK_8X8);
+      (tree_type != CHROMA_PART || bsize > BLOCK_8X8);
 
   const BLOCK_SIZE horz_subsize = get_partition_subsize(bsize, PARTITION_HORZ);
   const BLOCK_SIZE vert_subsize = get_partition_subsize(bsize, PARTITION_VERT);
@@ -3685,7 +3764,7 @@
       get_plane_block_size(vert_subsize, part_search_state->ss_x,
                            part_search_state->ss_y) != BLOCK_INVALID;
   const bool no_sub_16_chroma_part =
-      xd->tree_type != CHROMA_PART ||
+      tree_type != CHROMA_PART ||
       (block_size_wide[bsize] > 8 && block_size_high[bsize] > 8);
 
   // Initialize allowed partition types for the partition block.
@@ -3707,27 +3786,11 @@
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 }
 
+#if !CONFIG_EXT_RECUR_PARTITIONS
 // Override partition cost buffer for the edge blocks.
 static void set_partition_cost_for_edge_blk(
     AV1_COMMON const *cm, MACROBLOCKD *const xd,
-#if CONFIG_EXT_RECUR_PARTITIONS
-    const CHROMA_REF_INFO *chroma_ref_info,
-#endif  // CONFIG_EXT_RECUR_PARTITIONS
     PartitionSearchState *part_search_state) {
-#if CONFIG_EXT_RECUR_PARTITIONS
-  const PartitionBlkParams *blk_params = &part_search_state->part_blk_params;
-  const bool is_part_implied = is_partition_implied_at_boundary(
-      &cm->mi_params, xd->tree_type, part_search_state->ss_x,
-      part_search_state->ss_y, blk_params->mi_row, blk_params->mi_col,
-      blk_params->bsize, chroma_ref_info, NULL);
-  if (is_part_implied) {
-    for (int i = 0; i < PARTITION_TYPES; ++i) {
-      part_search_state->tmp_partition_cost[i] = 0;
-    }
-    part_search_state->partition_cost = part_search_state->tmp_partition_cost;
-  }
-  (void)xd;
-#else   // CONFIG_EXT_RECUR_PARTITIONS
   PartitionBlkParams blk_params = part_search_state->part_blk_params;
   assert(blk_params.bsize_at_least_8x8 && part_search_state->pl_ctx_idx >= 0);
   const int plane = xd->tree_type == CHROMA_PART;
@@ -3756,10 +3819,8 @@
   }
   // Override the partition cost buffer.
   part_search_state->partition_cost = part_search_state->tmp_partition_cost;
-#endif  // CONFIG_EXT_RECUR_PARTITIONS
 }
 
-#if !CONFIG_EXT_RECUR_PARTITIONS
 // Reset the partition search state flags when
 // must_find_valid_partition is equal to 1.
 static AOM_INLINE void reset_part_limitations(
@@ -4092,9 +4153,12 @@
         blk_params.subsize, pc_tree, partition_type, 1, 1, ss_x, ss_y);
 
     bool both_blocks_skippable = true;
-    const bool track_ptree_luma =
-        is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize);
 
+    const int track_ptree_luma =
+        is_luma_chroma_share_same_partition(x->e_mbd.tree_type, ptree_luma,
+                                            bsize) &&
+        partition_type ==
+            sdp_chroma_part_from_luma(bsize, ptree_luma->partition, ss_x, ss_y);
     rd_pick_rect_partition(
         cpi, td, tile_data, tp, x, pc_tree, part_search_state, best_rdc, i,
         mi_pos_rect, blk_params.subsize, is_not_edge_block, multi_pass_mode,
@@ -4189,10 +4253,15 @@
 #if CONFIG_EXT_RECUR_PARTITIONS
     if (sum_rdc->rdcost < INT64_MAX && both_blocks_skippable &&
         !frame_is_intra_only(cm)) {
-      const int64_t dist_breakout_thr =
-          (int64_t)(cpi->sf.part_sf.partition_search_breakout_dist_thr / 4) >>
-          ((2 * (MAX_SB_SIZE_LOG2 - 2)) -
+      const int right_shift =
+          ((2 * (BLOCK_128_MI_SIZE_LOG2)) -
            (mi_size_wide_log2[bsize] + mi_size_high_log2[bsize]));
+      const int64_t dist_breakout_thr =
+          (right_shift >= 0)
+              ? ((cpi->sf.part_sf.partition_search_breakout_dist_thr / 4) >>
+                 right_shift)
+              : ((cpi->sf.part_sf.partition_search_breakout_dist_thr / 4)
+                 << (-right_shift));
       const int rate_breakout_thr =
           (int64_t)25 * cpi->sf.part_sf.partition_search_breakout_rate_thr *
           num_pels_log2_lookup[bsize];
@@ -4731,10 +4800,15 @@
     }
 
     // Adjust dist breakout threshold according to the partition size.
-    const int64_t dist_breakout_thr =
-        cpi->sf.part_sf.partition_search_breakout_dist_thr >>
-        ((2 * (MAX_SB_SIZE_LOG2 - 2)) -
+    const int right_shift =
+        ((2 * (BLOCK_128_MI_SIZE_LOG2)) -
          (mi_size_wide_log2[bsize] + mi_size_high_log2[bsize]));
+    const int64_t dist_breakout_thr =
+        (right_shift >= 0)
+            ? (cpi->sf.part_sf.partition_search_breakout_dist_thr >>
+               right_shift)
+            : (cpi->sf.part_sf.partition_search_breakout_dist_thr
+               << (-right_shift));
     const int rate_breakout_thr =
         cpi->sf.part_sf.partition_search_breakout_rate_thr *
         num_pels_log2_lookup[bsize];
@@ -4887,8 +4961,8 @@
   }
 #endif
 #if CONFIG_EXT_RECUR_PARTITIONS
-  SimpleMotionData *sms_data = av1_get_sms_data_entry(
-      x->sms_bufs, mi_row, mi_col, bsize, cm->seq_params.sb_size);
+  SimpleMotionData *sms_data =
+      av1_get_sms_data_entry(x->sms_bufs, mi_row, mi_col, bsize, cm->sb_size);
   av1_set_best_mode_cache(x, sms_data->mode_cache);
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 
@@ -4925,8 +4999,8 @@
     // Record picked ref frame to prune ref frames for other partition types.
     if (cpi->sf.inter_sf.prune_ref_frame_for_rect_partitions) {
       const int ref_type = av1_ref_frame_type(pc_tree->none->mic.ref_frame);
-      av1_update_picked_ref_frames_mask(
-          x, ref_type, bsize, cm->seq_params.mib_size, mi_row, mi_col);
+      av1_update_picked_ref_frames_mask(x, ref_type, bsize, cm->mib_size,
+                                        mi_row, mi_col);
     }
 
     // Calculate the total cost and update the best partition.
@@ -4962,7 +5036,6 @@
 #endif  // CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
 }
 
-#if !CONFIG_EXT_RECUR_PARTITIONS
 // PARTITION_SPLIT search.
 static void split_partition_search(
     AV1_COMP *const cpi, ThreadData *td, TileDataEnc *tile_data,
@@ -4973,7 +5046,12 @@
 #if CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
     ,
     LevelBanksRDO *level_banks
-#endif  // CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
+#endif  // CONFIG_C043_MVP_IMPROVEMENTS
+#if CONFIG_EXT_RECUR_PARTITIONS
+    ,
+    const PARTITION_TREE *ptree_luma, const PARTITION_TREE *template_tree,
+    int max_recursion_depth
+#endif  // CONFIG_EXT_RECUR_PARTITIONS
 ) {
   const AV1_COMMON *const cm = &cpi->common;
   PartitionBlkParams blk_params = part_search_state->part_blk_params;
@@ -4986,9 +5064,38 @@
   const BLOCK_SIZE subsize = get_partition_subsize(bsize, PARTITION_SPLIT);
 
   // Check if partition split is allowed.
+#if CONFIG_EXT_RECUR_PARTITIONS
+  (void)sms_tree;
+  if (part_search_state->terminate_partition_search ||
+      !is_square_split_eligible(bsize, cm->sb_size)) {
+    return;
+  }
+  if (part_search_state->forced_partition != PARTITION_INVALID &&
+      part_search_state->forced_partition != PARTITION_SPLIT) {
+    return;
+  }
+  if (max_recursion_depth < 0) {
+    return;
+  }
+
+  const int num_planes = av1_num_planes(cm);
+  PC_TREE **sub_tree = pc_tree->split;
+  assert(sub_tree);
+  for (int idx = 0; idx < SUB_PARTITIONS_SPLIT; idx++) {
+    if (sub_tree[idx]) {
+      av1_free_pc_tree_recursive(sub_tree[idx], num_planes, 0, 0);
+      sub_tree[idx] = NULL;
+    }
+  }
+
+  const MACROBLOCKD *const xd = &x->e_mbd;
+  const int track_ptree_luma =
+      is_luma_chroma_share_same_partition(xd->tree_type, ptree_luma, bsize);
+#else
   if (part_search_state->terminate_partition_search ||
       !part_search_state->do_square_split)
     return;
+#endif  // CONFIG_EXT_RECUR_PARTITIONS
 
   // Initialization of this partition RD stats.
   av1_init_rd_stats(&sum_rdc);
@@ -5019,7 +5126,9 @@
           PARTITION_SPLIT, idx, idx == 3, part_search_state->ss_x,
           part_search_state->ss_y);
     }
+#if !CONFIG_EXT_RECUR_PARTITIONS
     int64_t *p_split_rd = &part_search_state->split_rd[idx];
+#endif  // !CONFIG_EXT_RECUR_PARTITIONS
     RD_STATS best_remain_rdcost;
     av1_rd_stats_subtraction(x->rdmult, best_rdc, &sum_rdc,
                              &best_remain_rdcost);
@@ -5033,6 +5142,16 @@
     // Split partition evaluation of corresponding idx.
     // If the RD cost exceeds the best cost then do not
     // evaluate other split sub-partitions.
+#if CONFIG_EXT_RECUR_PARTITIONS
+    if (!av1_rd_pick_partition(
+            cpi, td, tile_data, tp, mi_row + y_idx, mi_col + x_idx, subsize,
+            &part_search_state->this_rdc, best_remain_rdcost, sub_tree[idx],
+            track_ptree_luma ? ptree_luma->sub_tree[idx] : NULL,
+            get_partition_subtree_const(template_tree, idx),
+            max_recursion_depth, NULL, NULL, multi_pass_mode, NULL)) {
+      break;
+    }
+#else
     if (!av1_rd_pick_partition(
             cpi, td, tile_data, tp, mi_row + y_idx, mi_col + x_idx, subsize,
             &part_search_state->this_rdc, best_remain_rdcost,
@@ -5041,6 +5160,7 @@
       av1_invalid_rd_stats(&sum_rdc);
       break;
     }
+#endif  // CONFIG_EXT_RECUR_PARTITIONS
     if (frame_is_intra_only(cm) && bsize <= BLOCK_64X64) {
       part_search_state->intra_part_info->quad_tree_idx = curr_quad_tree_idx;
     }
@@ -5084,6 +5204,7 @@
       pc_tree->partitioning = PARTITION_SPLIT;
     }
   } else if (cpi->sf.part_sf.less_rectangular_check_level > 0) {
+#if !CONFIG_EXT_RECUR_PARTITIONS
     // Skip rectangular partition test when partition type none gives better
     // rd than partition type split.
     if (cpi->sf.part_sf.less_rectangular_check_level == 2 || idx <= 2) {
@@ -5093,13 +5214,13 @@
       part_search_state->do_rectangular_split &=
           !(partition_none_valid && partition_none_better);
     }
+#endif  // !CONFIG_EXT_RECUR_PARTITIONS
   }
   av1_restore_context(cm, x, x_ctx, mi_row, mi_col, bsize, av1_num_planes(cm));
 #if CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
   restore_level_banks(&x->e_mbd, level_banks);
 #endif  // CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
 }
-#endif  // !CONFIG_EXT_RECUR_PARTITIONS
 
 #if CONFIG_EXT_RECUR_PARTITIONS
 /*!\brief Stores some data used by rd_try_subblock_new to do rdopt. */
@@ -6431,6 +6552,81 @@
 
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 
+static AOM_INLINE int get_partition_depth(const PC_TREE *pc_tree,
+                                          int curr_depth) {
+  const PARTITION_TYPE partition = pc_tree->partitioning;
+  int max_depth = curr_depth;
+  switch (partition) {
+    case PARTITION_NONE: break;
+    case PARTITION_SPLIT:
+      for (int idx = 0; idx < 4; idx++) {
+        max_depth = AOMMAX(max_depth, get_partition_depth(pc_tree->split[idx],
+                                                          curr_depth + 2));
+      }
+      break;
+    case PARTITION_HORZ:
+      for (int idx = 0; idx < 2; idx++) {
+        max_depth = AOMMAX(
+            max_depth,
+            get_partition_depth(pc_tree->horizontal[idx], curr_depth + 1));
+      }
+      break;
+    case PARTITION_VERT:
+      for (int idx = 0; idx < 2; idx++) {
+        max_depth =
+            AOMMAX(max_depth,
+                   get_partition_depth(pc_tree->vertical[idx], curr_depth + 1));
+      }
+      break;
+    case PARTITION_HORZ_3:
+      for (int idx = 0; idx < 4; idx++) {
+        max_depth = AOMMAX(
+            max_depth,
+            get_partition_depth(pc_tree->horizontal3[idx], curr_depth + 1));
+      }
+      break;
+    case PARTITION_VERT_3:
+      for (int idx = 0; idx < 4; idx++) {
+        max_depth = AOMMAX(
+            max_depth,
+            get_partition_depth(pc_tree->vertical3[idx], curr_depth + 1));
+      }
+      break;
+#if CONFIG_UNEVEN_4WAY
+    case PARTITION_HORZ_4A:
+      for (int idx = 0; idx < 4; idx++) {
+        max_depth = AOMMAX(
+            max_depth,
+            get_partition_depth(pc_tree->horizontal4a[idx], curr_depth + 1));
+      }
+      break;
+    case PARTITION_HORZ_4B:
+      for (int idx = 0; idx < 4; idx++) {
+        max_depth = AOMMAX(
+            max_depth,
+            get_partition_depth(pc_tree->horizontal4b[idx], curr_depth + 1));
+      }
+      break;
+    case PARTITION_VERT_4A:
+      for (int idx = 0; idx < 4; idx++) {
+        max_depth = AOMMAX(
+            max_depth,
+            get_partition_depth(pc_tree->vertical4a[idx], curr_depth + 1));
+      }
+      break;
+    case PARTITION_VERT_4B:
+      for (int idx = 0; idx < 4; idx++) {
+        max_depth = AOMMAX(
+            max_depth,
+            get_partition_depth(pc_tree->vertical4b[idx], curr_depth + 1));
+      }
+      break;
+#endif  // CONFIG_UNEVEN_4WAY
+    default: assert(0); break;
+  }
+  return max_depth;
+}
+
 #if CONFIG_EXT_RECUR_PARTITIONS
 static AOM_INLINE bool try_none_after_rect(
     const MACROBLOCKD *xd, const CommonModeInfoParams *mi_params,
@@ -6509,19 +6705,29 @@
 
   const PARTITION_TYPE cur_best_partition = pc_tree->partitioning;
   PC_TREE *const *tree = NULL;
-  if (cur_best_partition == PARTITION_HORZ) {
+  int num_sub_parts = 0;
+  if (cur_best_partition == PARTITION_SPLIT) {
+    tree = pc_tree->split;
+    num_sub_parts = SUB_PARTITIONS_SPLIT;
+  } else if (cur_best_partition == PARTITION_HORZ) {
     tree = pc_tree->horizontal;
+    num_sub_parts = NUM_RECT_PARTS;
   } else if (cur_best_partition == PARTITION_VERT) {
     tree = pc_tree->vertical;
+    num_sub_parts = NUM_RECT_PARTS;
   } else {
     assert(0 &&
            "Unexpected best partition type in prune_none_with_rect_results.");
   }
   // Give up on PARTITION_NONE if either of the subtrees decided to split
   // further.
-  part_search_state->prune_partition_none |=
-      tree[0]->partitioning != PARTITION_NONE ||
-      tree[1]->partitioning != PARTITION_NONE;
+  for (int idx = 0; idx < num_sub_parts; idx++) {
+    if (!tree[idx]) {
+      break;
+    }
+    part_search_state->prune_partition_none |=
+        tree[idx]->partitioning != PARTITION_NONE;
+  }
 }
 
 /*!\brief AV1 block partition search (full search).
@@ -6665,8 +6871,8 @@
 #if WARP_CU_BANK
       x->e_mbd.warp_param_bank = counterpart_block->warp_param_bank;
 #endif  // WARP_CU_BANK
-      assert(bsize != cm->seq_params.sb_size);
-      if (bsize == cm->seq_params.sb_size) exit(0);
+      assert(bsize != cm->sb_size);
+      if (bsize == cm->sb_size) exit(0);
 
       if (!pc_tree->is_last_subblock) {
         encode_sb(cpi, td, tile_data, tp, mi_row, mi_col, DRY_RUN_NORMAL, bsize,
@@ -6683,7 +6889,7 @@
     }
   }
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
-  if (bsize == cm->seq_params.sb_size) x->must_find_valid_partition = 0;
+  if (bsize == cm->sb_size) x->must_find_valid_partition = 0;
 
   // Override skipping rectangular partition operations for edge blocks.
   if (none_rd) *none_rd = 0;
@@ -6700,14 +6906,12 @@
 #endif
 #endif
 
+#if !CONFIG_EXT_RECUR_PARTITIONS
   // Override partition costs at the edges of the frame in the same
   // way as in read_partition (see decodeframe.c).
   if (!(blk_params.has_rows && blk_params.has_cols))
-    set_partition_cost_for_edge_blk(cm, xd,
-#if CONFIG_EXT_RECUR_PARTITIONS
-                                    &pc_tree->chroma_ref_info,
-#endif  // CONFIG_EXT_RECUR_PARTITIONS
-                                    &part_search_state);
+    set_partition_cost_for_edge_blk(cm, xd, &part_search_state);
+#endif  // !CONFIG_EXT_RECUR_PARTITIONS
 
   // Disable rectangular partitions for inner blocks when the current block is
   // forced to only use square partitions.
@@ -6735,12 +6939,18 @@
   av1_set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize,
                   &pc_tree->chroma_ref_info);
 
+  bool search_none_after_split = false;
   bool search_none_after_rect = false;
 #if CONFIG_EXT_RECUR_PARTITIONS
-  if (cpi->sf.part_sf.adaptive_partition_search_order &&
-      part_search_state.forced_partition == PARTITION_INVALID) {
-    search_none_after_rect =
-        try_none_after_rect(xd, &cm->mi_params, bsize, mi_row, mi_col);
+  if (part_search_state.forced_partition == PARTITION_INVALID) {
+    if (cpi->sf.part_sf.adaptive_partition_search_order) {
+      search_none_after_rect =
+          try_none_after_rect(xd, &cm->mi_params, bsize, mi_row, mi_col);
+    }
+#if CONFIG_BLOCK_256
+    // For 256X256, always search the subblocks first.
+    search_none_after_split |= bsize == BLOCK_256X256;
+#endif  // CONFIG_BLOCK_256
   }
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 
@@ -6774,8 +6984,8 @@
 #endif  // CONFIG_MVP_IMPROVEMENT
 #if CONFIG_EXT_RECUR_PARTITIONS
   {
-    SimpleMotionData *sms_data = av1_get_sms_data_entry(
-        x->sms_bufs, mi_row, mi_col, bsize, cm->seq_params.sb_size);
+    SimpleMotionData *sms_data =
+        av1_get_sms_data_entry(x->sms_bufs, mi_row, mi_col, bsize, cm->sb_size);
     sms_tree = sms_data->old_sms;
   }
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
@@ -6853,7 +7063,7 @@
 
   // PARTITION_NONE search stage.
   int64_t part_none_rd = INT64_MAX;
-  if (!search_none_after_rect) {
+  if (!search_none_after_rect && !search_none_after_split) {
     none_partition_search(cpi, td, tile_data, x, pc_tree, sms_tree, &x_ctx,
                           &part_search_state, &best_rdc, &pb_source_variance,
                           none_rd, &part_none_rd
@@ -6879,7 +7089,6 @@
   }
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 
-#if !CONFIG_EXT_RECUR_PARTITIONS
   // PARTITION_SPLIT search stage.
   int64_t part_split_rd = INT64_MAX;
   split_partition_search(cpi, td, tile_data, tp, x, pc_tree, sms_tree, &x_ctx,
@@ -6889,13 +7098,18 @@
                          ,
                          &level_banks
 #endif  // CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
+#if CONFIG_EXT_RECUR_PARTITIONS
+                         ,
+                         ptree_luma, template_tree, max_recursion_depth - 1
+#endif  // CONFIG_EXT_RECUR_PARTITIONS
   );
 
+#if !CONFIG_EXT_RECUR_PARTITIONS
   // Terminate partition search for child partition,
   // when NONE and SPLIT partition rd_costs are INT64_MAX.
   if (cpi->sf.part_sf.early_term_after_none_split &&
       part_none_rd == INT64_MAX && part_split_rd == INT64_MAX &&
-      !x->must_find_valid_partition && (bsize != cm->seq_params.sb_size)) {
+      !x->must_find_valid_partition && (bsize != cm->sb_size)) {
     part_search_state.terminate_partition_search = 1;
   }
 
@@ -6903,6 +7117,45 @@
   prune_partitions_after_split(cpi, x, sms_tree, &part_search_state, &best_rdc,
                                part_none_rd, part_split_rd);
 #endif  // !CONFIG_EXT_RECUR_PARTITIONS
+#if CONFIG_BLOCK_256
+  if (search_none_after_split) {
+    // Based on split result, decide if we want to further delay the search to
+    // after rect
+    assert(pc_tree->partitioning == PARTITION_SPLIT);
+    for (int idx = 0; idx < 4; idx++) {
+      const int depth = get_partition_depth(pc_tree->split[idx], 0);
+      search_none_after_split &= depth == 0;
+    }
+  }
+  if (cpi->sf.part_sf.prune_rect_with_split_depth && !frame_is_intra_only(cm) &&
+      part_search_state.forced_partition == PARTITION_INVALID &&
+      pc_tree->split[0] && pc_tree->split[1] && pc_tree->split[2] &&
+      pc_tree->split[3]) {
+    int min_depth = INT_MAX, max_depth = 0;
+    for (int idx = 0; idx < 4; idx++) {
+      const int depth = get_partition_depth(pc_tree->split[idx], 0);
+      min_depth = AOMMIN(min_depth, depth);
+      max_depth = AOMMAX(max_depth, depth);
+    }
+    if (min_depth > 4) {
+      part_search_state.prune_rect_part[HORZ] =
+          part_search_state.prune_rect_part[VERT] = true;
+    }
+    (void)max_depth;
+  }
+
+  if (part_search_state.forced_partition == PARTITION_INVALID &&
+      search_none_after_split) {
+    none_partition_search(cpi, td, tile_data, x, pc_tree, sms_tree, &x_ctx,
+                          &part_search_state, &best_rdc, &pb_source_variance,
+                          none_rd, &part_none_rd
+#if CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
+                          ,
+                          &level_banks
+#endif  // CONFIG_MVP_IMPROVEMENT || WARP_CU_BANK
+    );
+  }
+#endif  // CONFIG_BLOCK_256
 
   // Rectangular partitions search stage.
   rectangular_partition_search(
@@ -6925,7 +7178,7 @@
   assert(IMPLIES(!cpi->oxcf.part_cfg.enable_rect_partitions,
                  !part_search_state.do_rectangular_split));
 #if CONFIG_EXT_RECUR_PARTITIONS
-  if (search_none_after_rect) {
+  if (search_none_after_rect && !search_none_after_split) {
     prune_none_with_rect_results(&part_search_state, pc_tree);
     none_partition_search(cpi, td, tile_data, x, pc_tree, sms_tree, &x_ctx,
                           &part_search_state, &best_rdc, &pb_source_variance,
@@ -7086,8 +7339,7 @@
                            multi_pass_mode, ext_recur_depth);
 #endif  // CONFIG_UNEVEN_4WAY
 
-  if (bsize == cm->seq_params.sb_size &&
-      !part_search_state.found_best_partition) {
+  if (bsize == cm->sb_size && !part_search_state.found_best_partition) {
     if (x->must_find_valid_partition) {
       aom_internal_error(
           &cpi->common.error, AOM_CODEC_ERROR,
@@ -7135,8 +7387,8 @@
     av1_invalid_rd_stats(&pc_tree->rd_cost);
   } else {
 #if CONFIG_EXT_RECUR_PARTITIONS
-    av1_cache_best_partition(x->sms_bufs, mi_row, mi_col, bsize,
-                             cm->seq_params.sb_size, pc_tree->partitioning);
+    av1_cache_best_partition(x->sms_bufs, mi_row, mi_col, bsize, cm->sb_size,
+                             pc_tree->partitioning);
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
   }
 
@@ -7196,10 +7448,7 @@
   // If a valid partition is found and reconstruction is required for future
   // sub-blocks in the same group.
   if (part_search_state.found_best_partition && pc_tree->index != 3) {
-#if CONFIG_EXT_RECUR_PARTITIONS
-    assert(pc_tree->partitioning != PARTITION_SPLIT);
-#endif  // CONFIG_EXT_RECUR_PARTITIONS
-    if (bsize == cm->seq_params.sb_size) {
+    if (bsize == cm->sb_size) {
       // Encode the superblock.
       const int emit_output = multi_pass_mode != SB_DRY_PASS;
       const RUN_TYPE run_type = emit_output ? OUTPUT_ENABLED : DRY_RUN_NORMAL;
@@ -7241,7 +7490,7 @@
     av1_free_pc_tree_recursive(pc_tree, num_planes, 1, 1);
   }
 
-  if (bsize == cm->seq_params.sb_size) {
+  if (bsize == cm->sb_size) {
     assert(best_rdc.rate < INT_MAX);
     assert(best_rdc.dist < INT64_MAX);
   } else {
diff --git a/av1/encoder/partition_strategy.c b/av1/encoder/partition_strategy.c
index ac792a7..18fa5c1 100644
--- a/av1/encoder/partition_strategy.c
+++ b/av1/encoder/partition_strategy.c
@@ -63,8 +63,7 @@
                                   int *partition_vert_allowed,
                                   int *do_rectangular_split,
                                   int *do_square_split) {
-  assert(cm->seq_params.sb_size >= BLOCK_64X64 &&
-         "Invalid sb_size for intra_cnn!");
+  assert(cm->sb_size >= BLOCK_64X64 && "Invalid sb_size for intra_cnn!");
   const int bsize_idx = convert_bsize_to_idx(bsize);
 
   if (bsize == BLOCK_128X128) {
@@ -618,6 +617,10 @@
     ml_mean = av1_simple_motion_search_term_none_mean_16;
     ml_std = av1_simple_motion_search_term_none_std_16;
     ml_model = av1_simple_motion_search_term_none_model_16;
+#if CONFIG_BLOCK_256
+  } else if (bsize == BLOCK_256X256) {
+    return;
+#endif  // CONFIG_BLOCK_256
   } else {
     assert(0 && "Unexpected block size in simple_motion_term_none");
   }
@@ -641,7 +644,7 @@
                                         float *features) {
   AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *xd = &x->e_mbd;
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
 
   assert(sb_size == BLOCK_128X128);
 
@@ -770,7 +773,7 @@
     }
   } else if (cpi->sf.part_sf.auto_max_partition_based_on_simple_motion ==
              ADAPT_PRED) {
-    const BLOCK_SIZE sb_size = cpi->common.seq_params.sb_size;
+    const BLOCK_SIZE sb_size = cpi->common.sb_size;
     const MACROBLOCKD *const xd = &x->e_mbd;
     // TODO(debargha): x->source_variance is unavailable at this point,
     // so compute. The redundant recomputation later can be removed.
@@ -1264,6 +1267,9 @@
       nn_config = &av1_partition_breakout_nnconfig_128;
       thresh = cpi->sf.part_sf.ml_partition_search_breakout_thresh[4];
       break;
+#if CONFIG_BLOCK_256
+    case BLOCK_256X256: return 0; break;
+#endif  // CONFIG_BLOCK_256
     default: assert(0 && "Unexpected bsize.");
   }
   if (!nn_config || thresh < 0) return 0;
@@ -1317,7 +1323,7 @@
   const int try_intra_cnn_split =
       !cpi->is_screen_content_type && frame_is_intra_only(cm) &&
       cpi->sf.part_sf.intra_cnn_split && xd->tree_type != CHROMA_PART &&
-      cm->seq_params.sb_size >= BLOCK_64X64 && bsize <= BLOCK_64X64 &&
+      cm->sb_size >= BLOCK_64X64 && bsize <= BLOCK_64X64 &&
       bsize >= BLOCK_8X8 &&
       mi_row + mi_size_high[bsize] <= mi_params->mi_rows &&
       mi_col + mi_size_wide[bsize] <= mi_params->mi_cols;
@@ -1348,14 +1354,14 @@
         do_square_split);
 #if CONFIG_EXT_RECUR_PARTITIONS
     if (!*partition_none_allowed) {
-      av1_cache_best_partition(x->sms_bufs, mi_row, mi_col, bsize,
-                               cm->seq_params.sb_size, PARTITION_HORZ);
+      av1_cache_best_partition(x->sms_bufs, mi_row, mi_col, bsize, cm->sb_size,
+                               PARTITION_HORZ);
       const int mi_step = block_size_high[bsize] / 2;
       BLOCK_SIZE subsize = get_partition_subsize(bsize, PARTITION_HORZ);
       av1_cache_best_partition(x->sms_bufs, mi_row, mi_col, subsize,
-                               cm->seq_params.sb_size, PARTITION_VERT);
+                               cm->sb_size, PARTITION_VERT);
       av1_cache_best_partition(x->sms_bufs, mi_row + mi_step, mi_col, subsize,
-                               cm->seq_params.sb_size, PARTITION_VERT);
+                               cm->sb_size, PARTITION_VERT);
     }
     (void)pc_tree;
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
@@ -1613,6 +1619,9 @@
 // Gets the number of sms data in a single dimension
 static INLINE int get_sms_count_from_length(int mi_length) {
   switch (mi_length) {
+#if CONFIG_BLOCK_256
+    case 64: return BLOCK_256_COUNT;
+#endif  // CONFIG_BLOCK_256
     case 32: return BLOCK_128_COUNT;
     case 16: return BLOCK_64_COUNT;
     case 8: return BLOCK_32_COUNT;
@@ -1666,6 +1675,9 @@
                                             BLOCK_SIZE bsize) {
   switch (bsize) {
     // Square blocks
+#if CONFIG_BLOCK_256
+    MAKE_SMS_ARR_SWITCH_CASE(256, 256);
+#endif  // CONFIG_BLOCK_256
     MAKE_SMS_ARR_SWITCH_CASE(128, 128);
     MAKE_SMS_ARR_SWITCH_CASE(64, 64);
     MAKE_SMS_ARR_SWITCH_CASE(32, 32);
@@ -1674,6 +1686,9 @@
     MAKE_SMS_ARR_SWITCH_CASE(4, 4);
 
     // 1:2 blocks
+#if CONFIG_BLOCK_256
+    MAKE_SMS_ARR_SWITCH_CASE(128, 256);
+#endif  // CONFIG_BLOCK_256
     MAKE_SMS_ARR_SWITCH_CASE(64, 128);
     MAKE_SMS_ARR_SWITCH_CASE(32, 64);
     MAKE_SMS_ARR_SWITCH_CASE(16, 32);
@@ -1681,6 +1696,9 @@
     MAKE_SMS_ARR_SWITCH_CASE(4, 8);
 
     // 2:1 blocks
+#if CONFIG_BLOCK_256
+    MAKE_SMS_ARR_SWITCH_CASE(256, 128);
+#endif  // CONFIG_BLOCK_256
     MAKE_SMS_ARR_SWITCH_CASE(128, 64);
     MAKE_SMS_ARR_SWITCH_CASE(64, 32);
     MAKE_SMS_ARR_SWITCH_CASE(32, 16);
@@ -1820,10 +1838,9 @@
     SimpleMotionDataBufs *sms_bufs, int mi_row, int mi_col, BLOCK_SIZE bsize,
     BLOCK_SIZE sb_size, PARTITION_TYPE partition, MV start_mv) {
   assert(bsize < BLOCK_SIZES_ALL);
-
   const int eighth_step_h = block_size_high[bsize] / 8;
   const int eighth_step_w = block_size_wide[bsize] / 8;
-  static const int subblock_count[EXT_PARTITION_TYPES] = {
+  static const int subblock_count[ALL_PARTITION_TYPES] = {
     1,  // PARTITION_NONE
     2,  // PARTITION_HORZ
     2,  // PARTITION_VERT
@@ -1835,9 +1852,10 @@
     4,  // PARTITION_VERT_4A
     4,  // PARTITION_VERT_4B
 #endif  // CONFIG_UNEVEN_4WAY
+    4,  // PARTITION_SPLIT
   };
   // PARTITION x NUM_SUBBLOCKS x (ROW and COL)
-  static const int step_multiplier[EXT_PARTITION_TYPES][4][2] = {
+  static const int step_multiplier[ALL_PARTITION_TYPES][4][2] = {
     { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },  // PARTITION_NONE
     { { 0, 0 }, { 4, 0 }, { 0, 0 }, { 0, 0 } },  // PARTITION_HORZ
     { { 0, 0 }, { 0, 4 }, { 0, 0 }, { 0, 0 } },  // PARTITION_VERT
@@ -1849,6 +1867,7 @@
     { { 0, 0 }, { 0, 1 }, { 0, 3 }, { 0, 7 } },  // PARTITION_VERT_4A
     { { 0, 0 }, { 0, 1 }, { 0, 5 }, { 0, 7 } },  // PARTITION_VERT_4B
 #endif                                           // CONFIG_UNEVEN_4WAY
+    { { 0, 0 }, { 0, 4 }, { 4, 0 }, { 4, 4 } },  // PARTITION_SPLIT
   };
 
   // Sizes of subblocks.
@@ -1897,7 +1916,7 @@
                                    const TileInfo *const tile, MACROBLOCK *x,
                                    int mi_row, int mi_col, BLOCK_SIZE bsize) {
   const AV1_COMMON *const cm = &cpi->common;
-  const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+  const BLOCK_SIZE sb_size = cm->sb_size;
   SimpleMotionDataBufs *sms_bufs = x->sms_bufs;
   SimpleMotionData *cur_block =
       av1_get_sms_data_entry(sms_bufs, mi_row, mi_col, bsize, sb_size);
diff --git a/av1/encoder/pickcdef.c b/av1/encoder/pickcdef.c
index 9d06025..8399c27 100644
--- a/av1/encoder/pickcdef.c
+++ b/av1/encoder/pickcdef.c
@@ -360,7 +360,11 @@
     return;
   }
 
+#if CONFIG_BLOCK_256
+  cdef_list dlist[MI_SIZE_256X256 * MI_SIZE_256X256];
+#else
   cdef_list dlist[MI_SIZE_128X128 * MI_SIZE_128X128];
+#endif  // CONFIG_BLOCK_256
   int dir[CDEF_NBLOCKS][CDEF_NBLOCKS] = { { 0 } };
   int var[CDEF_NBLOCKS][CDEF_NBLOCKS] = { { 0 } };
   const CommonModeInfoParams *const mi_params = &cm->mi_params;
@@ -422,17 +426,56 @@
       const MB_MODE_INFO *const mbmi =
           mi_params->mi_grid_base[MI_SIZE_64X64 * fbr * mi_params->mi_stride +
                                   MI_SIZE_64X64 * fbc];
+      BLOCK_SIZE bs = mbmi->sb_type[PLANE_TYPE_Y];
+#if CONFIG_BLOCK_256
+      if (bs > BLOCK_64X64 && bs <= BLOCK_256X256) {
+        const int bw = block_size_wide[bs];
+        const int bh = block_size_high[bs];
+        if ((bw == 256 && (fbc & 3)) || (bh == 256 && (fbr & 3))) {
+          continue;
+        };
+        if ((bw == 128 && (fbc & 1)) || (bh == 128 && (fbr & 1))) {
+          continue;
+        };
+      }
+#else
       if (((fbc & 1) && (mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_128X128 ||
                          mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_128X64)) ||
           ((fbr & 1) && (mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_128X128 ||
                          mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_64X128)))
         continue;
+#endif  // CONFIG_BLOCK_256
 
       int nhb = AOMMIN(MI_SIZE_64X64, mi_params->mi_cols - MI_SIZE_64X64 * fbc);
       int nvb = AOMMIN(MI_SIZE_64X64, mi_params->mi_rows - MI_SIZE_64X64 * fbr);
       int hb_step = 1;
       int vb_step = 1;
-      BLOCK_SIZE bs;
+#if CONFIG_BLOCK_256
+      if (bs > BLOCK_64X64 && bs <= BLOCK_256X256) {
+        if (block_size_wide[bs] == 256) {
+          nhb =
+              AOMMIN(MI_SIZE_256X256, mi_params->mi_cols - MI_SIZE_64X64 * fbc);
+          hb_step = 4;
+        }
+        if (block_size_high[bs] == 256) {
+          nvb =
+              AOMMIN(MI_SIZE_256X256, mi_params->mi_rows - MI_SIZE_64X64 * fbr);
+          vb_step = 4;
+        }
+        if (block_size_wide[bs] == 128) {
+          nhb =
+              AOMMIN(MI_SIZE_128X128, mi_params->mi_cols - MI_SIZE_64X64 * fbc);
+          hb_step = 2;
+        }
+        if (block_size_high[bs] == 128) {
+          nvb =
+              AOMMIN(MI_SIZE_128X128, mi_params->mi_rows - MI_SIZE_64X64 * fbr);
+          vb_step = 2;
+        }
+      } else {
+        bs = BLOCK_64X64;
+      }
+#else
       if (mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_128X128 ||
           mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_128X64 ||
           mbmi->sb_type[PLANE_TYPE_Y] == BLOCK_64X128) {
@@ -450,6 +493,7 @@
       } else {
         bs = BLOCK_64X64;
       }
+#endif  // CONFIG_BLOCK_256
 
       const int cdef_count = av1_cdef_compute_sb_list(
           mi_params, fbr * MI_SIZE_64X64, fbc * MI_SIZE_64X64, dlist, bs);
@@ -552,17 +596,19 @@
       }
     }
     mi_params->mi_grid_base[sb_index[i]]->cdef_strength = best_gi;
-    int bsize_y = mi_params->mi_grid_base[sb_index[i]]->sb_type[PLANE_TYPE_Y];
+    BLOCK_SIZE bsize_y =
+        mi_params->mi_grid_base[sb_index[i]]->sb_type[PLANE_TYPE_Y];
     const int bh = mi_size_high[bsize_y];
     const int bw = mi_size_wide[bsize_y];
     int mi_row = sb_index[i] / mi_params->mi_stride;
     int mi_col = sb_index[i] % mi_params->mi_stride;
-    if (mi_params->mi_grid_base[sb_index[i]]->sb_type[PLANE_TYPE_Y] ==
-            BLOCK_64X128 ||
-        mi_params->mi_grid_base[sb_index[i]]->sb_type[PLANE_TYPE_Y] ==
-            BLOCK_128X128 ||
-        mi_params->mi_grid_base[sb_index[i]]->sb_type[PLANE_TYPE_Y] ==
-            BLOCK_128X64) {
+    if (
+#if CONFIG_BLOCK_256
+        bsize_y == BLOCK_256X256 || bsize_y == BLOCK_256X128 ||
+        bsize_y == BLOCK_128X256 ||
+#endif  // CONFIG_BLOCK_256
+        bsize_y == BLOCK_128X128 || bsize_y == BLOCK_128X64 ||
+        bsize_y == BLOCK_64X128) {
       const int x_inside_boundary = AOMMIN(bw, mi_params->mi_cols - mi_col);
       const int y_inside_boundary = AOMMIN(bh, mi_params->mi_rows - mi_row);
       int idx = mi_params->mi_stride;
diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index eef3d93..5c49b56 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -4358,13 +4358,13 @@
   reset_rsc(rsc);
   rsc_on_tile(rsc, *processed);
   for (int mi_row = tile_info.mi_row_start; mi_row < tile_info.mi_row_end;
-       mi_row += rsc->cm->seq_params.mib_size) {
+       mi_row += rsc->cm->mib_size) {
     for (int mi_col = tile_info.mi_col_start; mi_col < tile_info.mi_col_end;
-         mi_col += rsc->cm->seq_params.mib_size) {
+         mi_col += rsc->cm->mib_size) {
       int rrow0, rrow1, rcol0, rcol1;
-      if (av1_loop_restoration_corners_in_sb(
-              rsc->cm, rsc->plane, mi_row, mi_col, rsc->cm->seq_params.sb_size,
-              &rcol0, &rcol1, &rrow0, &rrow1)) {
+      if (av1_loop_restoration_corners_in_sb(rsc->cm, rsc->plane, mi_row,
+                                             mi_col, rsc->cm->sb_size, &rcol0,
+                                             &rcol1, &rrow0, &rrow1)) {
         // RU domain rectangle for the coded SB
         AV1PixelRect ru_sb_rect = av1_get_rutile_rect(
             rsc->cm, is_uv, rrow0, rrow1, rcol0, rcol1, ru_size, ru_size);
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 3c6d75a..1671707 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -14,6 +14,8 @@
 #include <math.h>
 #include <stdio.h>
 
+#include "av1/common/blockd.h"
+#include "av1/common/enums.h"
 #include "config/av1_rtcd.h"
 
 #include "aom_dsp/aom_dsp_common.h"
@@ -55,7 +57,11 @@
 // This table is used to correct for block size.
 // The factors here are << 2 (2 = x0.5, 32 = x8 etc).
 static const uint8_t rd_thresh_block_size_factor[BLOCK_SIZES_ALL] = {
-  2, 3, 3, 4, 6, 6, 8, 12, 12, 16, 24, 24, 32, 48, 48, 64, 4, 4, 8, 8, 16, 16
+  2,  3,  3,   4, 6,  6, 8, 12, 12, 16, 24, 24, 32, 48, 48, 64,
+#if CONFIG_BLOCK_256
+  96, 96, 128,
+#endif  // CONFIG_BLOCK_256
+  4,  4,  8,   8, 16, 16
 };
 
 static const int use_intra_ext_tx_for_txsize[EXT_TX_SETS_INTRA]
@@ -108,6 +114,15 @@
                                fc->do_split_cdf[plane_index][i], NULL);
     }
   }
+#if CONFIG_BLOCK_256
+  for (int plane_index = (xd->tree_type == CHROMA_PART);
+       plane_index < PARTITION_STRUCTURE_NUM; plane_index++) {
+    for (i = 0; i < SQUARE_SPLIT_CONTEXTS; ++i) {
+      av1_cost_tokens_from_cdf(mode_costs->do_square_split_cost[plane_index][i],
+                               fc->do_square_split_cdf[plane_index][i], NULL);
+    }
+  }
+#endif  // CONFIG_BLOCK_256
   for (int plane_index = (xd->tree_type == CHROMA_PART);
        plane_index < PARTITION_STRUCTURE_NUM; plane_index++) {
     for (i = 0; i < PARTITION_CONTEXTS; ++i) {
@@ -142,7 +157,7 @@
        plane_index < PARTITION_STRUCTURE_NUM; plane_index++) {
     const TREE_TYPE tree_type = plane_index ? CHROMA_PART : LUMA_PART;
     for (BLOCK_SIZE bsize = 0; bsize < BLOCK_SIZES; bsize++) {
-      for (PARTITION_TYPE part = 0; part < EXT_PARTITION_TYPES; part++) {
+      for (PARTITION_TYPE part = 0; part < ALL_PARTITION_TYPES; part++) {
         for (int context = 0; context < PARTITION_PLOFFSET; context++) {
           const int ctx = PARTITION_PLOFFSET * bsize + context;
           const bool do_split = part != PARTITION_NONE;
@@ -151,6 +166,17 @@
           if (!do_split) {
             continue;
           }
+#if CONFIG_BLOCK_256
+          const bool do_square_split = part == PARTITION_SPLIT;
+          if (is_square_split_eligible(bsize, cm->sb_size)) {
+            mode_costs->partition_cost[plane_index][ctx][part] +=
+                mode_costs->do_square_split_cost[plane_index][context]
+                                                [do_square_split];
+          }
+          if (do_square_split) {
+            continue;
+          }
+#endif  // CONFIG_BLOCK_256
           RECT_PART_TYPE rect_type = get_rect_part_type(part);
           if (rect_type_implied_by_bsize(bsize, tree_type) == RECT_INVALID) {
             mode_costs->partition_cost[plane_index][ctx][part] +=
@@ -1471,7 +1497,33 @@
 */
 
 static const uint8_t bsize_curvfit_model_cat_lookup[BLOCK_SIZES_ALL] = {
-  0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3
+  0,
+  0,
+  0,
+  1,
+  1,
+  1,
+  2,
+  2,
+  2,
+  3,
+  3,
+  3,
+  3,
+  3,
+  3,
+  3,
+#if CONFIG_BLOCK_256
+  3,
+  3,
+  3,
+#endif  // CONFIG_BLOCK_256
+  1,
+  1,
+  2,
+  2,
+  3,
+  3
 };
 
 static int sse_norm_curvfit_model_cat_lookup(double sse_norm) {
@@ -1496,9 +1548,36 @@
 }
 
 static const uint8_t bsize_surffit_model_cat_lookup[BLOCK_SIZES_ALL] = {
-  0, 0, 0, 0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 0, 0, 2, 2, 4, 4
+  0,
+  0,
+  0,
+  0,
+  1,
+  1,
+  2,
+  3,
+  3,
+  4,
+  5,
+  5,
+  6,
+  7,
+  7,
+  8,
+#if CONFIG_BLOCK_256
+  8,
+  8,
+  8,
+#endif  // CONFIG_BLOCK_256
+  0,
+  0,
+  2,
+  2,
+  4,
+  4
 };
 
+// TODO(any): Add models for BLOCK_256
 static const double surffit_rate_params[9][4] = {
   {
       638.390212,
@@ -1883,7 +1962,7 @@
   assert(use_adaptive_rd_thresh > 0);
   const int max_rd_thresh_factor = use_adaptive_rd_thresh * RD_THRESH_MAX_FACT;
 
-  const int bsize_is_1_to_4 = bsize > cm->seq_params.sb_size;
+  const int bsize_is_1_to_4 = bsize > cm->sb_size;
   BLOCK_SIZE min_size, max_size;
   if (bsize_is_1_to_4) {
     // This part handles block sizes with 1:4 and 4:1 aspect ratios
@@ -1892,7 +1971,7 @@
     max_size = bsize;
   } else {
     min_size = AOMMAX(bsize - 2, BLOCK_4X4);
-    max_size = AOMMIN(bsize + 2, (int)cm->seq_params.sb_size);
+    max_size = AOMMIN(bsize + 2, (int)cm->sb_size);
   }
 
   for (PREDICTION_MODE mode = 0; mode < MB_MODE_COUNT; ++mode) {
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 50121c3..e5c1dd0 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -736,7 +736,7 @@
   const int mi_col = xd->mi_col;
   const int x_inside_boundary = AOMMIN(bw, cm->mi_params.mi_cols - mi_col);
   const int y_inside_boundary = AOMMIN(bh, cm->mi_params.mi_rows - mi_row);
-  const int dst_stride = MAX_MIB_SIZE;
+  const int dst_stride = bw;
   const int src_stride = cm->mi_params.mi_stride;
   for (int y = 0; y < y_inside_boundary; y++) {
     for (int x = 0; x < x_inside_boundary; x++) {
@@ -753,7 +753,7 @@
   const int mi_col = xd->mi_col;
   const int x_inside_boundary = AOMMIN(bw, cm->mi_params.mi_cols - mi_col);
   const int y_inside_boundary = AOMMIN(bh, cm->mi_params.mi_rows - mi_row);
-  const int src_stride = MAX_MIB_SIZE;
+  const int src_stride = bw;
   const int dst_stride = cm->mi_params.mi_stride;
   for (int y = 0; y < y_inside_boundary; y++) {
     for (int x = 0; x < x_inside_boundary; x++) {
@@ -6113,8 +6113,7 @@
 #endif
                               ))
     return 0;
-  if (!av1_is_dv_valid(dv, cm, xd, mi_row, mi_col, bsize,
-                       cm->seq_params.mib_size_log2))
+  if (!av1_is_dv_valid(dv, cm, xd, mi_row, mi_col, bsize, cm->mib_size_log2))
     return 0;
   return 1;
 }
@@ -6160,7 +6159,7 @@
         cur_ref_bv.as_int = 0;
       }
       if (cur_ref_bv.as_int == 0) {
-        av1_find_ref_dv(&cur_ref_bv, tile, cm->seq_params.mib_size, mi_row);
+        av1_find_ref_dv(&cur_ref_bv, tile, cm->mib_size, mi_row);
       }
       // Ref DV should not have sub-pel.
       assert((cur_ref_bv.as_mv.col & 7) == 0);
@@ -6218,7 +6217,7 @@
       cur_ref_bv.as_int = 0;
     }
     if (cur_ref_bv.as_int == 0) {
-      av1_find_ref_dv(&cur_ref_bv, tile, cm->seq_params.mib_size, mi_row);
+      av1_find_ref_dv(&cur_ref_bv, tile, cm->mib_size, mi_row);
     }
     // Ref DV should not have sub-pel.
     assert((cur_ref_bv.as_mv.col & 7) == 0);
@@ -6275,8 +6274,8 @@
   const int mi_col = xd->mi_col;
   const int w = block_size_wide[bsize];
   const int h = block_size_high[bsize];
-  const int sb_row = mi_row >> cm->seq_params.mib_size_log2;
-  const int sb_col = mi_col >> cm->seq_params.mib_size_log2;
+  const int sb_row = mi_row >> cm->mib_size_log2;
+  const int sb_col = mi_col >> cm->mib_size_log2;
 
   MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
   MV_REFERENCE_FRAME ref_frame = INTRA_FRAME;
@@ -6319,7 +6318,7 @@
   }
 #endif  // CONFIG_IBC_BV_IMPROVEMENT
   if (dv_ref.as_int == 0) {
-    av1_find_ref_dv(&dv_ref, tile, cm->seq_params.mib_size, mi_row);
+    av1_find_ref_dv(&dv_ref, tile, cm->mib_size, mi_row);
   }
   // Ref DV should not have sub-pel.
   assert((dv_ref.as_mv.col & 7) == 0);
@@ -6380,7 +6379,7 @@
 #if CONFIG_IBC_SR_EXT
   fullms_params.xd = xd;
   fullms_params.cm = cm;
-  fullms_params.mib_size_log2 = cm->seq_params.mib_size_log2;
+  fullms_params.mib_size_log2 = cm->mib_size_log2;
   fullms_params.mi_col = mi_col;
   fullms_params.mi_row = mi_row;
 #endif  // CONFIG_IBC_SR_EXT
@@ -6417,7 +6416,7 @@
           fullms_params.mv_limits.row_max = -h;
 #else
         fullms_params.mv_limits.row_max =
-            (sb_row * cm->seq_params.mib_size - mi_row) * MI_SIZE - h;
+            (sb_row * cm->mib_size - mi_row) * MI_SIZE - h;
 #endif  // CONFIG_IBC_SR_EXT
           break;
         case IBC_MOTION_LEFT:
@@ -6427,14 +6426,14 @@
           fullms_params.mv_limits.col_max = -w;
 #else
         fullms_params.mv_limits.col_max =
-            (sb_col * cm->seq_params.mib_size - mi_col) * MI_SIZE - w;
+            (sb_col * cm->mib_size - mi_col) * MI_SIZE - w;
 #endif  // CONFIG_IBC_SR_EXT
         // TODO(aconverse@google.com): Minimize the overlap between above and
         // left areas.
           fullms_params.mv_limits.row_min =
               (tile->mi_row_start - mi_row) * MI_SIZE;
           int bottom_coded_mi_edge =
-              AOMMIN((sb_row + 1) * cm->seq_params.mib_size, tile->mi_row_end);
+              AOMMIN((sb_row + 1) * cm->mib_size, tile->mi_row_end);
           fullms_params.mv_limits.row_max =
               (bottom_coded_mi_edge - mi_row) * MI_SIZE - h;
           break;
@@ -6443,13 +6442,12 @@
 #if CONFIG_IBC_SR_EXT
     } else {
       int left_coded_mi_edge =
-          AOMMAX((sb_col - 1) * cm->seq_params.mib_size, tile->mi_col_start);
+          AOMMAX((sb_col - 1) * cm->mib_size, tile->mi_col_start);
       int right_coded_mi_edge =
-          AOMMIN((sb_col + 1) * cm->seq_params.mib_size, tile->mi_col_end);
-      int up_coded_mi_edge =
-          AOMMAX((sb_row)*cm->seq_params.mib_size, tile->mi_row_start);
+          AOMMIN((sb_col + 1) * cm->mib_size, tile->mi_col_end);
+      int up_coded_mi_edge = AOMMAX((sb_row)*cm->mib_size, tile->mi_row_start);
       int bottom_coded_mi_edge =
-          AOMMIN((sb_row + 1) * cm->seq_params.mib_size, tile->mi_row_end);
+          AOMMIN((sb_row + 1) * cm->mib_size, tile->mi_row_end);
 
       switch (dir) {
         case IBC_MOTION_ABOVE:
@@ -6611,8 +6609,7 @@
 #endif
                                 ))
       continue;
-    if (!av1_is_dv_valid(dv, cm, xd, mi_row, mi_col, bsize,
-                         cm->seq_params.mib_size_log2))
+    if (!av1_is_dv_valid(dv, cm, xd, mi_row, mi_col, bsize, cm->mib_size_log2))
       continue;
 #endif  // CONFIG_IBC_BV_IMPROVEMENT
 
@@ -9460,10 +9457,9 @@
           continue;
         }
         for (int sub_idx = 0; sub_idx < 2; sub_idx++) {
-          const PARTITION_TYPE prev_part =
-              av1_get_prev_partition(x, mi_pos_rect[rect_type][sub_idx][0],
-                                     mi_pos_rect[rect_type][sub_idx][1],
-                                     subsize, cm->seq_params.sb_size);
+          const PARTITION_TYPE prev_part = av1_get_prev_partition(
+              x, mi_pos_rect[rect_type][sub_idx][0],
+              mi_pos_rect[rect_type][sub_idx][1], subsize, cm->sb_size);
           if (prev_part != PARTITION_INVALID) {
             prune_ref_frames = true;
             break;
@@ -9474,7 +9470,7 @@
 
     if (prune_ref_frames) {
       picked_ref_frames_mask =
-          fetch_picked_ref_frames_mask(x, bsize, cm->seq_params.mib_size);
+          fetch_picked_ref_frames_mask(x, bsize, cm->mib_size);
     }
   }
 #else   // CONFIG_EXT_RECUR_PARTITIONS
@@ -9487,7 +9483,7 @@
          mbmi->partition != PARTITION_HORZ) ||
         cpi->sf.inter_sf.prune_ref_frame_for_rect_partitions >= 2) {
       picked_ref_frames_mask =
-          fetch_picked_ref_frames_mask(x, bsize, cm->seq_params.mib_size);
+          fetch_picked_ref_frames_mask(x, bsize, cm->mib_size);
     }
   }
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
@@ -9593,7 +9589,7 @@
       (AOMMIN(cm->width, cm->height) > 480 && cpi->speed <= 1) ? 0 : 1;
   if (do_pruning && sf->intra_sf.skip_intra_in_interframe) {
     // Only consider full SB.
-    const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
+    const BLOCK_SIZE sb_size = cm->sb_size;
     const int tpl_bsize_1d = cpi->tpl_data.tpl_bsize_1d;
     const int len = (block_size_wide[sb_size] / tpl_bsize_1d) *
                     (block_size_high[sb_size] / tpl_bsize_1d);
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index 3647c7d..de2167f 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -164,10 +164,8 @@
 static INLINE int av1_get_sb_mi_size(const AV1_COMMON *const cm) {
   const int mi_alloc_size_1d = mi_size_wide[cm->mi_params.mi_alloc_bsize];
   int sb_mi_rows =
-      (mi_size_wide[cm->seq_params.sb_size] + mi_alloc_size_1d - 1) /
-      mi_alloc_size_1d;
-  assert(mi_size_wide[cm->seq_params.sb_size] ==
-         mi_size_high[cm->seq_params.sb_size]);
+      (mi_size_wide[cm->sb_size] + mi_alloc_size_1d - 1) / mi_alloc_size_1d;
+  assert(mi_size_wide[cm->sb_size] == mi_size_high[cm->sb_size]);
   int sb_mi_size = sb_mi_rows * sb_mi_rows;
 
   return sb_mi_size;
diff --git a/av1/encoder/segmentation.c b/av1/encoder/segmentation.c
index 766184d..7da61f4 100644
--- a/av1/encoder/segmentation.c
+++ b/av1/encoder/segmentation.c
@@ -291,19 +291,18 @@
                  tile_info.mi_row_start * cm->mi_params.mi_stride +
                  tile_info.mi_col_start;
         for (mi_row = tile_info.mi_row_start; mi_row < tile_info.mi_row_end;
-             mi_row += cm->seq_params.mib_size,
-            mi_ptr += cm->seq_params.mib_size * cm->mi_params.mi_stride) {
+             mi_row += cm->mib_size,
+            mi_ptr += cm->mib_size * cm->mi_params.mi_stride) {
           MB_MODE_INFO **mi = mi_ptr;
           for (mi_col = tile_info.mi_col_start; mi_col < tile_info.mi_col_end;
-               mi_col += cm->seq_params.mib_size,
-              mi += cm->seq_params.mib_size) {
+               mi_col += cm->mib_size, mi += cm->mib_size) {
             const SB_INFO *sbi = av1_get_sb_info(cm, mi_row, mi_col);
             const PARTITION_TREE *ptree = sbi->ptree_root[AOM_PLANE_Y];
             count_segs_sb(cm, xd, &tile_info, mi, no_pred_segcounts,
                           temporal_predictor_count, t_unpred_seg_counts, mi_row,
                           mi_col,
 #if !CONFIG_EXT_RECUR_PARTITIONS
-                          cm->seq_params.sb_size,
+                          cm->sb_size,
 #endif  // !CONFIG_EXT_RECUR_PARTITIONS
                           ptree);
           }
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 68fa3ee..0c8304f 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -309,6 +309,9 @@
       sf->inter_sf.prune_ref_mv_idx_search = 1;
     }
   }
+#if CONFIG_BLOCK_256
+  sf->part_sf.use_square_partition_only_threshold = BLOCK_MAX;
+#endif  // CONFIG_BLOCK_256
 }
 
 static void set_good_speed_features_framesize_independent(
@@ -393,6 +396,9 @@
   } else {
     sf->mv_sf.exhaustive_searches_thresh = (1 << 25);
   }
+#if CONFIG_BLOCK_256
+  sf->mv_sf.fast_motion_estimation_on_block_256 = 1;
+#endif  // CONFIG_BLOCK_256
 
   sf->rd_sf.perform_coeff_opt = 1;
   sf->hl_sf.superres_auto_search_type = SUPERRES_AUTO_DUAL;
@@ -754,6 +760,10 @@
   part_sf->prune_rect_with_ml = 0;
   part_sf->end_part_search_after_consec_failures = 0;
   part_sf->ext_recur_depth = INT_MAX;
+#if CONFIG_BLOCK_256
+  part_sf->prune_rect_with_split_depth = 0;
+  part_sf->search_256_after_128 = 0;
+#endif  // CONFIG_BLOCK_256
   part_sf->prune_part_h_with_partition_boundary = 0;
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 }
@@ -780,6 +790,9 @@
   mv_sf->use_downsampled_sad = 0;
   mv_sf->warp_search_method = WARP_SEARCH_SQUARE;
   mv_sf->warp_search_iters = 8;
+#if CONFIG_BLOCK_256
+  mv_sf->fast_motion_estimation_on_block_256 = 0;
+#endif  // CONFIG_BLOCK_256
 }
 
 #if CONFIG_FLEX_MVRES
@@ -990,6 +1003,12 @@
       } else {
         sf->part_sf.partition_search_breakout_dist_thr = (1 << 22);
       }
+#if CONFIG_BLOCK_256
+      const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720;
+      if (is_720p_or_larger) {
+        sf->part_sf.prune_rect_with_split_depth = 1;
+      }
+#endif  // CONFIG_BLOCK_256
       sf->part_sf.partition_search_breakout_rate_thr = 100;
       AOM_FALLTHROUGH_INTENDED;
     case 4: AOM_FALLTHROUGH_INTENDED;
@@ -1069,6 +1088,9 @@
       sf->inter_sf.reuse_erp_mode_flag =
           (REUSE_PARTITION_MODE_FLAG | REUSE_INTERFRAME_FLAG);
       sf->part_sf.prune_rect_with_none_rd = 1;
+#if CONFIG_BLOCK_256
+      sf->part_sf.search_256_after_128 = 1;
+#endif  // CONFIG_BLOCK_256
       AOM_FALLTHROUGH_INTENDED;
     case 0: break;
     default: assert(0 && "Invalid ERP pruning level.");
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index 90d048d..4607d30 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -515,6 +515,11 @@
   // The recursion depth allowed for ext partitions
   int ext_recur_depth;
 
+#if CONFIG_BLOCK_256
+  // Prune rect partitions if PARTITION_SPLIT goes deep.
+  int prune_rect_with_split_depth;
+#endif  // CONFIG_BLOCK_256
+
   // Search horizontal and vertical split before PARTITION_NONE if the neighbor
   // blocks are much smaller than the current block size.
   int adaptive_partition_search_order;
@@ -529,6 +534,10 @@
   // H-parts.
   int prune_part_4_with_partition_boundary;
 #endif  // CONFIG_UNEVEN_4WAY
+#if CONFIG_BLOCK_256
+  // Delay the search for block 256 to after block 128
+  int search_256_after_128;
+#endif  // CONFIG_BLOCK_256
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
 } PARTITION_SPEED_FEATURES;
 
@@ -605,6 +614,11 @@
 
   // Maximum number of iterations in WARPED_CAUSAL refinement search
   int warp_search_iters;
+#if CONFIG_BLOCK_256
+  // Use faster motion search settings for partition blocks with at least one
+  // dimension that's >= 256
+  int fast_motion_estimation_on_block_256;
+#endif  // CONFIG_BLOCK_256
 } MV_SPEED_FEATURES;
 
 typedef struct INTER_MODE_SPEED_FEATURES {
diff --git a/av1/encoder/tokenize.h b/av1/encoder/tokenize.h
index 5968d87..b886ea6 100644
--- a/av1/encoder/tokenize.h
+++ b/av1/encoder/tokenize.h
@@ -104,9 +104,12 @@
 
 // Allocate memory for token related info.
 static AOM_INLINE void alloc_token_info(AV1_COMMON *cm, TokenInfo *token_info) {
+  // We use the frame level sb size here instead of the seq level sb size. This
+  // is because fr_sb_size <= seq_sb_size, and we want to avoid repeated
+  // allocations. So we prefer to to allocate a larger memory in one go here.
   int mi_rows_aligned_to_sb =
-      ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->seq_params.mib_size_log2);
-  int sb_rows = mi_rows_aligned_to_sb >> cm->seq_params.mib_size_log2;
+      ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->mib_size_log2);
+  int sb_rows = mi_rows_aligned_to_sb >> cm->mib_size_log2;
   const int num_planes = av1_num_planes(cm);
   unsigned int tokens =
       get_token_alloc(cm->mi_params.mb_rows, cm->mi_params.mb_cols,
diff --git a/av1/encoder/tx_search.c b/av1/encoder/tx_search.c
index 53f4f4d..a98428c 100644
--- a/av1/encoder/tx_search.c
+++ b/av1/encoder/tx_search.c
@@ -56,16 +56,25 @@
 // origin_threshold * 128 / 100
 static const uint32_t skip_pred_threshold[3][BLOCK_SIZES_ALL] = {
   {
-      64, 64, 64, 70, 60, 60, 68, 68, 68, 68, 68,
-      68, 68, 68, 68, 68, 64, 64, 70, 70, 68, 68,
+      64, 64, 64, 70, 60, 60, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
+#if CONFIG_BLOCK_256
+      68, 68, 68,
+#endif  // CONFIG_BLOCK_256
+      64, 64, 70, 70, 68, 68,
   },
   {
-      88, 88, 88, 86, 87, 87, 68, 68, 68, 68, 68,
-      68, 68, 68, 68, 68, 88, 88, 86, 86, 68, 68,
+      88, 88, 88, 86, 87, 87, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
+#if CONFIG_BLOCK_256
+      68, 68, 68,
+#endif  // CONFIG_BLOCK_256
+      88, 88, 86, 86, 68, 68,
   },
   {
-      90, 93, 93, 90, 93, 93, 74, 74, 74, 74, 74,
-      74, 74, 74, 74, 74, 90, 90, 90, 90, 74, 74,
+      90, 93, 93, 90, 93, 93, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+#if CONFIG_BLOCK_256
+      74, 74, 74,
+#endif  // CONFIG_BLOCK_256
+      90, 90, 90, 90, 74, 74,
   },
 };
 
@@ -76,8 +85,11 @@
 static const TX_SIZE max_predict_sf_tx_size[BLOCK_SIZES_ALL] = {
   TX_4X4,   TX_4X8,   TX_8X4,   TX_8X8,   TX_8X16,  TX_16X8,
   TX_16X16, TX_16X16, TX_16X16, TX_16X16, TX_16X16, TX_16X16,
-  TX_16X16, TX_16X16, TX_16X16, TX_16X16, TX_4X16,  TX_16X4,
-  TX_8X8,   TX_8X8,   TX_16X16, TX_16X16,
+  TX_16X16, TX_16X16, TX_16X16, TX_16X16,
+#if CONFIG_BLOCK_256
+  TX_16X16, TX_16X16, TX_16X16,
+#endif  // CONFIG_BLOCK_256
+  TX_4X16,  TX_16X4,  TX_8X8,   TX_8X8,   TX_16X16, TX_16X16,
 };
 
 // look-up table for sqrt of number of pixels in a transform block
@@ -191,6 +203,7 @@
   { 0, { 5, 6, -1, -1 } },
 };
 
+// TODO(any): Support rd_record_tree for BLOCK_256X256
 static const RD_RECORD_IDX_NODE *rd_record_tree[BLOCK_SIZES_ALL] = {
   NULL,                    // BLOCK_4X4
   NULL,                    // BLOCK_4X8
@@ -208,12 +221,17 @@
   rd_record_tree_64x128,   // BLOCK_64X128
   rd_record_tree_128x64,   // BLOCK_128X64
   rd_record_tree_128x128,  // BLOCK_128X128
-  NULL,                    // BLOCK_4X16
-  NULL,                    // BLOCK_16X4
-  rd_record_tree_1_4,      // BLOCK_8X32
-  rd_record_tree_4_1,      // BLOCK_32X8
-  rd_record_tree_1_4,      // BLOCK_16X64
-  rd_record_tree_4_1,      // BLOCK_64X16
+#if CONFIG_BLOCK_256
+  NULL,                // BLOCK_128X256
+  NULL,                // BLOCK_256X128
+  NULL,                // BLOCK_256X256
+#endif                 // CONFIG_BLOCK_256
+  NULL,                // BLOCK_4X16
+  NULL,                // BLOCK_16X4
+  rd_record_tree_1_4,  // BLOCK_8X32
+  rd_record_tree_4_1,  // BLOCK_32X8
+  rd_record_tree_1_4,  // BLOCK_16X64
+  rd_record_tree_4_1,  // BLOCK_64X16
 };
 
 static const int rd_record_tree_size[BLOCK_SIZES_ALL] = {
@@ -233,12 +251,17 @@
   sizeof(rd_record_tree_64x128) / sizeof(RD_RECORD_IDX_NODE),   // BLOCK_64X128
   sizeof(rd_record_tree_128x64) / sizeof(RD_RECORD_IDX_NODE),   // BLOCK_128X64
   sizeof(rd_record_tree_128x128) / sizeof(RD_RECORD_IDX_NODE),  // BLOCK_128X128
-  0,                                                            // BLOCK_4X16
-  0,                                                            // BLOCK_16X4
-  sizeof(rd_record_tree_1_4) / sizeof(RD_RECORD_IDX_NODE),      // BLOCK_8X32
-  sizeof(rd_record_tree_4_1) / sizeof(RD_RECORD_IDX_NODE),      // BLOCK_32X8
-  sizeof(rd_record_tree_1_4) / sizeof(RD_RECORD_IDX_NODE),      // BLOCK_16X64
-  sizeof(rd_record_tree_4_1) / sizeof(RD_RECORD_IDX_NODE),      // BLOCK_64X16
+#if CONFIG_BLOCK_256
+  0,                                                        // BLOCK_128X256
+  0,                                                        // BLOCK_256X128
+  0,                                                        // BLOCK_256X256
+#endif                                                      // CONFIG_BLOCK_256
+  0,                                                        // BLOCK_4X16
+  0,                                                        // BLOCK_16X4
+  sizeof(rd_record_tree_1_4) / sizeof(RD_RECORD_IDX_NODE),  // BLOCK_8X32
+  sizeof(rd_record_tree_4_1) / sizeof(RD_RECORD_IDX_NODE),  // BLOCK_32X8
+  sizeof(rd_record_tree_1_4) / sizeof(RD_RECORD_IDX_NODE),  // BLOCK_16X64
+  sizeof(rd_record_tree_4_1) / sizeof(RD_RECORD_IDX_NODE),  // BLOCK_64X16
 };
 
 static INLINE void init_rd_record_tree(TXB_RD_INFO_NODE *tree,
@@ -2210,6 +2233,7 @@
     if (plane) {
       const CctxType cctx_type = av1_get_cctx_type(xd, blk_row, blk_col);
       assert(cctx_type == CCTX_NONE);
+      (void)cctx_type;
     }
 #endif  // CONFIG_DEBUG && CONFIG_CROSS_CHROMA_TX
 
@@ -3028,12 +3052,18 @@
   // The buffer used to swap dqcoeff in macroblockd_plane so we can keep dqcoeff
   // of the best tx_type. best_dqcoeff are initialized as those dqcoeffs
   // obtained earlier with CCTX_NONE
+  const int max_sb_square_y = 1 << num_pels_log2_lookup[cm->sb_size];
+  const int max_sb_square_uv =
+      max_sb_square_y >>
+      (cm->seq_params.subsampling_x + cm->seq_params.subsampling_y);
   tran_low_t *this_dqcoeff_c1 =
-      aom_memalign(32, MAX_SB_SQUARE * sizeof(tran_low_t));
+      aom_memalign(32, max_sb_square_uv * sizeof(tran_low_t));
   tran_low_t *this_dqcoeff_c2 =
-      aom_memalign(32, MAX_SB_SQUARE * sizeof(tran_low_t));
-  memcpy(this_dqcoeff_c1, p_c1->dqcoeff, sizeof(tran_low_t) * MAX_SB_SQUARE);
-  memcpy(this_dqcoeff_c2, p_c2->dqcoeff, sizeof(tran_low_t) * MAX_SB_SQUARE);
+      aom_memalign(32, max_sb_square_uv * sizeof(tran_low_t));
+  memcpy(this_dqcoeff_c1 + BLOCK_OFFSET(block),
+         p_c1->dqcoeff + BLOCK_OFFSET(block), sizeof(tran_low_t) * max_eob);
+  memcpy(this_dqcoeff_c2 + BLOCK_OFFSET(block),
+         p_c2->dqcoeff + BLOCK_OFFSET(block), sizeof(tran_low_t) * max_eob);
   tran_low_t *orig_dqcoeff_c1 = p_c1->dqcoeff;
   tran_low_t *orig_dqcoeff_c2 = p_c2->dqcoeff;
   tran_low_t *best_dqcoeff_c1 = this_dqcoeff_c1;
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 7c3431f..f281eaf 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -149,6 +149,7 @@
 set_aom_config_var(
   CONFIG_EXT_RECUR_PARTITIONS 1 NUMBER
   "AV2 Fully recursive partitions including H partitions experiment flag")
+set_aom_config_var(CONFIG_BLOCK_256 1 NUMBER "AV2 BLOCK_256 experiment flag")
 set_aom_config_var(CONFIG_ERP_TFLITE 0 NUMBER "Build ERP with TFLite")
 set_aom_config_var(CONFIG_UNEVEN_4WAY 1 NUMBER
                    "AV2 uneven 4-way partition experiment flag")
diff --git a/build/cmake/aom_configure.cmake b/build/cmake/aom_configure.cmake
index 648472b..7b03a8f 100644
--- a/build/cmake/aom_configure.cmake
+++ b/build/cmake/aom_configure.cmake
@@ -287,19 +287,22 @@
   add_compiler_flag_if_supported("-Wunused")
   add_compiler_flag_if_supported("-Wvla")
 
-  if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND "${SANITIZE}" MATCHES
-                                           "address|undefined")
-
-    # This combination has more stack overhead, so we account for it by
-    # providing higher stack limit than usual.
-    add_c_flag_if_supported("-Wstack-usage=170000")
-    add_cxx_flag_if_supported("-Wstack-usage=270000")
-  elseif(CONFIG_RD_DEBUG) # Another case where higher stack usage is expected.
-    add_c_flag_if_supported("-Wstack-usage=140000")
-    add_cxx_flag_if_supported("-Wstack-usage=270000")
-  else()
-    add_c_flag_if_supported("-Wstack-usage=100000")
-    add_cxx_flag_if_supported("-Wstack-usage=240000")
+  if(CMAKE_C_COMPILER_ID MATCHES "GNU")
+    if(CONFIG_BLOCK_256)
+      add_c_flag_if_supported("-Wstack-usage=960000")
+      add_cxx_flag_if_supported("-Wstack-usage=960000")
+    elseif("${SANITIZE}" MATCHES "address|undefined")
+      # This combination has more stack overhead, so we account for it by
+      # providing higher stack limit than usual.
+      add_c_flag_if_supported("-Wstack-usage=170000")
+      add_cxx_flag_if_supported("-Wstack-usage=270000")
+    elseif(CONFIG_RD_DEBUG) # Another case where higher stack usage is expected.
+      add_c_flag_if_supported("-Wstack-usage=140000")
+      add_cxx_flag_if_supported("-Wstack-usage=270000")
+    else()
+      add_c_flag_if_supported("-Wstack-usage=100000")
+      add_cxx_flag_if_supported("-Wstack-usage=240000")
+    endif()
   endif()
 
   if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND SANITIZE MATCHES "address")
diff --git a/examples/inspect.c b/examples/inspect.c
index 704e1d6..1605178 100644
--- a/examples/inspect.c
+++ b/examples/inspect.c
@@ -167,16 +167,34 @@
                                ENUM(2),           ENUM(3), ENUM(4),
                                ENUM(5),           ENUM(6), LAST_ENUM };
 
-const map_entry block_size_map[] = {
-  ENUM(BLOCK_4X4),     ENUM(BLOCK_4X8),    ENUM(BLOCK_8X4),
-  ENUM(BLOCK_8X8),     ENUM(BLOCK_8X16),   ENUM(BLOCK_16X8),
-  ENUM(BLOCK_16X16),   ENUM(BLOCK_16X32),  ENUM(BLOCK_32X16),
-  ENUM(BLOCK_32X32),   ENUM(BLOCK_32X64),  ENUM(BLOCK_64X32),
-  ENUM(BLOCK_64X64),   ENUM(BLOCK_64X128), ENUM(BLOCK_128X64),
-  ENUM(BLOCK_128X128), ENUM(BLOCK_4X16),   ENUM(BLOCK_16X4),
-  ENUM(BLOCK_8X32),    ENUM(BLOCK_32X8),   ENUM(BLOCK_16X64),
-  ENUM(BLOCK_64X16),   LAST_ENUM
-};
+const map_entry block_size_map[] = { ENUM(BLOCK_4X4),
+                                     ENUM(BLOCK_4X8),
+                                     ENUM(BLOCK_8X4),
+                                     ENUM(BLOCK_8X8),
+                                     ENUM(BLOCK_8X16),
+                                     ENUM(BLOCK_16X8),
+                                     ENUM(BLOCK_16X16),
+                                     ENUM(BLOCK_16X32),
+                                     ENUM(BLOCK_32X16),
+                                     ENUM(BLOCK_32X32),
+                                     ENUM(BLOCK_32X64),
+                                     ENUM(BLOCK_64X32),
+                                     ENUM(BLOCK_64X64),
+                                     ENUM(BLOCK_64X128),
+                                     ENUM(BLOCK_128X64),
+                                     ENUM(BLOCK_128X128),
+#if CONFIG_BLOCK_256
+                                     ENUM(BLOCK_128X256),
+                                     ENUM(BLOCK_256X128),
+                                     ENUM(BLOCK_256X256),
+#endif  // CONFIG_BLOCK_256
+                                     ENUM(BLOCK_4X16),
+                                     ENUM(BLOCK_16X4),
+                                     ENUM(BLOCK_8X32),
+                                     ENUM(BLOCK_32X8),
+                                     ENUM(BLOCK_16X64),
+                                     ENUM(BLOCK_64X16),
+                                     LAST_ENUM };
 
 #define TX_SKIP -1
 
diff --git a/test/av1_convolve_test.cc b/test/av1_convolve_test.cc
index ab43f4b..abcd0b6 100644
--- a/test/av1_convolve_test.cc
+++ b/test/av1_convolve_test.cc
@@ -143,7 +143,7 @@
 
 TEST_F(AV1ConvolveParametersTest, GetHighbdTestParams) {
   auto v = GetHighbdTestParams(av1_highbd_convolve_x_sr_c);
-  ASSERT_EQ(54U, v.size());
+  ASSERT_EQ(60U, v.size());
   int num_10 = 0;
   int num_12 = 0;
   for (const auto &p : v) {
@@ -576,7 +576,7 @@
 
 TEST_F(AV1ConvolveParametersTest, GetHighbdLumaTestParams) {
   auto v = GetHighbdLumaTestParams(av1_highbd_dist_wtd_convolve_x_c);
-  ASSERT_EQ(44U, v.size());
+  ASSERT_EQ(50U, v.size());
   int num_10 = 0;
   int num_12 = 0;
   for (const auto &e : v) {
@@ -1571,6 +1571,39 @@
 //////////////////////////////////////////////////////////
 
 #if CONFIG_PC_WIENER
+
+// Generate the list of all block widths / heights that need to be tested for
+// pc_wiener.
+template <typename T>
+std::vector<TestParam<T>> GetPCWienerTestParams(
+    std::initializer_list<int> bit_depths, T test_func) {
+  std::set<BlockSize> sizes;
+  for (int b = BLOCK_4X4; b < BLOCK_SIZES_ALL; ++b) {
+    const int w = block_size_wide[b];
+    const int h = block_size_high[b];
+    if (w > RESTORATION_PROC_UNIT_SIZE || h > RESTORATION_PROC_UNIT_SIZE) {
+      continue;
+    }
+    sizes.insert(BlockSize(w, h));
+    // Add in smaller chroma sizes as well.
+    if (w == 4 || h == 4) {
+      sizes.insert(BlockSize(w / 2, h / 2));
+    }
+  }
+  std::vector<TestParam<T>> result;
+  for (const BlockSize &block : sizes) {
+    for (int bd : bit_depths) {
+      result.push_back(TestParam<T>(block, bd, test_func));
+    }
+  }
+  return result;
+}
+template <typename T>
+::testing::internal::ParamGenerator<TestParam<T>> BuildHighbdPCWienerParams(
+    T test_func) {
+  return ::testing::ValuesIn(GetPCWienerTestParams({ 10, 12 }, test_func));
+}
+
 typedef void (*fill_directional_feature_buffers_highbd_func)(
     int *feature_sum_buffers[], int16_t *feature_line_buffers[], int row,
     int buffer_row, const uint16_t *dgd, int dgd_stride, int width,
@@ -1766,7 +1799,7 @@
 #if HAVE_AVX2
 INSTANTIATE_TEST_SUITE_P(
     AVX2, AV1FillDirFeatureBufHighbdTest,
-    BuildHighbdParams(fill_directional_feature_buffers_highbd_avx2));
+    BuildHighbdPCWienerParams(fill_directional_feature_buffers_highbd_avx2));
 #endif  // HAVE_AVX2
 
 typedef void (*FillTSkipSumBufferFunc)(int row, const uint8_t *tskip,
diff --git a/test/comp_avg_pred_test.h b/test/comp_avg_pred_test.h
index 3f1b3c5..c69351d 100644
--- a/test/comp_avg_pred_test.h
+++ b/test/comp_avg_pred_test.h
@@ -26,7 +26,11 @@
 #include "aom_ports/aom_timer.h"
 
 namespace libaom_test {
+#if CONFIG_BLOCK_256
+const int kMaxSize = MAX_SB_SIZE + 32;  // padding
+#else
 const int kMaxSize = 128 + 32;  // padding
+#endif  // CONFIG_BLOCK_256
 
 namespace AV1DISTWTDCOMPAVG {
 
diff --git a/test/masked_sad_test.cc b/test/masked_sad_test.cc
index b81f765..ee376f0 100644
--- a/test/masked_sad_test.cc
+++ b/test/masked_sad_test.cc
@@ -184,6 +184,16 @@
              &aom_highbd_masked_sad128x64_ssse3),
   make_tuple(&aom_highbd_masked_sad128x128_avx2,
              &aom_highbd_masked_sad128x128_ssse3),
+
+#if CONFIG_BLOCK_256
+  make_tuple(&aom_highbd_masked_sad128x256_avx2,
+             &aom_highbd_masked_sad128x256_c),
+  make_tuple(&aom_highbd_masked_sad256x128_avx2,
+             &aom_highbd_masked_sad256x128_c),
+  make_tuple(&aom_highbd_masked_sad256x256_avx2,
+             &aom_highbd_masked_sad256x256_c),
+#endif  // CONFIG_BLOCK_256
+
   make_tuple(&aom_highbd_masked_sad4x16_avx2, &aom_highbd_masked_sad4x16_ssse3),
   make_tuple(&aom_highbd_masked_sad16x4_avx2, &aom_highbd_masked_sad16x4_ssse3),
   make_tuple(&aom_highbd_masked_sad8x32_avx2, &aom_highbd_masked_sad8x32_ssse3),
diff --git a/test/masked_variance_test.cc b/test/masked_variance_test.cc
index c4584c9..f4cde34 100644
--- a/test/masked_variance_test.cc
+++ b/test/masked_variance_test.cc
@@ -180,6 +180,14 @@
 
 #if HAVE_SSSE3
 const HighbdMaskedSubPixelVarianceParam hbd_sub_pel_var_test[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance256x256_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance256x256_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance256x128_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance256x128_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance128x256_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance128x256_c, AOM_BITS_8),
+#endif  // CONFIG_BLOCK_256
   make_tuple(&aom_highbd_8_masked_sub_pixel_variance128x128_ssse3,
              &aom_highbd_8_masked_sub_pixel_variance128x128_c, AOM_BITS_8),
   make_tuple(&aom_highbd_8_masked_sub_pixel_variance128x64_ssse3,
@@ -212,6 +220,15 @@
              &aom_highbd_8_masked_sub_pixel_variance4x8_c, AOM_BITS_8),
   make_tuple(&aom_highbd_8_masked_sub_pixel_variance4x4_ssse3,
              &aom_highbd_8_masked_sub_pixel_variance4x4_c, AOM_BITS_8),
+
+#if CONFIG_BLOCK_256
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance256x256_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance256x256_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance256x128_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance256x128_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance128x256_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance128x256_c, AOM_BITS_10),
+#endif  // CONFIG_BLOCK_256
   make_tuple(&aom_highbd_10_masked_sub_pixel_variance128x128_ssse3,
              &aom_highbd_10_masked_sub_pixel_variance128x128_c, AOM_BITS_10),
   make_tuple(&aom_highbd_10_masked_sub_pixel_variance128x64_ssse3,
@@ -244,6 +261,15 @@
              &aom_highbd_10_masked_sub_pixel_variance4x8_c, AOM_BITS_10),
   make_tuple(&aom_highbd_10_masked_sub_pixel_variance4x4_ssse3,
              &aom_highbd_10_masked_sub_pixel_variance4x4_c, AOM_BITS_10),
+
+#if CONFIG_BLOCK_256
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance256x256_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance256x256_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance256x128_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance256x128_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance128x256_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance128x256_c, AOM_BITS_12),
+#endif  // CONFIG_BLOCK_256
   make_tuple(&aom_highbd_12_masked_sub_pixel_variance128x128_ssse3,
              &aom_highbd_12_masked_sub_pixel_variance128x128_c, AOM_BITS_12),
   make_tuple(&aom_highbd_12_masked_sub_pixel_variance128x64_ssse3,
diff --git a/test/obmc_sad_test.cc b/test/obmc_sad_test.cc
index 47cd171..8f3ea94 100644
--- a/test/obmc_sad_test.cc
+++ b/test/obmc_sad_test.cc
@@ -119,6 +119,11 @@
 
 #if HAVE_AVX2
 ObmcSadHBDTest::ParamType avx2_functions_hbd[] = {
+#if CONFIG_BLOCK_256
+  TestFuncs(aom_highbd_obmc_sad256x256_c, aom_highbd_obmc_sad256x256_avx2),
+  TestFuncs(aom_highbd_obmc_sad256x128_c, aom_highbd_obmc_sad256x128_avx2),
+  TestFuncs(aom_highbd_obmc_sad128x256_c, aom_highbd_obmc_sad128x256_avx2),
+#endif  // CONFIG_BLOCK_256
   TestFuncs(aom_highbd_obmc_sad128x128_c, aom_highbd_obmc_sad128x128_avx2),
   TestFuncs(aom_highbd_obmc_sad128x64_c, aom_highbd_obmc_sad128x64_avx2),
   TestFuncs(aom_highbd_obmc_sad64x128_c, aom_highbd_obmc_sad64x128_avx2),
diff --git a/test/obmc_variance_test.cc b/test/obmc_variance_test.cc
index 952db8e..10e8fd5 100644
--- a/test/obmc_variance_test.cc
+++ b/test/obmc_variance_test.cc
@@ -97,6 +97,14 @@
 
 #if HAVE_SSE4_1
 ObmcVarianceHBDTest::ParamType sse4_functions_hbd[] = {
+#if CONFIG_BLOCK_256
+  TestFuncs(aom_highbd_obmc_variance256x256_c,
+            aom_highbd_obmc_variance256x256_sse4_1, 8),
+  TestFuncs(aom_highbd_obmc_variance256x128_c,
+            aom_highbd_obmc_variance256x128_sse4_1, 8),
+  TestFuncs(aom_highbd_obmc_variance128x256_c,
+            aom_highbd_obmc_variance128x256_sse4_1, 8),
+#endif  // CONFIG_BLOCK_256
   TestFuncs(aom_highbd_obmc_variance128x128_c,
             aom_highbd_obmc_variance128x128_sse4_1, 8),
   TestFuncs(aom_highbd_obmc_variance128x64_c,
@@ -129,6 +137,15 @@
             8),
   TestFuncs(aom_highbd_obmc_variance4x4_c, aom_highbd_obmc_variance4x4_sse4_1,
             8),
+
+#if CONFIG_BLOCK_256
+  TestFuncs(aom_highbd_obmc_variance256x256_c,
+            aom_highbd_obmc_variance256x256_sse4_1, 10),
+  TestFuncs(aom_highbd_obmc_variance256x128_c,
+            aom_highbd_obmc_variance256x128_sse4_1, 10),
+  TestFuncs(aom_highbd_obmc_variance128x256_c,
+            aom_highbd_obmc_variance128x256_sse4_1, 10),
+#endif  // CONFIG_BLOCK_256
   TestFuncs(aom_highbd_10_obmc_variance128x128_c,
             aom_highbd_10_obmc_variance128x128_sse4_1, 10),
   TestFuncs(aom_highbd_10_obmc_variance128x64_c,
@@ -161,6 +178,15 @@
             aom_highbd_10_obmc_variance4x8_sse4_1, 10),
   TestFuncs(aom_highbd_10_obmc_variance4x4_c,
             aom_highbd_10_obmc_variance4x4_sse4_1, 10),
+
+#if CONFIG_BLOCK_256
+  TestFuncs(aom_highbd_obmc_variance256x256_c,
+            aom_highbd_obmc_variance256x256_sse4_1, 12),
+  TestFuncs(aom_highbd_obmc_variance256x128_c,
+            aom_highbd_obmc_variance256x128_sse4_1, 12),
+  TestFuncs(aom_highbd_obmc_variance128x256_c,
+            aom_highbd_obmc_variance128x256_sse4_1, 12),
+#endif  // CONFIG_BLOCK_256
   TestFuncs(aom_highbd_12_obmc_variance128x128_c,
             aom_highbd_12_obmc_variance128x128_sse4_1, 12),
   TestFuncs(aom_highbd_12_obmc_variance128x64_c,
diff --git a/test/sad_test.cc b/test/sad_test.cc
index fbacefb..3f1b7a3 100644
--- a/test/sad_test.cc
+++ b/test/sad_test.cc
@@ -92,11 +92,11 @@
     reference_data16_ = reinterpret_cast<uint16_t *>(
         aom_memalign(kDataAlignment, kDataBufferSize * sizeof(uint16_t)));
     second_pred16_ = reinterpret_cast<uint16_t *>(
-        aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
+        aom_memalign(kDataAlignment, kDataBlockSize * sizeof(uint16_t)));
     comp_pred16_ = reinterpret_cast<uint16_t *>(
-        aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
+        aom_memalign(kDataAlignment, kDataBlockSize * sizeof(uint16_t)));
     comp_pred16_test_ = reinterpret_cast<uint16_t *>(
-        aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
+        aom_memalign(kDataAlignment, kDataBlockSize * sizeof(uint16_t)));
   }
 
   static void TearDownTestSuite() {
@@ -115,9 +115,10 @@
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
-  // Handle up to 4 128x128 blocks, with stride up to 256
+  // Handle up to 4 256x256 blocks, with stride up to 256
   static const int kDataAlignment = 16;
-  static const int kDataBlockSize = 128 * 256;
+  static const int kMaxDim = 256;
+  static const int kDataBlockSize = kMaxDim * (kMaxDim + 1);
   static const int kDataBufferSize = 4 * kDataBlockSize;
 
   virtual void SetUp() {
@@ -129,7 +130,7 @@
     comp_pred_test_ = comp_pred16_test_;
     mask_ = (1 << bit_depth_) - 1;
     source_stride_ = (width_ + 31) & ~31;
-    reference_stride_ = width_ * 2;
+    reference_stride_ = width_;
     rnd_.Reset(ACMRandom::DeterministicSeed());
   }
 
@@ -1073,6 +1074,11 @@
 //------------------------------------------------------------------------------
 // C functions
 const SadMxNParam c_tests[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256_c, 8),
+  make_tuple(256, 128, &aom_highbd_sad256x128_c, 8),
+  make_tuple(128, 256, &aom_highbd_sad128x256_c, 8),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad128x128_c, 8),
   make_tuple(128, 64, &aom_highbd_sad128x64_c, 8),
   make_tuple(64, 128, &aom_highbd_sad64x128_c, 8),
@@ -1089,6 +1095,11 @@
   make_tuple(8, 4, &aom_highbd_sad8x4_c, 8),
   make_tuple(4, 8, &aom_highbd_sad4x8_c, 8),
   make_tuple(4, 4, &aom_highbd_sad4x4_c, 8),
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256_c, 10),
+  make_tuple(256, 128, &aom_highbd_sad256x128_c, 10),
+  make_tuple(128, 256, &aom_highbd_sad128x256_c, 10),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad128x128_c, 10),
   make_tuple(128, 64, &aom_highbd_sad128x64_c, 10),
   make_tuple(64, 128, &aom_highbd_sad64x128_c, 10),
@@ -1105,6 +1116,11 @@
   make_tuple(8, 4, &aom_highbd_sad8x4_c, 10),
   make_tuple(4, 8, &aom_highbd_sad4x8_c, 10),
   make_tuple(4, 4, &aom_highbd_sad4x4_c, 10),
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256_c, 12),
+  make_tuple(256, 128, &aom_highbd_sad256x128_c, 12),
+  make_tuple(128, 256, &aom_highbd_sad128x256_c, 12),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad128x128_c, 12),
   make_tuple(128, 64, &aom_highbd_sad128x64_c, 12),
   make_tuple(64, 128, &aom_highbd_sad64x128_c, 12),
@@ -1146,6 +1162,11 @@
 INSTANTIATE_TEST_SUITE_P(C, SADTest, ::testing::ValuesIn(c_tests));
 
 const SadSkipMxNParam skip_c_tests[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256_c, 8),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128_c, 8),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256_c, 8),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad_skip_128x128_c, 8),
   make_tuple(128, 64, &aom_highbd_sad_skip_128x64_c, 8),
   make_tuple(64, 128, &aom_highbd_sad_skip_64x128_c, 8),
@@ -1169,6 +1190,11 @@
   make_tuple(16, 4, &aom_highbd_sad_skip_16x4_c, 8),
   make_tuple(4, 16, &aom_highbd_sad_skip_4x16_c, 8),
 
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256_c, 10),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128_c, 10),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256_c, 10),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad_skip_128x128_c, 10),
   make_tuple(128, 64, &aom_highbd_sad_skip_128x64_c, 10),
   make_tuple(64, 128, &aom_highbd_sad_skip_64x128_c, 10),
@@ -1192,6 +1218,11 @@
   make_tuple(16, 4, &aom_highbd_sad_skip_16x4_c, 10),
   make_tuple(4, 16, &aom_highbd_sad_skip_4x16_c, 10),
 
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256_c, 12),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128_c, 12),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256_c, 12),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad_skip_128x128_c, 12),
   make_tuple(128, 64, &aom_highbd_sad_skip_128x64_c, 12),
   make_tuple(64, 128, &aom_highbd_sad_skip_64x128_c, 12),
@@ -1218,6 +1249,11 @@
 INSTANTIATE_TEST_SUITE_P(C, SADSkipTest, ::testing::ValuesIn(skip_c_tests));
 
 const SadMxNAvgParam avg_c_tests[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256_avg_c, 8),
+  make_tuple(256, 128, &aom_highbd_sad256x128_avg_c, 8),
+  make_tuple(128, 256, &aom_highbd_sad128x256_avg_c, 8),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad128x128_avg_c, 8),
   make_tuple(128, 64, &aom_highbd_sad128x64_avg_c, 8),
   make_tuple(64, 128, &aom_highbd_sad64x128_avg_c, 8),
@@ -1234,6 +1270,12 @@
   make_tuple(8, 4, &aom_highbd_sad8x4_avg_c, 8),
   make_tuple(4, 8, &aom_highbd_sad4x8_avg_c, 8),
   make_tuple(4, 4, &aom_highbd_sad4x4_avg_c, 8),
+
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256_avg_c, 10),
+  make_tuple(256, 128, &aom_highbd_sad256x128_avg_c, 10),
+  make_tuple(128, 256, &aom_highbd_sad128x256_avg_c, 10),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad128x128_avg_c, 10),
   make_tuple(128, 64, &aom_highbd_sad128x64_avg_c, 10),
   make_tuple(64, 128, &aom_highbd_sad64x128_avg_c, 10),
@@ -1250,6 +1292,12 @@
   make_tuple(8, 4, &aom_highbd_sad8x4_avg_c, 10),
   make_tuple(4, 8, &aom_highbd_sad4x8_avg_c, 10),
   make_tuple(4, 4, &aom_highbd_sad4x4_avg_c, 10),
+
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256_avg_c, 12),
+  make_tuple(256, 128, &aom_highbd_sad256x128_avg_c, 12),
+  make_tuple(128, 256, &aom_highbd_sad128x256_avg_c, 12),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad128x128_avg_c, 12),
   make_tuple(128, 64, &aom_highbd_sad128x64_avg_c, 12),
   make_tuple(64, 128, &aom_highbd_sad64x128_avg_c, 12),
@@ -1291,6 +1339,11 @@
 INSTANTIATE_TEST_SUITE_P(C, SADavgTest, ::testing::ValuesIn(avg_c_tests));
 
 const SadMxNx4Param x4d_c_tests[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256x4d_c, 8),
+  make_tuple(256, 128, &aom_highbd_sad256x128x4d_c, 8),
+  make_tuple(128, 256, &aom_highbd_sad128x256x4d_c, 8),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad128x128x4d_c, 8),
   make_tuple(128, 64, &aom_highbd_sad128x64x4d_c, 8),
   make_tuple(64, 128, &aom_highbd_sad64x128x4d_c, 8),
@@ -1307,6 +1360,12 @@
   make_tuple(8, 4, &aom_highbd_sad8x4x4d_c, 8),
   make_tuple(4, 8, &aom_highbd_sad4x8x4d_c, 8),
   make_tuple(4, 4, &aom_highbd_sad4x4x4d_c, 8),
+
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256x4d_c, 10),
+  make_tuple(256, 128, &aom_highbd_sad256x128x4d_c, 10),
+  make_tuple(128, 256, &aom_highbd_sad128x256x4d_c, 10),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad128x128x4d_c, 10),
   make_tuple(128, 64, &aom_highbd_sad128x64x4d_c, 10),
   make_tuple(64, 128, &aom_highbd_sad64x128x4d_c, 10),
@@ -1323,6 +1382,12 @@
   make_tuple(8, 4, &aom_highbd_sad8x4x4d_c, 10),
   make_tuple(4, 8, &aom_highbd_sad4x8x4d_c, 10),
   make_tuple(4, 4, &aom_highbd_sad4x4x4d_c, 10),
+
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256x4d_c, 12),
+  make_tuple(256, 128, &aom_highbd_sad256x128x4d_c, 12),
+  make_tuple(128, 256, &aom_highbd_sad128x256x4d_c, 12),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad128x128x4d_c, 12),
   make_tuple(128, 64, &aom_highbd_sad128x64x4d_c, 12),
   make_tuple(64, 128, &aom_highbd_sad64x128x4d_c, 12),
@@ -1364,6 +1429,11 @@
 INSTANTIATE_TEST_SUITE_P(C, SADx4Test, ::testing::ValuesIn(x4d_c_tests));
 
 const SadMxNx4Param skip_x4d_c_tests[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256x4d_c, 8),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128x4d_c, 8),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256x4d_c, 8),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad_skip_128x128x4d_c, 8),
   make_tuple(128, 64, &aom_highbd_sad_skip_128x64x4d_c, 8),
   make_tuple(64, 128, &aom_highbd_sad_skip_64x128x4d_c, 8),
@@ -1387,6 +1457,11 @@
   make_tuple(16, 4, &aom_highbd_sad_skip_16x4x4d_c, 8),
   make_tuple(4, 16, &aom_highbd_sad_skip_4x16x4d_c, 8),
 
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256x4d_c, 10),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128x4d_c, 10),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256x4d_c, 10),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad_skip_128x128x4d_c, 10),
   make_tuple(128, 64, &aom_highbd_sad_skip_128x64x4d_c, 10),
   make_tuple(64, 128, &aom_highbd_sad_skip_64x128x4d_c, 10),
@@ -1410,6 +1485,11 @@
   make_tuple(16, 4, &aom_highbd_sad_skip_16x4x4d_c, 10),
   make_tuple(4, 16, &aom_highbd_sad_skip_4x16x4d_c, 10),
 
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256x4d_c, 12),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128x4d_c, 12),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256x4d_c, 12),
+#endif  // CONFIG_BLOCK_256
   make_tuple(128, 128, &aom_highbd_sad_skip_128x128x4d_c, 12),
   make_tuple(128, 64, &aom_highbd_sad_skip_128x64x4d_c, 12),
   make_tuple(64, 128, &aom_highbd_sad_skip_64x128x4d_c, 12),
@@ -1763,6 +1843,18 @@
 
 #if HAVE_AVX2
 const SadMxNParam avx2_tests[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256_avx2, 8),
+  make_tuple(256, 128, &aom_highbd_sad256x128_avx2, 8),
+  make_tuple(128, 256, &aom_highbd_sad128x256_avx2, 8),
+  make_tuple(256, 256, &aom_highbd_sad256x256_avx2, 10),
+  make_tuple(256, 128, &aom_highbd_sad256x128_avx2, 10),
+  make_tuple(128, 256, &aom_highbd_sad128x256_avx2, 10),
+  make_tuple(256, 256, &aom_highbd_sad256x256_avx2, 12),
+  make_tuple(256, 128, &aom_highbd_sad256x128_avx2, 12),
+  make_tuple(128, 256, &aom_highbd_sad128x256_avx2, 12),
+#endif  // CONFIG_BLOCK_256
+
   make_tuple(128, 128, &aom_highbd_sad128x128_avx2, 8),
   make_tuple(128, 128, &aom_highbd_sad128x128_avx2, 10),
   make_tuple(128, 128, &aom_highbd_sad128x128_avx2, 12),
@@ -1813,6 +1905,17 @@
 INSTANTIATE_TEST_SUITE_P(AVX2, SADTest, ::testing::ValuesIn(avx2_tests));
 
 const SadSkipMxNParam skip_avx2_tests[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256_avx2, 8),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128_avx2, 8),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256_avx2, 8),
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256_avx2, 10),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128_avx2, 10),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256_avx2, 10),
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256_avx2, 12),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128_avx2, 12),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256_avx2, 12),
+#endif  // CONFIG_BLOCK_256
 
   make_tuple(128, 128, &aom_highbd_sad_skip_128x128_avx2, 8),
   make_tuple(128, 64, &aom_highbd_sad_skip_128x64_avx2, 8),
@@ -1857,6 +1960,18 @@
                          ::testing::ValuesIn(skip_avx2_tests));
 
 const SadMxNAvgParam avg_avx2_tests[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256_avg_avx2, 8),
+  make_tuple(256, 128, &aom_highbd_sad256x128_avg_avx2, 8),
+  make_tuple(128, 256, &aom_highbd_sad128x256_avg_avx2, 8),
+  make_tuple(256, 256, &aom_highbd_sad256x256_avg_avx2, 10),
+  make_tuple(256, 128, &aom_highbd_sad256x128_avg_avx2, 10),
+  make_tuple(128, 256, &aom_highbd_sad128x256_avg_avx2, 10),
+  make_tuple(256, 256, &aom_highbd_sad256x256_avg_avx2, 12),
+  make_tuple(256, 128, &aom_highbd_sad256x128_avg_avx2, 12),
+  make_tuple(128, 256, &aom_highbd_sad128x256_avg_avx2, 12),
+#endif  // CONFIG_BLOCK_256
+
   make_tuple(128, 128, &aom_highbd_sad128x128_avg_avx2, 8),
   make_tuple(128, 128, &aom_highbd_sad128x128_avg_avx2, 10),
   make_tuple(128, 128, &aom_highbd_sad128x128_avg_avx2, 12),
@@ -1907,6 +2022,18 @@
 INSTANTIATE_TEST_SUITE_P(AVX2, SADavgTest, ::testing::ValuesIn(avg_avx2_tests));
 
 const SadSkipMxNx4Param skip_x4d_avx2_tests[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256x4d_avx2, 8),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128x4d_avx2, 8),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256x4d_avx2, 8),
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256x4d_avx2, 10),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128x4d_avx2, 10),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256x4d_avx2, 10),
+  make_tuple(256, 256, &aom_highbd_sad_skip_256x256x4d_avx2, 12),
+  make_tuple(256, 128, &aom_highbd_sad_skip_256x128x4d_avx2, 12),
+  make_tuple(128, 256, &aom_highbd_sad_skip_128x256x4d_avx2, 12),
+#endif  // CONFIG_BLOCK_256
+
   make_tuple(128, 128, &aom_highbd_sad_skip_128x128x4d_avx2, 8),
   make_tuple(128, 64, &aom_highbd_sad_skip_128x64x4d_avx2, 8),
   make_tuple(64, 128, &aom_highbd_sad_skip_64x128x4d_avx2, 8),
@@ -1956,6 +2083,18 @@
                          ::testing::ValuesIn(skip_x4d_avx2_tests));
 
 const SadMxNx4Param x4d_avx2_tests[] = {
+#if CONFIG_BLOCK_256
+  make_tuple(256, 256, &aom_highbd_sad256x256x4d_avx2, 8),
+  make_tuple(256, 128, &aom_highbd_sad256x128x4d_avx2, 8),
+  make_tuple(128, 256, &aom_highbd_sad128x256x4d_avx2, 8),
+  make_tuple(256, 256, &aom_highbd_sad256x256x4d_avx2, 10),
+  make_tuple(256, 128, &aom_highbd_sad256x128x4d_avx2, 10),
+  make_tuple(128, 256, &aom_highbd_sad128x256x4d_avx2, 10),
+  make_tuple(256, 256, &aom_highbd_sad256x256x4d_avx2, 12),
+  make_tuple(256, 128, &aom_highbd_sad256x128x4d_avx2, 12),
+  make_tuple(128, 256, &aom_highbd_sad128x256x4d_avx2, 12),
+#endif  // CONFIG_BLOCK_256
+
   make_tuple(128, 128, &aom_highbd_sad128x128x4d_avx2, 8),
   make_tuple(128, 128, &aom_highbd_sad128x128x4d_avx2, 10),
   make_tuple(128, 128, &aom_highbd_sad128x128x4d_avx2, 12),
diff --git a/test/variance_test.cc b/test/variance_test.cc
index d6207a4..4e1942a 100644
--- a/test/variance_test.cc
+++ b/test/variance_test.cc
@@ -385,7 +385,7 @@
   unsigned int sse, var, expected;
   ASM_REGISTER_STATE_CHECK(
       var = params_.func(src_, width(), ref_, width(), &sse));
-  expected = block_size() * 255 * 255 / 4;
+  expected = block_size() * 255l * 255 / 4;
   EXPECT_EQ(expected, var);
 }
 
@@ -1348,7 +1348,6 @@
                          ::testing::ValuesIn(kArrayHBDVariance_sse2));
 
 #if HAVE_AVX2
-
 INSTANTIATE_TEST_SUITE_P(
     AVX2, MseHBDWxHTest,
     ::testing::Values(MseHBDWxHParams(3, 3, &aom_mse_wxh_16bit_highbd_avx2, 10),
@@ -1358,6 +1357,11 @@
                                       10)));
 
 const VarianceParams kArrayHBDVariance_avx2[] = {
+#if CONFIG_BLOCK_256
+  VarianceParams(8, 8, &aom_highbd_8_variance256x256_avx2, 8),
+  VarianceParams(8, 7, &aom_highbd_8_variance256x128_avx2, 8),
+  VarianceParams(7, 8, &aom_highbd_8_variance128x256_avx2, 8),
+#endif  // CONFIG_BLOCK_256
   VarianceParams(7, 7, &aom_highbd_8_variance128x128_avx2, 8),
   VarianceParams(7, 6, &aom_highbd_8_variance128x64_avx2, 8),
   VarianceParams(6, 7, &aom_highbd_8_variance64x128_avx2, 8),
@@ -1377,6 +1381,11 @@
   VarianceParams(4, 6, &aom_highbd_8_variance16x64_avx2, 8),
   VarianceParams(6, 4, &aom_highbd_8_variance64x16_avx2, 8),
 
+#if CONFIG_BLOCK_256
+  VarianceParams(8, 8, &aom_highbd_10_variance256x256_avx2, 10),
+  VarianceParams(8, 7, &aom_highbd_10_variance256x128_avx2, 10),
+  VarianceParams(7, 8, &aom_highbd_10_variance128x256_avx2, 10),
+#endif  // CONFIG_BLOCK_256
   VarianceParams(7, 7, &aom_highbd_10_variance128x128_avx2, 10),
   VarianceParams(7, 6, &aom_highbd_10_variance128x64_avx2, 10),
   VarianceParams(6, 7, &aom_highbd_10_variance64x128_avx2, 10),
@@ -1396,6 +1405,11 @@
   VarianceParams(4, 6, &aom_highbd_10_variance16x64_avx2, 10),
   VarianceParams(6, 4, &aom_highbd_10_variance64x16_avx2, 10),
 
+#if CONFIG_BLOCK_256
+  VarianceParams(8, 8, &aom_highbd_12_variance256x256_avx2, 12),
+  VarianceParams(8, 7, &aom_highbd_12_variance256x128_avx2, 12),
+  VarianceParams(7, 8, &aom_highbd_12_variance128x256_avx2, 12),
+#endif  // CONFIG_BLOCK_256
   VarianceParams(7, 7, &aom_highbd_12_variance128x128_avx2, 12),
   VarianceParams(7, 6, &aom_highbd_12_variance128x64_avx2, 12),
   VarianceParams(6, 7, &aom_highbd_12_variance64x128_avx2, 12),
@@ -1420,6 +1434,14 @@
                          ::testing::ValuesIn(kArrayHBDVariance_avx2));
 
 const SubpelVarianceParams kArrayHBDSubpelVariance_avx2[] = {
+#if CONFIG_BLOCK_256X256
+//  SubpelVarianceParams(8, 8, &aom_highbd_12_sub_pixel_variance256x256_avx2,
+//  12),
+//  SubpelVarianceParams(8, 7, &aom_highbd_12_sub_pixel_variance256x128_avx2,
+//  12),
+//  SubpelVarianceParams(7, 8, &aom_highbd_12_sub_pixel_variance128x256_avx2,
+//  12),
+#endif  // CONFIG_BLOCK_256X256
   // SubpelVarianceParams(7, 7, &aom_highbd_12_sub_pixel_variance128x128_avx2,
   // 12),
   // SubpelVarianceParams(7, 6, &aom_highbd_12_sub_pixel_variance128x64_avx2,
@@ -1442,6 +1464,11 @@
   // 12),
   SubpelVarianceParams(4, 3, &aom_highbd_12_sub_pixel_variance16x8_avx2, 12),
 
+#if CONFIG_BLOCK_256X256
+  SubpelVarianceParams(8, 8, &aom_highbd_10_sub_pixel_variance256x256_avx2, 10),
+  SubpelVarianceParams(8, 7, &aom_highbd_10_sub_pixel_variance256x128_avx2, 10),
+  SubpelVarianceParams(7, 8, &aom_highbd_10_sub_pixel_variance128x256_avx2, 10),
+#endif  // CONFIG_BLOCK_256X256
   SubpelVarianceParams(7, 7, &aom_highbd_10_sub_pixel_variance128x128_avx2, 10),
   SubpelVarianceParams(7, 6, &aom_highbd_10_sub_pixel_variance128x64_avx2, 10),
   SubpelVarianceParams(6, 7, &aom_highbd_10_sub_pixel_variance64x128_avx2, 10),
@@ -1454,6 +1481,11 @@
   SubpelVarianceParams(4, 4, &aom_highbd_10_sub_pixel_variance16x16_avx2, 10),
   SubpelVarianceParams(4, 3, &aom_highbd_10_sub_pixel_variance16x8_avx2, 10),
 
+#if CONFIG_BLOCK_256X256
+  SubpelVarianceParams(8, 8, &aom_highbd_8_sub_pixel_variance256x256_avx2, 8),
+  SubpelVarianceParams(8, 7, &aom_highbd_8_sub_pixel_variance256x128_avx2, 8),
+  SubpelVarianceParams(7, 8, &aom_highbd_8_sub_pixel_variance128x256_avx2, 8),
+#endif  // CONFIG_BLOCK_256X256
   SubpelVarianceParams(7, 7, &aom_highbd_8_sub_pixel_variance128x128_avx2, 8),
   SubpelVarianceParams(7, 6, &aom_highbd_8_sub_pixel_variance128x64_avx2, 8),
   SubpelVarianceParams(6, 7, &aom_highbd_8_sub_pixel_variance64x128_avx2, 8),
diff --git a/tools/aom_entropy_optimizer.c b/tools/aom_entropy_optimizer.c
index e66ecc4..5ef8ec1 100644
--- a/tools/aom_entropy_optimizer.c
+++ b/tools/aom_entropy_optimizer.c
@@ -27,6 +27,7 @@
 #include <assert.h>
 #include <stdio.h>
 
+#include "av1/common/enums.h"
 #include "config/aom_config.h"
 
 #include "av1/encoder/encoder.h"
@@ -446,6 +447,18 @@
       &fc.do_split[0][0][0], probsfile, 3, cts_each_dim,
       "static aom_cdf_prob default_do_split_cdf"
       "[PARTITION_STRUCTURE_NUM][PARTITION_CONTEXTS][CDF_SIZE(2)]");
+#if CONFIG_BLOCK_256
+  cts_each_dim[0] = PARTITION_STRUCTURE_NUM;
+  cts_each_dim[1] = SQUARE_SPLIT_CONTEXTS;
+  cts_each_dim[2] = 2;
+  optimize_cdf_table(
+      &fc.do_square_split[0][0][0], probsfile, 3, cts_each_dim,
+      "static aom_cdf_prob default_do_square_split_cdf"
+      "[PARTITION_STRUCTURE_NUM][SQUARE_SPLIT_CONTEXTS][CDF_SIZE(2)]");
+  cts_each_dim[0] = PARTITION_STRUCTURE_NUM;
+  cts_each_dim[1] = PARTITION_CONTEXTS;
+  cts_each_dim[2] = 2;
+#endif  // CONFIG_BLOCK_256
   optimize_cdf_table(
       &fc.rect_type[0][0][0], probsfile, 3, cts_each_dim,
       "static aom_cdf_prob default_rect_type_cdf"