Implement 64x32 and 32x64 transforms

Change-Id: Ifa983d83a509cdfad78f6400df7d60c8f5b4f68c
diff --git a/av1/common/av1_fwd_txfm2d.c b/av1/common/av1_fwd_txfm2d.c
index 90c571e..650b5bd 100644
--- a/av1/common/av1_fwd_txfm2d.c
+++ b/av1/common/av1_fwd_txfm2d.c
@@ -257,6 +257,7 @@
   fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
 }
 
+#if CONFIG_TX64X64
 void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride,
                             int tx_type, int bd) {
   int32_t txfm_buf[64 * 64];
@@ -264,6 +265,21 @@
   fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
 }
 
+void av1_fwd_txfm2d_32x64_c(const int16_t *input, int32_t *output, int stride,
+                            int tx_type, int bd) {
+  int32_t txfm_buf[32 * 64];
+  TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_32x64_cfg(tx_type);
+  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
+}
+
+void av1_fwd_txfm2d_64x32_c(const int16_t *input, int32_t *output, int stride,
+                            int tx_type, int bd) {
+  int32_t txfm_buf[64 * 32];
+  TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_64x32_cfg(tx_type);
+  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
+}
+#endif  // CONFIG_TX64X64
+
 static const TXFM_1D_CFG *fwd_txfm_col_cfg_ls[TX_TYPES_1D][TX_SIZES] = {
   // DCT
   {
@@ -342,6 +358,39 @@
   return cfg;
 }
 
+#if CONFIG_TX64X64
+TXFM_2D_FLIP_CFG av1_get_fwd_txfm_32x64_cfg(int tx_type) {
+  TXFM_2D_FLIP_CFG cfg;
+  const int tx_type_row = htx_tab[tx_type];
+  const int tx_size_row = txsize_horz_map[TX_32X64];
+  switch (tx_type) {
+    case DCT_DCT:
+      cfg.col_cfg = &fwd_txfm_1d_col_cfg_dct_64;
+      cfg.row_cfg = fwd_txfm_row_cfg_ls[tx_type_row][tx_size_row];
+      cfg.ud_flip = 0;
+      cfg.lr_flip = 0;
+      break;
+    default: assert(0);
+  }
+  return cfg;
+}
+
+TXFM_2D_FLIP_CFG av1_get_fwd_txfm_64x32_cfg(int tx_type) {
+  TXFM_2D_FLIP_CFG cfg;
+  const int tx_type_col = vtx_tab[tx_type];
+  const int tx_size_col = txsize_vert_map[TX_64X32];
+  switch (tx_type) {
+    case DCT_DCT:
+      cfg.col_cfg = fwd_txfm_col_cfg_ls[tx_type_col][tx_size_col];
+      cfg.row_cfg = &fwd_txfm_1d_row_cfg_dct_64;
+      cfg.ud_flip = 0;
+      cfg.lr_flip = 0;
+      break;
+    default: assert(0);
+  }
+  return cfg;
+}
+
 TXFM_2D_FLIP_CFG av1_get_fwd_txfm_64x64_cfg(int tx_type) {
   TXFM_2D_FLIP_CFG cfg;
   switch (tx_type) {
@@ -358,3 +407,4 @@
   }
   return cfg;
 }
+#endif  // CONFIG_TX64X64
diff --git a/av1/common/av1_inv_txfm2d.c b/av1/common/av1_inv_txfm2d.c
index ba5ae4d..86d16b3 100644
--- a/av1/common/av1_inv_txfm2d.c
+++ b/av1/common/av1_inv_txfm2d.c
@@ -349,12 +349,24 @@
   inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_32X32, bd);
 }
 
+#if CONFIG_TX64X64
 void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output,
                                 int stride, int tx_type, int bd) {
   int txfm_buf[64 * 64 + 64 + 64];
   TXFM_2D_FLIP_CFG cfg = av1_get_inv_txfm_64x64_cfg(tx_type);
   inv_txfm2d_add_c(input, output, stride, &cfg, txfm_buf, -4, bd);
-#if CONFIG_TX64X64
   assert(fwd_shift_sum[TX_64X64] == -4);
-#endif
 }
+
+void av1_inv_txfm2d_add_64x32_c(const int32_t *input, uint16_t *output,
+                                int stride, int tx_type, int bd) {
+  int txfm_buf[64 * 32 + 64 + 64];
+  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_32X64, bd);
+}
+
+void av1_inv_txfm2d_add_32x64_c(const int32_t *input, uint16_t *output,
+                                int stride, int tx_type, int bd) {
+  int txfm_buf[64 * 32 + 64 + 64];
+  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_32X64, bd);
+}
+#endif  // CONFIG_TX64X64
diff --git a/av1/common/av1_loopfilter.c b/av1/common/av1_loopfilter.c
index a41d0ee..077d2b1 100644
--- a/av1/common/av1_loopfilter.c
+++ b/av1/common/av1_loopfilter.c
@@ -2813,6 +2813,10 @@
       16 - 1,  // TX_16X8
       16 - 1,  // TX_16X32
       32 - 1,  // TX_32X16
+#if CONFIG_TX64X64
+      32 - 1,  // TX_32X64
+      64 - 1,  // TX_64X32
+#endif         // CONFIG_TX64X64
       4 - 1,   // TX_4X16
       16 - 1,  // TX_16X4
       8 - 1,   // TX_8X32
@@ -2835,6 +2839,10 @@
       8 - 1,   // TX_16X8
       32 - 1,  // TX_16X32
       16 - 1,  // TX_32X16
+#if CONFIG_TX64X64
+      64 - 1,  // TX_32X64
+      32 - 1,  // TX_64X32
+#endif         // CONFIG_TX64X64
       16 - 1,  // TX_4X16
       4 - 1,   // TX_16X4
       32 - 1,  // TX_8X32
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl
index 70011fe..4578d74 100755
--- a/av1/common/av1_rtcd_defs.pl
+++ b/av1/common/av1_rtcd_defs.pl
@@ -160,6 +160,8 @@
 
 if (aom_config("CONFIG_TX64X64") eq "yes") {
   add_proto qw/void av1_iht64x64_4096_add/, "const tran_low_t *input, uint8_t *output, int pitch, const struct txfm_param *param";
+  add_proto qw/void av1_iht32x64_2048_add/, "const tran_low_t *input, uint8_t *output, int pitch, const struct txfm_param *param";
+  add_proto qw/void av1_iht64x32_2048_add/, "const tran_low_t *input, uint8_t *output, int pitch, const struct txfm_param *param";
 }
 
 if (aom_config("CONFIG_NEW_QUANT") eq "yes") {
@@ -285,7 +287,11 @@
 if (aom_config("CONFIG_DAALA_DCT32") ne "yes") {
   specialize qw/av1_inv_txfm2d_add_32x32 avx2/;
 }
-add_proto qw/void av1_inv_txfm2d_add_64x64/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+if (aom_config("CONFIG_TX64X64") eq "yes") {
+  add_proto qw/void av1_inv_txfm2d_add_64x64/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+  add_proto qw/void av1_inv_txfm2d_add_64x32/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+  add_proto qw/void av1_inv_txfm2d_add_32x64/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+}
 
 #
 # Encoder functions below this point.
@@ -354,6 +360,8 @@
 
   if (aom_config("CONFIG_TX64X64") eq "yes") {
     add_proto qw/void av1_fht64x64/, "const int16_t *input, tran_low_t *output, int stride, struct txfm_param *param";
+    add_proto qw/void av1_fht64x32/, "const int16_t *input, tran_low_t *output, int stride, struct txfm_param *param";
+    add_proto qw/void av1_fht32x64/, "const int16_t *input, tran_low_t *output, int stride, struct txfm_param *param";
   }
 
   add_proto qw/void av1_fht4x8/, "const int16_t *input, tran_low_t *output, int stride, struct txfm_param *param";
@@ -396,7 +404,7 @@
     }
   }
 
-  add_proto qw/void av1_fwd_idtx/, "const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type";
+  add_proto qw/void av1_fwd_idtx/, "const int16_t *src_diff, tran_low_t *coeff, int stride, int bsx, int bsy, int tx_type";
 
   #fwd txfm
   add_proto qw/void av1_fwd_txfm2d_4x8/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
@@ -421,9 +429,14 @@
   if (aom_config("CONFIG_DAALA_DCT32") ne "yes") {
     specialize qw/av1_fwd_txfm2d_32x32 sse4_1/;
   }
-  add_proto qw/void av1_fwd_txfm2d_64x64/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
-  if (aom_config("CONFIG_DAALA_DCT64") ne "yes") {
-    specialize qw/av1_fwd_txfm2d_64x64 sse4_1/;
+
+  if (aom_config("CONFIG_TX64X64") eq "yes") {
+    add_proto qw/void av1_fwd_txfm2d_32x64/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+    add_proto qw/void av1_fwd_txfm2d_64x32/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+    add_proto qw/void av1_fwd_txfm2d_64x64/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+    if (aom_config("CONFIG_DAALA_DCT64") ne "yes") {
+      specialize qw/av1_fwd_txfm2d_64x64 sse4_1/;
+    }
   }
   #
   # Motion search
diff --git a/av1/common/av1_txfm.h b/av1/common/av1_txfm.h
index d1dfef7..a61e25d 100644
--- a/av1/common/av1_txfm.h
+++ b/av1/common/av1_txfm.h
@@ -207,6 +207,8 @@
     case TX_32X32: return TX_32X32;
 #if CONFIG_TX64X64
     case TX_64X64: return TX_64X64;
+    case TX_32X64: return TX_64X32;
+    case TX_64X32: return TX_32X64;
 #endif
     case TX_4X8: return TX_8X4;
     case TX_8X4: return TX_4X8;
@@ -352,7 +354,11 @@
                              int bd);
 
 TXFM_2D_FLIP_CFG av1_get_fwd_txfm_cfg(int tx_type, int tx_size);
+#if CONFIG_TX64X64
 TXFM_2D_FLIP_CFG av1_get_fwd_txfm_64x64_cfg(int tx_type);
+TXFM_2D_FLIP_CFG av1_get_fwd_txfm_64x32_cfg(int tx_type);
+TXFM_2D_FLIP_CFG av1_get_fwd_txfm_32x64_cfg(int tx_type);
+#endif  // CONFIG_TX64X64
 TXFM_2D_FLIP_CFG av1_get_inv_txfm_cfg(int tx_type, int tx_size);
 #ifdef __cplusplus
 }
diff --git a/av1/common/common_data.h b/av1/common/common_data.h
index bee642b..ec28000 100644
--- a/av1/common/common_data.h
+++ b/av1/common/common_data.h
@@ -867,6 +867,10 @@
   TX_8X8,    // TX_16X8
   TX_16X16,  // TX_16X32
   TX_16X16,  // TX_32X16
+#if CONFIG_TX64X64
+  TX_32X32,  // TX_32X64
+  TX_32X32,  // TX_64X32
+#endif       // CONFIG_TX64X64
   TX_4X4,    // TX_4X16
   TX_4X4,    // TX_16X4
   TX_8X8,    // TX_8X32
@@ -890,6 +894,10 @@
   TX_16X16,  // TX_16X8
   TX_16X16,  // TX_16X32
   TX_32X32,  // TX_32X16
+#if CONFIG_TX64X64
+  TX_32X32,  // TX_32X64
+  TX_64X64,  // TX_64X32
+#endif       // CONFIG_TX64X64
   TX_4X4,    // TX_4X16
   TX_16X16,  // TX_16X4
   TX_8X8,    // TX_8X32
@@ -913,6 +921,10 @@
   TX_8X8,    // TX_16X8
   TX_32X32,  // TX_16X32
   TX_16X16,  // TX_32X16
+#if CONFIG_TX64X64
+  TX_64X64,  // TX_32X64
+  TX_32X32,  // TX_64X32
+#endif       // CONFIG_TX64X64
   TX_16X16,  // TX_4X16
   TX_4X4,    // TX_16X4
   TX_32X32,  // TX_8X32
@@ -930,11 +942,15 @@
 #if CONFIG_CHROMA_2X2
   2,
 #endif
-  4,  8, 16, 32,
+  4,  8,  16, 32,
 #if CONFIG_TX64X64
   64,
 #endif  // CONFIG_TX64X64
-  4,  8, 8,  16, 16, 32, 4, 16, 8, 32
+  4,  8,  8,  16, 16, 32,
+#if CONFIG_TX64X64
+  32, 64,
+#endif  // CONFIG_TX64X64
+  4,  16, 8,  32
 };
 
 #if CONFIG_CHROMA_2X2
@@ -948,44 +964,64 @@
 #if CONFIG_CHROMA_2X2
   2,
 #endif
-  4,  8, 16, 32,
+  4,  8,  16, 32,
 #if CONFIG_TX64X64
   64,
 #endif  // CONFIG_TX64X64
-  8,  4, 16, 8,  32, 16, 16, 4, 32, 8
+  8,  4,  16, 8,  32, 16,
+#if CONFIG_TX64X64
+  64, 32,
+#endif  // CONFIG_TX64X64
+  16, 4,  32, 8
 };
 
 // Transform block width in unit
 static const int tx_size_wide_unit[TX_SIZES_ALL] = {
 #if CONFIG_CHROMA_2X2
-  1,  2, 4, 8, 16,
+  1,  2,  4, 8, 16,
 #if CONFIG_TX64X64
   32,
 #endif  // CONFIG_TX64X64
-  2,  4, 4, 8, 8,  16, 2, 8, 4, 16
+  2,  4,  4, 8, 8,  16,
+#if CONFIG_TX64X64
+  16, 32,
+#endif  // CONFIG_TX64X64
+  2,  8,  4, 16
 #else  // CONFIG_CHROMA_2X2
-  1,  2, 4, 8,
+  1,  2,  4, 8,
 #if CONFIG_TX64X64
   16,
 #endif  // CONFIG_TX64X64
-  1,  2, 2, 4, 4, 8, 1, 4, 2, 8
+  1,  2,  2, 4, 4, 8,
+#if CONFIG_TX64X64
+  8,  16,
+#endif  // CONFIG_TX64X64
+  1,  4,  2, 8
 #endif  // CONFIG_CHROMA_2X2
 };
 
 // Transform block height in unit
 static const int tx_size_high_unit[TX_SIZES_ALL] = {
 #if CONFIG_CHROMA_2X2
-  1,  2, 4, 8, 16,
+  1,  2,  4,  8, 16,
 #if CONFIG_TX64X64
   32,
 #endif  // CONFIG_TX64X64
-  4,  2, 8, 4, 16, 8, 8, 2, 16, 4
+  4,  2,  8,  4, 16, 8,
+#if CONFIG_TX64X64
+  32, 16,
+#endif  // CONFIG_TX64X64
+  8,  2,  16, 4
 #else  // CONFIG_CHROMA_2X2
   1,  2, 4, 8,
 #if CONFIG_TX64X64
   16,
 #endif  // CONFIG_TX64X64
-  2,  1, 4, 2, 8, 4, 4, 1, 8, 2
+  2,  1, 4, 2, 8, 4,
+#if CONFIG_TX64X64
+  16, 8,
+#endif  // CONFIG_TX64X64
+  4,  1, 8, 2
 #endif  // CONFIG_CHROMA_2X2
 };
 
@@ -998,7 +1034,11 @@
 #if CONFIG_TX64X64
   6,
 #endif  // CONFIG_TX64X64
-  2, 3, 3, 4, 4, 5, 2, 4, 3, 5
+  2, 3, 3, 4, 4, 5,
+#if CONFIG_TX64X64
+  5, 6,
+#endif  // CONFIG_TX64X64
+  2, 4, 3, 5
 };
 
 // Transform block height in log2
@@ -1010,7 +1050,11 @@
 #if CONFIG_TX64X64
   6,
 #endif  // CONFIG_TX64X64
-  3, 2, 4, 3, 5, 4, 4, 2, 5, 3
+  3, 2, 4, 3, 5, 4,
+#if CONFIG_TX64X64
+  6, 5,
+#endif  // CONFIG_TX64X64
+  4, 2, 5, 3
 };
 
 #define TX_UNIT_WIDE_LOG2 (MI_SIZE_LOG2 - tx_size_wide_log2[0])
@@ -1020,11 +1064,15 @@
 #if CONFIG_CHROMA_2X2
   4,
 #endif
-  16,   64, 256, 1024,
+  16,   64,   256, 1024,
 #if CONFIG_TX64X64
   4096,
 #endif  // CONFIG_TX64X64
-  32,   32, 128, 128,  512, 512, 64, 64, 256, 256
+  32,   32,   128, 128,  512, 512,
+#if CONFIG_TX64X64
+  2048, 2048,
+#endif  // CONFIG_TX64X64
+  64,   64,   256, 256
 };
 
 static const BLOCK_SIZE txsize_to_bsize[TX_SIZES_ALL] = {
@@ -1044,6 +1092,10 @@
   BLOCK_16X8,   // TX_16X8
   BLOCK_16X32,  // TX_16X32
   BLOCK_32X16,  // TX_32X16
+#if CONFIG_TX64X64
+  BLOCK_32X64,  // TX_32X64
+  BLOCK_64X32,  // TX_64X32
+#endif          // CONFIG_TX64X64
   BLOCK_4X16,   // TX_4X16
   BLOCK_16X4,   // TX_16X4
   BLOCK_8X32,   // TX_8X32
@@ -1067,6 +1119,10 @@
   TX_8X8,    // TX_16X8
   TX_16X16,  // TX_16X32
   TX_16X16,  // TX_32X16
+#if CONFIG_TX64X64
+  TX_32X32,  // TX_32X64
+  TX_32X32,  // TX_64X32
+#endif       // CONFIG_TX64X64
   TX_4X4,    // TX_4X16
   TX_4X4,    // TX_16X4
   TX_8X8,    // TX_8X32
@@ -1090,6 +1146,10 @@
   TX_16X16,  // TX_16X8
   TX_32X32,  // TX_16X32
   TX_32X32,  // TX_32X16
+#if CONFIG_TX64X64
+  TX_64X64,  // TX_32X64
+  TX_64X64,  // TX_64X32
+#endif       // CONFIG_TX64X64
   TX_16X16,  // TX_4X16
   TX_16X16,  // TX_16X4
   TX_32X32,  // TX_8X32
@@ -1174,6 +1234,10 @@
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
+#if CONFIG_TX64X64
+      { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
+      { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
+#endif  // CONFIG_TX64X64
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
@@ -1198,13 +1262,17 @@
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
+#if CONFIG_TX64X64
+      { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
+      { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
+#endif  // CONFIG_TX64X64
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
   },
   {
-      // BLOCK_2X4
+      // BLOCK_4X2
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
@@ -1216,6 +1284,10 @@
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
+#if CONFIG_TX64X64
+      { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
+      { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
+#endif  // CONFIG_TX64X64
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
@@ -1226,7 +1298,7 @@
   },
 #elif CONFIG_CHROMA_SUB8X8
   {
-      // BLOCK_2X2
+      // BLOCK_2x2
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
@@ -1237,6 +1309,10 @@
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#if CONFIG_TX64X64
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
@@ -1260,13 +1336,17 @@
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#if CONFIG_TX64X64
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
   },
   {
-      // BLOCK_2X4
+      // BLOCK_4X2
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
@@ -1277,6 +1357,10 @@
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#if CONFIG_TX64X64
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
@@ -1303,6 +1387,10 @@
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#if CONFIG_TX64X64
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
@@ -1335,6 +1423,10 @@
       { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#if CONFIG_TX64X64
+      { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
+      { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
@@ -1364,6 +1456,10 @@
       { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#if CONFIG_TX64X64
+      { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+      { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_8X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
@@ -1387,6 +1483,10 @@
       { { TX_8X8, TX_8X4 }, { TX_4X8, TX_4X4 } },
       { { TX_8X8, TX_8X4 }, { TX_4X8, TX_4X4 } },
       { { TX_8X8, TX_8X4 }, { TX_4X8, TX_4X4 } },
+#if CONFIG_TX64X64
+      { { TX_8X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
+      { { TX_8X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X8, TX_4X4 }, { TX_4X8, TX_4X4 } },
       { { TX_8X4, TX_8X4 }, { TX_4X4, TX_4X4 } },
       { { TX_8X8, TX_8X4 }, { TX_4X8, TX_4X4 } },
@@ -1402,7 +1502,7 @@
       { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
       { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
 #if CONFIG_TX64X64
-      { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
+      { { TX_8X16, TX_8X8 }, { TX_4X4, TX_4X4 } },
 #endif  // CONFIG_TX64X64
       { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
       { { TX_8X4, TX_8X4 }, { TX_4X4, TX_4X4 } },
@@ -1410,6 +1510,10 @@
       { { TX_8X16, TX_8X8 }, { TX_4X8, TX_4X8 } },
       { { TX_8X16, TX_8X8 }, { TX_4X8, TX_4X8 } },
       { { TX_8X16, TX_8X8 }, { TX_4X8, TX_4X8 } },
+#if CONFIG_TX64X64
+      { { TX_8X16, TX_8X8 }, { TX_4X4, TX_4X4 } },
+      { { TX_8X16, TX_8X8 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X8 }, { TX_4X16, TX_4X8 } },
       { { TX_8X4, TX_8X4 }, { TX_4X4, TX_4X4 } },
       { { TX_8X16, TX_8X8 }, { TX_4X16, TX_4X8 } },
@@ -1425,7 +1529,7 @@
       { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
       { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
 #if CONFIG_TX64X64
-      { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
+      { { TX_16X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
 #endif  // CONFIG_TX64X64
       { { TX_4X8, TX_4X4 }, { TX_4X8, TX_4X4 } },
       { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
@@ -1433,6 +1537,10 @@
       { { TX_16X8, TX_8X4 }, { TX_8X8, TX_8X4 } },  // used
       { { TX_16X8, TX_8X4 }, { TX_8X8, TX_8X4 } },
       { { TX_16X8, TX_8X4 }, { TX_8X8, TX_8X4 } },
+#if CONFIG_TX64X64
+      { { TX_16X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
+      { { TX_16X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X8, TX_4X4 }, { TX_4X8, TX_4X4 } },
       { { TX_16X4, TX_16X4 }, { TX_8X4, TX_8X4 } },
       { { TX_8X8, TX_8X4 }, { TX_8X8, TX_8X4 } },
@@ -1456,6 +1564,10 @@
       { { TX_16X8, TX_16X8 }, { TX_8X8, TX_8X8 } },
       { { TX_16X16, TX_16X8 }, { TX_8X16, TX_8X8 } },
       { { TX_16X16, TX_16X8 }, { TX_8X16, TX_8X8 } },
+#if CONFIG_TX64X64
+      { { TX_16X16, TX_8X8 }, { TX_8X8, TX_8X8 } },
+      { { TX_16X16, TX_8X8 }, { TX_8X8, TX_8X8 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X8 }, { TX_4X16, TX_4X8 } },
       { { TX_16X4, TX_16X4 }, { TX_8X4, TX_8X4 } },
       { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
@@ -1471,7 +1583,7 @@
       { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
       { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
 #if CONFIG_TX64X64
-      { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
+      { { TX_16X32, TX_16X16 }, { TX_8X8, TX_8X8 } },
 #endif  // CONFIG_TX64X64
       { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
       { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
@@ -1479,6 +1591,10 @@
       { { TX_16X8, TX_16X8 }, { TX_8X8, TX_8X8 } },
       { { TX_16X32, TX_16X16 }, { TX_8X16, TX_8X16 } },  // used
       { { TX_16X32, TX_16X16 }, { TX_8X16, TX_8X16 } },
+#if CONFIG_TX64X64
+      { { TX_16X32, TX_16X16 }, { TX_8X8, TX_8X8 } },
+      { { TX_16X32, TX_16X16 }, { TX_8X8, TX_8X8 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X16 }, { TX_4X16, TX_4X16 } },
       { { TX_16X4, TX_16X4 }, { TX_8X4, TX_8X4 } },
       { { TX_8X32, TX_8X16 }, { TX_8X32, TX_8X16 } },
@@ -1494,7 +1610,7 @@
       { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
       { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
 #if CONFIG_TX64X64
-      { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
+      { { TX_32X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
 #endif  // CONFIG_TX64X64
       { { TX_4X8, TX_4X8 }, { TX_4X8, TX_4X8 } },
       { { TX_8X4, TX_8X4 }, { TX_8X4, TX_8X4 } },
@@ -1502,6 +1618,10 @@
       { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
       { { TX_32X16, TX_16X8 }, { TX_16X16, TX_16X8 } },
       { { TX_32X16, TX_16X8 }, { TX_16X16, TX_16X8 } },  // used
+#if CONFIG_TX64X64
+      { { TX_32X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
+      { { TX_32X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X8 }, { TX_4X16, TX_4X8 } },
       { { TX_16X4, TX_16X4 }, { TX_16X4, TX_16X4 } },
       { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
@@ -1525,6 +1645,10 @@
       { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
       { { TX_16X32, TX_16X16 }, { TX_16X32, TX_16X16 } },
       { { TX_32X16, TX_32X16 }, { TX_16X16, TX_16X16 } },
+#if CONFIG_TX64X64
+      { { TX_32X32, TX_16X16 }, { TX_16X16, TX_16X16 } },
+      { { TX_32X32, TX_16X16 }, { TX_16X16, TX_16X16 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X8 }, { TX_4X16, TX_4X8 } },
       { { TX_16X4, TX_16X4 }, { TX_16X4, TX_16X4 } },
       { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
@@ -1548,6 +1672,10 @@
       { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
       { { TX_16X32, TX_16X32 }, { TX_16X16, TX_16X16 } },
       { { TX_32X16, TX_32X16 }, { TX_16X16, TX_16X16 } },
+#if CONFIG_TX64X64
+      { { TX_32X64, TX_32X32 }, { TX_16X16, TX_16X16 } },
+      { { TX_32X32, TX_32X32 }, { TX_16X16, TX_16X16 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X8 }, { TX_4X16, TX_4X8 } },
       { { TX_16X4, TX_16X4 }, { TX_16X4, TX_16X4 } },
       { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
@@ -1571,6 +1699,10 @@
       { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
       { { TX_16X32, TX_16X16 }, { TX_16X32, TX_16X16 } },
       { { TX_32X16, TX_16X16 }, { TX_32X16, TX_16X16 } },
+#if CONFIG_TX64X64
+      { { TX_32X32, TX_16X16 }, { TX_32X32, TX_16X16 } },
+      { { TX_64X32, TX_16X16 }, { TX_32X32, TX_16X16 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X8 }, { TX_4X16, TX_4X8 } },
       { { TX_16X4, TX_16X4 }, { TX_16X4, TX_16X4 } },
       { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
@@ -1594,6 +1726,10 @@
       { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
       { { TX_16X32, TX_16X32 }, { TX_16X32, TX_16X32 } },
       { { TX_32X16, TX_32X16 }, { TX_32X16, TX_16X16 } },
+#if CONFIG_TX64X64
+      { { TX_32X64, TX_32X32 }, { TX_16X16, TX_16X16 } },
+      { { TX_64X32, TX_16X16 }, { TX_32X32, TX_16X16 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X8 }, { TX_4X16, TX_4X8 } },
       { { TX_16X4, TX_16X4 }, { TX_16X4, TX_16X4 } },
       { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
@@ -1618,6 +1754,10 @@
       { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
       { { TX_16X32, TX_16X32 }, { TX_16X32, TX_16X32 } },
       { { TX_32X16, TX_32X16 }, { TX_32X16, TX_32X16 } },
+#if CONFIG_TX64X64
+      { { TX_32X64, TX_32X32 }, { TX_16X16, TX_16X16 } },
+      { { TX_64X32, TX_16X16 }, { TX_32X32, TX_16X16 } },
+#endif  // CONFIG_TX64X64
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
@@ -1641,6 +1781,10 @@
       { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
       { { TX_16X32, TX_16X32 }, { TX_16X32, TX_16X32 } },
       { { TX_32X16, TX_32X16 }, { TX_32X16, TX_32X16 } },
+#if CONFIG_TX64X64
+      { { TX_32X64, TX_32X32 }, { TX_16X16, TX_16X16 } },
+      { { TX_64X32, TX_16X16 }, { TX_32X32, TX_16X16 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X8 }, { TX_4X16, TX_4X8 } },
       { { TX_16X4, TX_16X4 }, { TX_16X4, TX_16X4 } },
       { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
@@ -1664,6 +1808,10 @@
       { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
       { { TX_16X32, TX_16X32 }, { TX_16X32, TX_16X32 } },
       { { TX_32X16, TX_32X16 }, { TX_32X16, TX_32X16 } },
+#if CONFIG_TX64X64
+      { { TX_32X64, TX_32X32 }, { TX_16X16, TX_16X16 } },
+      { { TX_64X32, TX_16X16 }, { TX_32X32, TX_16X16 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X8 }, { TX_4X16, TX_4X8 } },
       { { TX_16X4, TX_16X4 }, { TX_16X4, TX_16X4 } },
       { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
@@ -1690,6 +1838,10 @@
       { { TX_4X8, TX_4X8 }, { TX_4X4, TX_4X4 } },
       { { TX_4X8, TX_4X8 }, { TX_4X4, TX_4X4 } },
       { { TX_4X8, TX_4X8 }, { TX_4X4, TX_4X4 } },
+#if CONFIG_TX64X64
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X8 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X16, TX_4X8 }, { TX_4X4, TX_4X4 } },
@@ -1715,6 +1867,10 @@
       { { TX_8X4, TX_4X4 }, { TX_8X4, TX_4X4 } },
       { { TX_8X4, TX_4X4 }, { TX_8X4, TX_4X4 } },
       { { TX_8X4, TX_4X4 }, { TX_8X4, TX_4X4 } },
+#if CONFIG_TX64X64
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+      { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_16X4, TX_4X4 }, { TX_8X4, TX_4X4 } },
       { { TX_8X4, TX_4X4 }, { TX_8X4, TX_4X4 } },
@@ -1738,6 +1894,10 @@
       { { TX_8X8, TX_8X8 }, { TX_4X8, TX_4X8 } },
       { { TX_8X16, TX_8X16 }, { TX_4X8, TX_4X8 } },
       { { TX_8X16, TX_8X16 }, { TX_4X8, TX_4X8 } },
+#if CONFIG_TX64X64
+      { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
+      { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X16, TX_4X16 }, { TX_4X16, TX_4X16 } },
       { { TX_8X4, TX_8X4 }, { TX_4X4, TX_4X4 } },
       { { TX_8X32, TX_8X16 }, { TX_4X16, TX_4X16 } },
@@ -1761,6 +1921,10 @@
       { { TX_16X8, TX_8X4 }, { TX_16X8, TX_8X4 } },
       { { TX_16X8, TX_8X4 }, { TX_16X8, TX_8X4 } },
       { { TX_16X8, TX_8X4 }, { TX_16X8, TX_8X4 } },
+#if CONFIG_TX64X64
+      { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
+      { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
+#endif  // CONFIG_TX64X64
       { { TX_4X8, TX_4X4 }, { TX_4X8, TX_4X4 } },
       { { TX_16X4, TX_16X4 }, { TX_16X4, TX_16X4 } },
       { { TX_8X8, TX_8X4 }, { TX_8X8, TX_8X4 } },
@@ -1784,6 +1948,10 @@
       { { TX_16X8, TX_16X8 }, { TX_8X8, TX_8X8 } },
       { { TX_16X32, TX_16X32 }, { TX_8X16, TX_8X16 } },
       { { TX_16X16, TX_16X16 }, { TX_8X16, TX_8X16 } },
+#if CONFIG_TX64X64
+      { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
+      { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
+#endif
       { { TX_4X16, TX_4X16 }, { TX_4X16, TX_4X16 } },
       { { TX_16X4, TX_16X4 }, { TX_8X4, TX_8X4 } },
       { { TX_8X32, TX_8X32 }, { TX_8X32, TX_8X32 } },
@@ -1807,6 +1975,10 @@
       { { TX_16X8, TX_16X8 }, { TX_16X8, TX_16X8 } },
       { { TX_16X16, TX_16X8 }, { TX_16X16, TX_16X8 } },
       { { TX_32X16, TX_16X8 }, { TX_32X16, TX_16X8 } },
+#if CONFIG_TX64X64
+      { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
+      { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
+#endif
       { { TX_4X16, TX_4X8 }, { TX_4X16, TX_4X8 } },
       { { TX_16X4, TX_16X4 }, { TX_16X4, TX_16X4 } },
       { { TX_8X16, TX_8X8 }, { TX_8X16, TX_8X8 } },
diff --git a/av1/common/entropy.c b/av1/common/entropy.c
index 9219c3b..5d2eabd 100644
--- a/av1/common/entropy.c
+++ b/av1/common/entropy.c
@@ -149,6 +149,9 @@
   { 1, 2, 3, 4, 8, 32 - 18, 0 },    { 1, 2, 3, 4, 8, 32 - 18, 0 },
   { 1, 2, 3, 4, 11, 128 - 21, 0 },  { 1, 2, 3, 4, 11, 128 - 21, 0 },
   { 1, 2, 3, 4, 11, 512 - 21, 0 },  { 1, 2, 3, 4, 11, 512 - 21, 0 },
+#if CONFIG_TX64X64
+  { 1, 2, 3, 4, 11, 2048 - 21, 0 }, { 1, 2, 3, 4, 11, 2048 - 21, 0 },
+#endif  // CONFIG_TX64X64
   { 1, 2, 3, 4, 11, 64 - 21, 0 },   { 1, 2, 3, 4, 11, 64 - 21, 0 },
   { 1, 2, 3, 4, 11, 256 - 21, 0 },  { 1, 2, 3, 4, 11, 256 - 21, 0 },
 };
@@ -165,6 +168,9 @@
   { 0, 1, 3, 6, 10, 18, 32, 0 },   { 0, 1, 3, 6, 10, 18, 32, 0 },
   { 0, 1, 3, 6, 10, 21, 128, 0 },  { 0, 1, 3, 6, 10, 21, 128, 0 },
   { 0, 1, 3, 6, 10, 21, 512, 0 },  { 0, 1, 3, 6, 10, 21, 512, 0 },
+#if CONFIG_TX64X64
+  { 0, 1, 3, 6, 10, 21, 2048, 0 }, { 0, 1, 3, 6, 10, 21, 2048, 0 },
+#endif  // CONFIG_TX64X64
   { 0, 1, 3, 6, 10, 21, 64, 0 },   { 0, 1, 3, 6, 10, 21, 64, 0 },
   { 0, 1, 3, 6, 10, 21, 256, 0 },  { 0, 1, 3, 6, 10, 21, 256, 0 },
 };
diff --git a/av1/common/entropy.h b/av1/common/entropy.h
index 8c1fa1d..679aae8 100644
--- a/av1/common/entropy.h
+++ b/av1/common/entropy.h
@@ -326,6 +326,16 @@
       left_ec = !!(*(const uint64_t *)l | *(const uint64_t *)(l + 8) |
                    *(const uint64_t *)(l + 16) | *(const uint64_t *)(l + 24));
       break;
+    case TX_32X64:
+      above_ec = !!(*(const uint64_t *)a | *(const uint64_t *)(a + 8));
+      left_ec = !!(*(const uint64_t *)l | *(const uint64_t *)(l + 8) |
+                   *(const uint64_t *)(l + 16) | *(const uint64_t *)(l + 24));
+      break;
+    case TX_64X32:
+      above_ec = !!(*(const uint64_t *)a | *(const uint64_t *)(a + 8) |
+                    *(const uint64_t *)(a + 16) | *(const uint64_t *)(a + 24));
+      left_ec = !!(*(const uint64_t *)l | *(const uint64_t *)(l + 8));
+      break;
 #endif  // CONFIG_TX64X64
 #if CONFIG_RECT_TX_EXT && (CONFIG_EXT_TX || CONFIG_VAR_TX)
     case TX_4X16:
@@ -396,6 +406,14 @@
       above_ec = !!(*(const uint64_t *)a | *(const uint64_t *)(a + 8));
       left_ec = !!(*(const uint64_t *)l | *(const uint64_t *)(l + 8));
       break;
+    case TX_32X64:
+      above_ec = !!*(const uint64_t *)a;
+      left_ec = !!(*(const uint64_t *)l | *(const uint64_t *)(l + 8));
+      break;
+    case TX_64X32:
+      above_ec = !!(*(const uint64_t *)a | *(const uint64_t *)(a + 8));
+      left_ec = !!*(const uint64_t *)l;
+      break;
 #endif  // CONFIG_TX64X64
 #if CONFIG_RECT_TX_EXT && (CONFIG_EXT_TX || CONFIG_VAR_TX)
     case TX_4X16:
diff --git a/av1/common/enums.h b/av1/common/enums.h
index 40b7061..5385a43 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -190,14 +190,18 @@
   TX_16X16,  // 16x16 transform
   TX_32X32,  // 32x32 transform
 #if CONFIG_TX64X64
-  TX_64X64,           // 64x64 transform
+  TX_64X64,  // 64x64 transform
+#endif       // CONFIG_TX64X64
+  TX_4X8,    // 4x8 transform
+  TX_8X4,    // 8x4 transform
+  TX_8X16,   // 8x16 transform
+  TX_16X8,   // 16x8 transform
+  TX_16X32,  // 16x32 transform
+  TX_32X16,  // 32x16 transform
+#if CONFIG_TX64X64
+  TX_32X64,           // 32x64 transform
+  TX_64X32,           // 64x32 transform
 #endif                // CONFIG_TX64X64
-  TX_4X8,             // 4x8 transform
-  TX_8X4,             // 8x4 transform
-  TX_8X16,            // 8x16 transform
-  TX_16X8,            // 16x8 transform
-  TX_16X32,           // 16x32 transform
-  TX_32X16,           // 32x16 transform
   TX_4X16,            // 4x16 transform
   TX_16X4,            // 16x4 transform
   TX_8X32,            // 8x32 transform
diff --git a/av1/common/idct.c b/av1/common/idct.c
index 151ce4a..ca1c361 100644
--- a/av1/common/idct.c
+++ b/av1/common/idct.c
@@ -122,15 +122,16 @@
 // Inverse identity transform and add.
 #if CONFIG_EXT_TX
 static void inv_idtx_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                           int bs, int tx_type) {
+                           int bsx, int bsy, int tx_type) {
   int r, c;
-  const int shift = bs < 32 ? 3 : (bs < 64 ? 2 : 1);
+  const int pels = bsx * bsy;
+  const int shift = 3 - ((pels > 256) + (pels > 1024));
   if (tx_type == IDTX) {
-    for (r = 0; r < bs; ++r) {
-      for (c = 0; c < bs; ++c)
+    for (r = 0; r < bsy; ++r) {
+      for (c = 0; c < bsx; ++c)
         dest[c] = clip_pixel_add(dest[c], input[c] >> shift);
       dest += stride;
-      input += bs;
+      input += bsx;
     }
   }
 }
@@ -185,17 +186,19 @@
 #if CONFIG_HIGHBITDEPTH
 #if CONFIG_EXT_TX && CONFIG_TX64X64
 static void highbd_inv_idtx_add_c(const tran_low_t *input, uint8_t *dest8,
-                                  int stride, int bs, int tx_type, int bd) {
+                                  int stride, int bsx, int bsy, int tx_type,
+                                  int bd) {
   int r, c;
-  const int shift = bs < 32 ? 3 : 2;
+  const int pels = bsx * bsy;
+  const int shift = 3 - ((pels > 256) + (pels > 1024));
   uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
 
   if (tx_type == IDTX) {
-    for (r = 0; r < bs; ++r) {
-      for (c = 0; c < bs; ++c)
+    for (r = 0; r < bsy; ++r) {
+      for (c = 0; c < bsx; ++c)
         dest[c] = highbd_clip_pixel_add(dest[c], input[c] >> shift, bd);
       dest += stride;
-      input += bs;
+      input += bsx;
     }
   }
 }
@@ -1521,6 +1524,131 @@
     }
   }
 }
+
+void av1_iht64x32_2048_add_c(const tran_low_t *input, uint8_t *dest, int stride,
+                             const TxfmParam *txfm_param) {
+  int tx_type = txfm_param->tx_type;
+#if CONFIG_MRC_TX
+  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
+#endif  // CONFIG_MRC_TX
+#if CONFIG_DCT_ONLY
+  assert(tx_type == DCT_DCT);
+#endif
+  static const transform_2d IHT_64x32[] = {
+    { aom_idct32_c, idct64_row_c },      // DCT_DCT
+    { ihalfright32_c, idct64_row_c },    // ADST_DCT
+    { aom_idct32_c, ihalfright64_c },    // DCT_ADST
+    { ihalfright32_c, ihalfright64_c },  // ADST_ADST
+#if CONFIG_EXT_TX
+    { ihalfright32_c, idct64_row_c },    // FLIPADST_DCT
+    { aom_idct32_c, ihalfright64_c },    // DCT_FLIPADST
+    { ihalfright32_c, ihalfright64_c },  // FLIPADST_FLIPADST
+    { ihalfright32_c, ihalfright64_c },  // ADST_FLIPADST
+    { ihalfright32_c, ihalfright64_c },  // FLIPADST_ADST
+    { iidtx32_c, iidtx64_c },            // IDTX
+    { aom_idct32_c, iidtx64_c },         // V_DCT
+    { iidtx32_c, idct64_row_c },         // H_DCT
+    { ihalfright32_c, iidtx64_c },       // V_ADST
+    { iidtx32_c, ihalfright64_c },       // H_ADST
+    { ihalfright32_c, iidtx64_c },       // V_FLIPADST
+    { iidtx32_c, ihalfright64_c },       // H_FLIPADST
+#endif
+  };
+  const int n = 32;
+  const int n2 = 64;
+
+  int i, j;
+  tran_low_t out[64][32], tmp[64][32], outtmp[64];
+  tran_low_t *outp = &out[0][0];
+  int outstride = n;
+
+  // inverse transform row vectors and transpose
+  for (i = 0; i < n; ++i) {
+    IHT_64x32[tx_type].rows(input, outtmp);
+    for (j = 0; j < n2; ++j)
+      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
+    input += n2;
+  }
+
+  // inverse transform column vectors
+  for (i = 0; i < n2; ++i) IHT_64x32[tx_type].cols(tmp[i], out[i]);
+
+#if CONFIG_EXT_TX
+  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
+#endif
+
+  // Sum with the destination
+  for (i = 0; i < n; ++i) {
+    for (j = 0; j < n2; ++j) {
+      int d = i * stride + j;
+      int s = j * outstride + i;
+      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
+    }
+  }
+}
+
+void av1_iht32x64_2048_add_c(const tran_low_t *input, uint8_t *dest, int stride,
+                             const TxfmParam *txfm_param) {
+  int tx_type = txfm_param->tx_type;
+#if CONFIG_MRC_TX
+  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
+#endif  // CONFIG_MRC_TX
+#if CONFIG_DCT_ONLY
+  assert(tx_type == DCT_DCT);
+#endif
+  static const transform_2d IHT_32x64[] = {
+    { idct64_col_c, aom_idct32_c },      // DCT_DCT
+    { ihalfright64_c, aom_idct32_c },    // ADST_DCT
+    { idct64_col_c, ihalfright32_c },    // DCT_ADST
+    { ihalfright64_c, ihalfright32_c },  // ADST_ADST
+#if CONFIG_EXT_TX
+    { ihalfright64_c, aom_idct32_c },    // FLIPADST_DCT
+    { idct64_col_c, ihalfright32_c },    // DCT_FLIPADST
+    { ihalfright64_c, ihalfright32_c },  // FLIPADST_FLIPADST
+    { ihalfright64_c, ihalfright32_c },  // ADST_FLIPADST
+    { ihalfright64_c, ihalfright32_c },  // FLIPADST_ADST
+    { iidtx64_c, iidtx32_c },            // IDTX
+    { idct64_col_c, iidtx32_c },         // V_DCT
+    { iidtx64_c, aom_idct32_c },         // H_DCT
+    { ihalfright64_c, iidtx32_c },       // V_ADST
+    { iidtx64_c, ihalfright32_c },       // H_ADST
+    { ihalfright64_c, iidtx32_c },       // V_FLIPADST
+    { iidtx64_c, ihalfright32_c },       // H_FLIPADST
+#endif
+  };
+
+  const int n = 32;
+  const int n2 = 64;
+  int i, j;
+  tran_low_t out[32][64], tmp[32][64], outtmp[32];
+  tran_low_t *outp = &out[0][0];
+  int outstride = n2;
+
+  // inverse transform row vectors and transpose
+  for (i = 0; i < n2; ++i) {
+    IHT_32x64[tx_type].rows(input, outtmp);
+    for (j = 0; j < n; ++j)
+      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
+    input += n;
+  }
+
+  // inverse transform column vectors
+  for (i = 0; i < n; ++i) IHT_32x64[tx_type].cols(tmp[i], out[i]);
+
+#if CONFIG_EXT_TX
+  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
+#endif
+
+  // Sum with the destination
+  for (i = 0; i < n2; ++i) {
+    for (j = 0; j < n; ++j) {
+      int d = i * stride + j;
+      int s = j * outstride + i;
+      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
+    }
+  }
+}
+
 #endif  // CONFIG_TX64X64
 
 // idct
@@ -1743,7 +1871,7 @@
       // Use C version since DST only exists in C code
       av1_iht4x4_16_add_c(input, dest, stride, txfm_param);
       break;
-    case IDTX: inv_idtx_add_c(input, dest, stride, 4, tx_type); break;
+    case IDTX: inv_idtx_add_c(input, dest, stride, 4, 4, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
@@ -1834,6 +1962,18 @@
   av1_iht32x16_512_add(input, dest, stride, txfm_param);
 }
 
+#if CONFIG_TX64X64
+static void inv_txfm_add_32x64(const tran_low_t *input, uint8_t *dest,
+                               int stride, const TxfmParam *txfm_param) {
+  av1_iht32x64_2048_add(input, dest, stride, txfm_param);
+}
+
+static void inv_txfm_add_64x32(const tran_low_t *input, uint8_t *dest,
+                               int stride, const TxfmParam *txfm_param) {
+  av1_iht64x32_2048_add(input, dest, stride, txfm_param);
+}
+#endif  // CONFIG_TX64X64
+
 static void inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest, int stride,
                              const TxfmParam *txfm_param) {
   const TX_TYPE tx_type = txfm_param->tx_type;
@@ -1875,7 +2015,7 @@
       // Use C version since DST only exists in C code
       av1_iht8x8_64_add_c(input, dest, stride, txfm_param);
       break;
-    case IDTX: inv_idtx_add_c(input, dest, stride, 8, tx_type); break;
+    case IDTX: inv_idtx_add_c(input, dest, stride, 8, 8, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
@@ -1917,7 +2057,7 @@
       av1_iht16x16_256_add(input, dest, stride, txfm_param);
 #endif  // CONFIG_DAALA_DCT16
       break;
-    case IDTX: inv_idtx_add_c(input, dest, stride, 16, tx_type); break;
+    case IDTX: inv_idtx_add_c(input, dest, stride, 16, 16, tx_type); break;
 #endif  // CONFIG_EXT_TX
 #if CONFIG_MRC_TX
     case MRC_DCT: assert(0 && "Invalid tx type for tx size");
@@ -1954,7 +2094,7 @@
     case H_FLIPADST:
       av1_iht32x32_1024_add_c(input, dest, stride, txfm_param);
       break;
-    case IDTX: inv_idtx_add_c(input, dest, stride, 32, tx_type); break;
+    case IDTX: inv_idtx_add_c(input, dest, stride, 32, 32, tx_type); break;
 #endif  // CONFIG_EXT_TX
 #if CONFIG_MRC_TX
     case MRC_DCT: imrc32x32_add_c(input, dest, stride, txfm_param); break;
@@ -1990,7 +2130,7 @@
     case H_FLIPADST:
       av1_iht64x64_4096_add_c(input, dest, stride, txfm_param);
       break;
-    case IDTX: inv_idtx_add_c(input, dest, stride, 64, tx_type); break;
+    case IDTX: inv_idtx_add_c(input, dest, stride, 64, 64, tx_type); break;
 #endif  // CONFIG_EXT_TX
 #if CONFIG_MRC_TX
     case MRC_DCT: assert(0 && "Invalid tx type for tx size");
@@ -2130,6 +2270,22 @@
                              txfm_param->tx_type, txfm_param->bd);
 }
 
+#if CONFIG_TX64X64
+static void highbd_inv_txfm_add_32x64(const tran_low_t *input, uint8_t *dest,
+                                      int stride, const TxfmParam *txfm_param) {
+  const int32_t *src = (const int32_t *)input;
+  av1_inv_txfm2d_add_32x64_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                             txfm_param->tx_type, txfm_param->bd);
+}
+
+static void highbd_inv_txfm_add_64x32(const tran_low_t *input, uint8_t *dest,
+                                      int stride, const TxfmParam *txfm_param) {
+  const int32_t *src = (const int32_t *)input;
+  av1_inv_txfm2d_add_64x32_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                             txfm_param->tx_type, txfm_param->bd);
+}
+#endif  // CONFIG_TX64X64
+
 static void highbd_inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest,
                                     int stride, const TxfmParam *txfm_param) {
   int bd = txfm_param->bd;
@@ -2280,7 +2436,7 @@
                                  DCT_DCT, bd);
       break;
     case IDTX:
-      highbd_inv_idtx_add_c(input, dest, stride, 64, tx_type, bd);
+      highbd_inv_idtx_add_c(input, dest, stride, 64, 64, tx_type, bd);
       break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
@@ -2304,6 +2460,10 @@
     case TX_16X8: inv_txfm_add_16x8(input, dest, stride, txfm_param); break;
     case TX_16X32: inv_txfm_add_16x32(input, dest, stride, txfm_param); break;
     case TX_32X16: inv_txfm_add_32x16(input, dest, stride, txfm_param); break;
+#if CONFIG_TX64X64
+    case TX_64X32: inv_txfm_add_64x32(input, dest, stride, txfm_param); break;
+    case TX_32X64: inv_txfm_add_32x64(input, dest, stride, txfm_param); break;
+#endif  // CONFIG_TX64X64
     case TX_4X4:
       // this is like av1_short_idct4x4 but has a special case around eob<=1
       // which is significant (not just an optimization) for the lossless
@@ -2474,6 +2634,14 @@
     case TX_32X16:
       highbd_inv_txfm_add_32x16(input, dest, stride, txfm_param);
       break;
+#if CONFIG_TX64X64
+    case TX_64X32:
+      highbd_inv_txfm_add_64x32(input, dest, stride, txfm_param);
+      break;
+    case TX_32X64:
+      highbd_inv_txfm_add_32x64(input, dest, stride, txfm_param);
+      break;
+#endif  // CONFIG_TX64X64
     case TX_4X4:
       // this is like av1_short_idct4x4 but has a special case around eob<=1
       // which is significant (not just an optimization) for the lossless
diff --git a/av1/common/scan.c b/av1/common/scan.c
index 3a1694a..146e748 100644
--- a/av1/common/scan.c
+++ b/av1/common/scan.c
@@ -1171,6 +1171,328 @@
 };
 
 #if CONFIG_TX64X64
+DECLARE_ALIGNED(16, static const int16_t, default_scan_32x64[2048]) = {
+  0,    1,    32,   2,    33,   64,   3,    34,   65,   96,   4,    35,   66,
+  97,   128,  5,    36,   67,   98,   129,  160,  6,    37,   68,   99,   130,
+  161,  192,  7,    38,   69,   100,  131,  162,  193,  224,  8,    39,   70,
+  101,  132,  163,  194,  225,  256,  9,    40,   71,   102,  133,  164,  195,
+  226,  257,  288,  10,   41,   72,   103,  134,  165,  196,  227,  258,  289,
+  320,  11,   42,   73,   104,  135,  166,  197,  228,  259,  290,  321,  352,
+  12,   43,   74,   105,  136,  167,  198,  229,  260,  291,  322,  353,  384,
+  13,   44,   75,   106,  137,  168,  199,  230,  261,  292,  323,  354,  385,
+  416,  14,   45,   76,   107,  138,  169,  200,  231,  262,  293,  324,  355,
+  386,  417,  448,  15,   46,   77,   108,  139,  170,  201,  232,  263,  294,
+  325,  356,  387,  418,  449,  480,  16,   47,   78,   109,  140,  171,  202,
+  233,  264,  295,  326,  357,  388,  419,  450,  481,  512,  17,   48,   79,
+  110,  141,  172,  203,  234,  265,  296,  327,  358,  389,  420,  451,  482,
+  513,  544,  18,   49,   80,   111,  142,  173,  204,  235,  266,  297,  328,
+  359,  390,  421,  452,  483,  514,  545,  576,  19,   50,   81,   112,  143,
+  174,  205,  236,  267,  298,  329,  360,  391,  422,  453,  484,  515,  546,
+  577,  608,  20,   51,   82,   113,  144,  175,  206,  237,  268,  299,  330,
+  361,  392,  423,  454,  485,  516,  547,  578,  609,  640,  21,   52,   83,
+  114,  145,  176,  207,  238,  269,  300,  331,  362,  393,  424,  455,  486,
+  517,  548,  579,  610,  641,  672,  22,   53,   84,   115,  146,  177,  208,
+  239,  270,  301,  332,  363,  394,  425,  456,  487,  518,  549,  580,  611,
+  642,  673,  704,  23,   54,   85,   116,  147,  178,  209,  240,  271,  302,
+  333,  364,  395,  426,  457,  488,  519,  550,  581,  612,  643,  674,  705,
+  736,  24,   55,   86,   117,  148,  179,  210,  241,  272,  303,  334,  365,
+  396,  427,  458,  489,  520,  551,  582,  613,  644,  675,  706,  737,  768,
+  25,   56,   87,   118,  149,  180,  211,  242,  273,  304,  335,  366,  397,
+  428,  459,  490,  521,  552,  583,  614,  645,  676,  707,  738,  769,  800,
+  26,   57,   88,   119,  150,  181,  212,  243,  274,  305,  336,  367,  398,
+  429,  460,  491,  522,  553,  584,  615,  646,  677,  708,  739,  770,  801,
+  832,  27,   58,   89,   120,  151,  182,  213,  244,  275,  306,  337,  368,
+  399,  430,  461,  492,  523,  554,  585,  616,  647,  678,  709,  740,  771,
+  802,  833,  864,  28,   59,   90,   121,  152,  183,  214,  245,  276,  307,
+  338,  369,  400,  431,  462,  493,  524,  555,  586,  617,  648,  679,  710,
+  741,  772,  803,  834,  865,  896,  29,   60,   91,   122,  153,  184,  215,
+  246,  277,  308,  339,  370,  401,  432,  463,  494,  525,  556,  587,  618,
+  649,  680,  711,  742,  773,  804,  835,  866,  897,  928,  30,   61,   92,
+  123,  154,  185,  216,  247,  278,  309,  340,  371,  402,  433,  464,  495,
+  526,  557,  588,  619,  650,  681,  712,  743,  774,  805,  836,  867,  898,
+  929,  960,  31,   62,   93,   124,  155,  186,  217,  248,  279,  310,  341,
+  372,  403,  434,  465,  496,  527,  558,  589,  620,  651,  682,  713,  744,
+  775,  806,  837,  868,  899,  930,  961,  992,  63,   94,   125,  156,  187,
+  218,  249,  280,  311,  342,  373,  404,  435,  466,  497,  528,  559,  590,
+  621,  652,  683,  714,  745,  776,  807,  838,  869,  900,  931,  962,  993,
+  1024, 95,   126,  157,  188,  219,  250,  281,  312,  343,  374,  405,  436,
+  467,  498,  529,  560,  591,  622,  653,  684,  715,  746,  777,  808,  839,
+  870,  901,  932,  963,  994,  1025, 1056, 127,  158,  189,  220,  251,  282,
+  313,  344,  375,  406,  437,  468,  499,  530,  561,  592,  623,  654,  685,
+  716,  747,  778,  809,  840,  871,  902,  933,  964,  995,  1026, 1057, 1088,
+  159,  190,  221,  252,  283,  314,  345,  376,  407,  438,  469,  500,  531,
+  562,  593,  624,  655,  686,  717,  748,  779,  810,  841,  872,  903,  934,
+  965,  996,  1027, 1058, 1089, 1120, 191,  222,  253,  284,  315,  346,  377,
+  408,  439,  470,  501,  532,  563,  594,  625,  656,  687,  718,  749,  780,
+  811,  842,  873,  904,  935,  966,  997,  1028, 1059, 1090, 1121, 1152, 223,
+  254,  285,  316,  347,  378,  409,  440,  471,  502,  533,  564,  595,  626,
+  657,  688,  719,  750,  781,  812,  843,  874,  905,  936,  967,  998,  1029,
+  1060, 1091, 1122, 1153, 1184, 255,  286,  317,  348,  379,  410,  441,  472,
+  503,  534,  565,  596,  627,  658,  689,  720,  751,  782,  813,  844,  875,
+  906,  937,  968,  999,  1030, 1061, 1092, 1123, 1154, 1185, 1216, 287,  318,
+  349,  380,  411,  442,  473,  504,  535,  566,  597,  628,  659,  690,  721,
+  752,  783,  814,  845,  876,  907,  938,  969,  1000, 1031, 1062, 1093, 1124,
+  1155, 1186, 1217, 1248, 319,  350,  381,  412,  443,  474,  505,  536,  567,
+  598,  629,  660,  691,  722,  753,  784,  815,  846,  877,  908,  939,  970,
+  1001, 1032, 1063, 1094, 1125, 1156, 1187, 1218, 1249, 1280, 351,  382,  413,
+  444,  475,  506,  537,  568,  599,  630,  661,  692,  723,  754,  785,  816,
+  847,  878,  909,  940,  971,  1002, 1033, 1064, 1095, 1126, 1157, 1188, 1219,
+  1250, 1281, 1312, 383,  414,  445,  476,  507,  538,  569,  600,  631,  662,
+  693,  724,  755,  786,  817,  848,  879,  910,  941,  972,  1003, 1034, 1065,
+  1096, 1127, 1158, 1189, 1220, 1251, 1282, 1313, 1344, 415,  446,  477,  508,
+  539,  570,  601,  632,  663,  694,  725,  756,  787,  818,  849,  880,  911,
+  942,  973,  1004, 1035, 1066, 1097, 1128, 1159, 1190, 1221, 1252, 1283, 1314,
+  1345, 1376, 447,  478,  509,  540,  571,  602,  633,  664,  695,  726,  757,
+  788,  819,  850,  881,  912,  943,  974,  1005, 1036, 1067, 1098, 1129, 1160,
+  1191, 1222, 1253, 1284, 1315, 1346, 1377, 1408, 479,  510,  541,  572,  603,
+  634,  665,  696,  727,  758,  789,  820,  851,  882,  913,  944,  975,  1006,
+  1037, 1068, 1099, 1130, 1161, 1192, 1223, 1254, 1285, 1316, 1347, 1378, 1409,
+  1440, 511,  542,  573,  604,  635,  666,  697,  728,  759,  790,  821,  852,
+  883,  914,  945,  976,  1007, 1038, 1069, 1100, 1131, 1162, 1193, 1224, 1255,
+  1286, 1317, 1348, 1379, 1410, 1441, 1472, 543,  574,  605,  636,  667,  698,
+  729,  760,  791,  822,  853,  884,  915,  946,  977,  1008, 1039, 1070, 1101,
+  1132, 1163, 1194, 1225, 1256, 1287, 1318, 1349, 1380, 1411, 1442, 1473, 1504,
+  575,  606,  637,  668,  699,  730,  761,  792,  823,  854,  885,  916,  947,
+  978,  1009, 1040, 1071, 1102, 1133, 1164, 1195, 1226, 1257, 1288, 1319, 1350,
+  1381, 1412, 1443, 1474, 1505, 1536, 607,  638,  669,  700,  731,  762,  793,
+  824,  855,  886,  917,  948,  979,  1010, 1041, 1072, 1103, 1134, 1165, 1196,
+  1227, 1258, 1289, 1320, 1351, 1382, 1413, 1444, 1475, 1506, 1537, 1568, 639,
+  670,  701,  732,  763,  794,  825,  856,  887,  918,  949,  980,  1011, 1042,
+  1073, 1104, 1135, 1166, 1197, 1228, 1259, 1290, 1321, 1352, 1383, 1414, 1445,
+  1476, 1507, 1538, 1569, 1600, 671,  702,  733,  764,  795,  826,  857,  888,
+  919,  950,  981,  1012, 1043, 1074, 1105, 1136, 1167, 1198, 1229, 1260, 1291,
+  1322, 1353, 1384, 1415, 1446, 1477, 1508, 1539, 1570, 1601, 1632, 703,  734,
+  765,  796,  827,  858,  889,  920,  951,  982,  1013, 1044, 1075, 1106, 1137,
+  1168, 1199, 1230, 1261, 1292, 1323, 1354, 1385, 1416, 1447, 1478, 1509, 1540,
+  1571, 1602, 1633, 1664, 735,  766,  797,  828,  859,  890,  921,  952,  983,
+  1014, 1045, 1076, 1107, 1138, 1169, 1200, 1231, 1262, 1293, 1324, 1355, 1386,
+  1417, 1448, 1479, 1510, 1541, 1572, 1603, 1634, 1665, 1696, 767,  798,  829,
+  860,  891,  922,  953,  984,  1015, 1046, 1077, 1108, 1139, 1170, 1201, 1232,
+  1263, 1294, 1325, 1356, 1387, 1418, 1449, 1480, 1511, 1542, 1573, 1604, 1635,
+  1666, 1697, 1728, 799,  830,  861,  892,  923,  954,  985,  1016, 1047, 1078,
+  1109, 1140, 1171, 1202, 1233, 1264, 1295, 1326, 1357, 1388, 1419, 1450, 1481,
+  1512, 1543, 1574, 1605, 1636, 1667, 1698, 1729, 1760, 831,  862,  893,  924,
+  955,  986,  1017, 1048, 1079, 1110, 1141, 1172, 1203, 1234, 1265, 1296, 1327,
+  1358, 1389, 1420, 1451, 1482, 1513, 1544, 1575, 1606, 1637, 1668, 1699, 1730,
+  1761, 1792, 863,  894,  925,  956,  987,  1018, 1049, 1080, 1111, 1142, 1173,
+  1204, 1235, 1266, 1297, 1328, 1359, 1390, 1421, 1452, 1483, 1514, 1545, 1576,
+  1607, 1638, 1669, 1700, 1731, 1762, 1793, 1824, 895,  926,  957,  988,  1019,
+  1050, 1081, 1112, 1143, 1174, 1205, 1236, 1267, 1298, 1329, 1360, 1391, 1422,
+  1453, 1484, 1515, 1546, 1577, 1608, 1639, 1670, 1701, 1732, 1763, 1794, 1825,
+  1856, 927,  958,  989,  1020, 1051, 1082, 1113, 1144, 1175, 1206, 1237, 1268,
+  1299, 1330, 1361, 1392, 1423, 1454, 1485, 1516, 1547, 1578, 1609, 1640, 1671,
+  1702, 1733, 1764, 1795, 1826, 1857, 1888, 959,  990,  1021, 1052, 1083, 1114,
+  1145, 1176, 1207, 1238, 1269, 1300, 1331, 1362, 1393, 1424, 1455, 1486, 1517,
+  1548, 1579, 1610, 1641, 1672, 1703, 1734, 1765, 1796, 1827, 1858, 1889, 1920,
+  991,  1022, 1053, 1084, 1115, 1146, 1177, 1208, 1239, 1270, 1301, 1332, 1363,
+  1394, 1425, 1456, 1487, 1518, 1549, 1580, 1611, 1642, 1673, 1704, 1735, 1766,
+  1797, 1828, 1859, 1890, 1921, 1952, 1023, 1054, 1085, 1116, 1147, 1178, 1209,
+  1240, 1271, 1302, 1333, 1364, 1395, 1426, 1457, 1488, 1519, 1550, 1581, 1612,
+  1643, 1674, 1705, 1736, 1767, 1798, 1829, 1860, 1891, 1922, 1953, 1984, 1055,
+  1086, 1117, 1148, 1179, 1210, 1241, 1272, 1303, 1334, 1365, 1396, 1427, 1458,
+  1489, 1520, 1551, 1582, 1613, 1644, 1675, 1706, 1737, 1768, 1799, 1830, 1861,
+  1892, 1923, 1954, 1985, 2016, 1087, 1118, 1149, 1180, 1211, 1242, 1273, 1304,
+  1335, 1366, 1397, 1428, 1459, 1490, 1521, 1552, 1583, 1614, 1645, 1676, 1707,
+  1738, 1769, 1800, 1831, 1862, 1893, 1924, 1955, 1986, 2017, 1119, 1150, 1181,
+  1212, 1243, 1274, 1305, 1336, 1367, 1398, 1429, 1460, 1491, 1522, 1553, 1584,
+  1615, 1646, 1677, 1708, 1739, 1770, 1801, 1832, 1863, 1894, 1925, 1956, 1987,
+  2018, 1151, 1182, 1213, 1244, 1275, 1306, 1337, 1368, 1399, 1430, 1461, 1492,
+  1523, 1554, 1585, 1616, 1647, 1678, 1709, 1740, 1771, 1802, 1833, 1864, 1895,
+  1926, 1957, 1988, 2019, 1183, 1214, 1245, 1276, 1307, 1338, 1369, 1400, 1431,
+  1462, 1493, 1524, 1555, 1586, 1617, 1648, 1679, 1710, 1741, 1772, 1803, 1834,
+  1865, 1896, 1927, 1958, 1989, 2020, 1215, 1246, 1277, 1308, 1339, 1370, 1401,
+  1432, 1463, 1494, 1525, 1556, 1587, 1618, 1649, 1680, 1711, 1742, 1773, 1804,
+  1835, 1866, 1897, 1928, 1959, 1990, 2021, 1247, 1278, 1309, 1340, 1371, 1402,
+  1433, 1464, 1495, 1526, 1557, 1588, 1619, 1650, 1681, 1712, 1743, 1774, 1805,
+  1836, 1867, 1898, 1929, 1960, 1991, 2022, 1279, 1310, 1341, 1372, 1403, 1434,
+  1465, 1496, 1527, 1558, 1589, 1620, 1651, 1682, 1713, 1744, 1775, 1806, 1837,
+  1868, 1899, 1930, 1961, 1992, 2023, 1311, 1342, 1373, 1404, 1435, 1466, 1497,
+  1528, 1559, 1590, 1621, 1652, 1683, 1714, 1745, 1776, 1807, 1838, 1869, 1900,
+  1931, 1962, 1993, 2024, 1343, 1374, 1405, 1436, 1467, 1498, 1529, 1560, 1591,
+  1622, 1653, 1684, 1715, 1746, 1777, 1808, 1839, 1870, 1901, 1932, 1963, 1994,
+  2025, 1375, 1406, 1437, 1468, 1499, 1530, 1561, 1592, 1623, 1654, 1685, 1716,
+  1747, 1778, 1809, 1840, 1871, 1902, 1933, 1964, 1995, 2026, 1407, 1438, 1469,
+  1500, 1531, 1562, 1593, 1624, 1655, 1686, 1717, 1748, 1779, 1810, 1841, 1872,
+  1903, 1934, 1965, 1996, 2027, 1439, 1470, 1501, 1532, 1563, 1594, 1625, 1656,
+  1687, 1718, 1749, 1780, 1811, 1842, 1873, 1904, 1935, 1966, 1997, 2028, 1471,
+  1502, 1533, 1564, 1595, 1626, 1657, 1688, 1719, 1750, 1781, 1812, 1843, 1874,
+  1905, 1936, 1967, 1998, 2029, 1503, 1534, 1565, 1596, 1627, 1658, 1689, 1720,
+  1751, 1782, 1813, 1844, 1875, 1906, 1937, 1968, 1999, 2030, 1535, 1566, 1597,
+  1628, 1659, 1690, 1721, 1752, 1783, 1814, 1845, 1876, 1907, 1938, 1969, 2000,
+  2031, 1567, 1598, 1629, 1660, 1691, 1722, 1753, 1784, 1815, 1846, 1877, 1908,
+  1939, 1970, 2001, 2032, 1599, 1630, 1661, 1692, 1723, 1754, 1785, 1816, 1847,
+  1878, 1909, 1940, 1971, 2002, 2033, 1631, 1662, 1693, 1724, 1755, 1786, 1817,
+  1848, 1879, 1910, 1941, 1972, 2003, 2034, 1663, 1694, 1725, 1756, 1787, 1818,
+  1849, 1880, 1911, 1942, 1973, 2004, 2035, 1695, 1726, 1757, 1788, 1819, 1850,
+  1881, 1912, 1943, 1974, 2005, 2036, 1727, 1758, 1789, 1820, 1851, 1882, 1913,
+  1944, 1975, 2006, 2037, 1759, 1790, 1821, 1852, 1883, 1914, 1945, 1976, 2007,
+  2038, 1791, 1822, 1853, 1884, 1915, 1946, 1977, 2008, 2039, 1823, 1854, 1885,
+  1916, 1947, 1978, 2009, 2040, 1855, 1886, 1917, 1948, 1979, 2010, 2041, 1887,
+  1918, 1949, 1980, 2011, 2042, 1919, 1950, 1981, 2012, 2043, 1951, 1982, 2013,
+  2044, 1983, 2014, 2045, 2015, 2046, 2047,
+};
+
+DECLARE_ALIGNED(16, static const int16_t, default_scan_64x32[2048]) = {
+  0,    1,    64,   2,    65,   128,  3,    66,   129,  192,  4,    67,   130,
+  193,  256,  5,    68,   131,  194,  257,  320,  6,    69,   132,  195,  258,
+  321,  384,  7,    70,   133,  196,  259,  322,  385,  448,  8,    71,   134,
+  197,  260,  323,  386,  449,  512,  9,    72,   135,  198,  261,  324,  387,
+  450,  513,  576,  10,   73,   136,  199,  262,  325,  388,  451,  514,  577,
+  640,  11,   74,   137,  200,  263,  326,  389,  452,  515,  578,  641,  704,
+  12,   75,   138,  201,  264,  327,  390,  453,  516,  579,  642,  705,  768,
+  13,   76,   139,  202,  265,  328,  391,  454,  517,  580,  643,  706,  769,
+  832,  14,   77,   140,  203,  266,  329,  392,  455,  518,  581,  644,  707,
+  770,  833,  896,  15,   78,   141,  204,  267,  330,  393,  456,  519,  582,
+  645,  708,  771,  834,  897,  960,  16,   79,   142,  205,  268,  331,  394,
+  457,  520,  583,  646,  709,  772,  835,  898,  961,  1024, 17,   80,   143,
+  206,  269,  332,  395,  458,  521,  584,  647,  710,  773,  836,  899,  962,
+  1025, 1088, 18,   81,   144,  207,  270,  333,  396,  459,  522,  585,  648,
+  711,  774,  837,  900,  963,  1026, 1089, 1152, 19,   82,   145,  208,  271,
+  334,  397,  460,  523,  586,  649,  712,  775,  838,  901,  964,  1027, 1090,
+  1153, 1216, 20,   83,   146,  209,  272,  335,  398,  461,  524,  587,  650,
+  713,  776,  839,  902,  965,  1028, 1091, 1154, 1217, 1280, 21,   84,   147,
+  210,  273,  336,  399,  462,  525,  588,  651,  714,  777,  840,  903,  966,
+  1029, 1092, 1155, 1218, 1281, 1344, 22,   85,   148,  211,  274,  337,  400,
+  463,  526,  589,  652,  715,  778,  841,  904,  967,  1030, 1093, 1156, 1219,
+  1282, 1345, 1408, 23,   86,   149,  212,  275,  338,  401,  464,  527,  590,
+  653,  716,  779,  842,  905,  968,  1031, 1094, 1157, 1220, 1283, 1346, 1409,
+  1472, 24,   87,   150,  213,  276,  339,  402,  465,  528,  591,  654,  717,
+  780,  843,  906,  969,  1032, 1095, 1158, 1221, 1284, 1347, 1410, 1473, 1536,
+  25,   88,   151,  214,  277,  340,  403,  466,  529,  592,  655,  718,  781,
+  844,  907,  970,  1033, 1096, 1159, 1222, 1285, 1348, 1411, 1474, 1537, 1600,
+  26,   89,   152,  215,  278,  341,  404,  467,  530,  593,  656,  719,  782,
+  845,  908,  971,  1034, 1097, 1160, 1223, 1286, 1349, 1412, 1475, 1538, 1601,
+  1664, 27,   90,   153,  216,  279,  342,  405,  468,  531,  594,  657,  720,
+  783,  846,  909,  972,  1035, 1098, 1161, 1224, 1287, 1350, 1413, 1476, 1539,
+  1602, 1665, 1728, 28,   91,   154,  217,  280,  343,  406,  469,  532,  595,
+  658,  721,  784,  847,  910,  973,  1036, 1099, 1162, 1225, 1288, 1351, 1414,
+  1477, 1540, 1603, 1666, 1729, 1792, 29,   92,   155,  218,  281,  344,  407,
+  470,  533,  596,  659,  722,  785,  848,  911,  974,  1037, 1100, 1163, 1226,
+  1289, 1352, 1415, 1478, 1541, 1604, 1667, 1730, 1793, 1856, 30,   93,   156,
+  219,  282,  345,  408,  471,  534,  597,  660,  723,  786,  849,  912,  975,
+  1038, 1101, 1164, 1227, 1290, 1353, 1416, 1479, 1542, 1605, 1668, 1731, 1794,
+  1857, 1920, 31,   94,   157,  220,  283,  346,  409,  472,  535,  598,  661,
+  724,  787,  850,  913,  976,  1039, 1102, 1165, 1228, 1291, 1354, 1417, 1480,
+  1543, 1606, 1669, 1732, 1795, 1858, 1921, 1984, 32,   95,   158,  221,  284,
+  347,  410,  473,  536,  599,  662,  725,  788,  851,  914,  977,  1040, 1103,
+  1166, 1229, 1292, 1355, 1418, 1481, 1544, 1607, 1670, 1733, 1796, 1859, 1922,
+  1985, 33,   96,   159,  222,  285,  348,  411,  474,  537,  600,  663,  726,
+  789,  852,  915,  978,  1041, 1104, 1167, 1230, 1293, 1356, 1419, 1482, 1545,
+  1608, 1671, 1734, 1797, 1860, 1923, 1986, 34,   97,   160,  223,  286,  349,
+  412,  475,  538,  601,  664,  727,  790,  853,  916,  979,  1042, 1105, 1168,
+  1231, 1294, 1357, 1420, 1483, 1546, 1609, 1672, 1735, 1798, 1861, 1924, 1987,
+  35,   98,   161,  224,  287,  350,  413,  476,  539,  602,  665,  728,  791,
+  854,  917,  980,  1043, 1106, 1169, 1232, 1295, 1358, 1421, 1484, 1547, 1610,
+  1673, 1736, 1799, 1862, 1925, 1988, 36,   99,   162,  225,  288,  351,  414,
+  477,  540,  603,  666,  729,  792,  855,  918,  981,  1044, 1107, 1170, 1233,
+  1296, 1359, 1422, 1485, 1548, 1611, 1674, 1737, 1800, 1863, 1926, 1989, 37,
+  100,  163,  226,  289,  352,  415,  478,  541,  604,  667,  730,  793,  856,
+  919,  982,  1045, 1108, 1171, 1234, 1297, 1360, 1423, 1486, 1549, 1612, 1675,
+  1738, 1801, 1864, 1927, 1990, 38,   101,  164,  227,  290,  353,  416,  479,
+  542,  605,  668,  731,  794,  857,  920,  983,  1046, 1109, 1172, 1235, 1298,
+  1361, 1424, 1487, 1550, 1613, 1676, 1739, 1802, 1865, 1928, 1991, 39,   102,
+  165,  228,  291,  354,  417,  480,  543,  606,  669,  732,  795,  858,  921,
+  984,  1047, 1110, 1173, 1236, 1299, 1362, 1425, 1488, 1551, 1614, 1677, 1740,
+  1803, 1866, 1929, 1992, 40,   103,  166,  229,  292,  355,  418,  481,  544,
+  607,  670,  733,  796,  859,  922,  985,  1048, 1111, 1174, 1237, 1300, 1363,
+  1426, 1489, 1552, 1615, 1678, 1741, 1804, 1867, 1930, 1993, 41,   104,  167,
+  230,  293,  356,  419,  482,  545,  608,  671,  734,  797,  860,  923,  986,
+  1049, 1112, 1175, 1238, 1301, 1364, 1427, 1490, 1553, 1616, 1679, 1742, 1805,
+  1868, 1931, 1994, 42,   105,  168,  231,  294,  357,  420,  483,  546,  609,
+  672,  735,  798,  861,  924,  987,  1050, 1113, 1176, 1239, 1302, 1365, 1428,
+  1491, 1554, 1617, 1680, 1743, 1806, 1869, 1932, 1995, 43,   106,  169,  232,
+  295,  358,  421,  484,  547,  610,  673,  736,  799,  862,  925,  988,  1051,
+  1114, 1177, 1240, 1303, 1366, 1429, 1492, 1555, 1618, 1681, 1744, 1807, 1870,
+  1933, 1996, 44,   107,  170,  233,  296,  359,  422,  485,  548,  611,  674,
+  737,  800,  863,  926,  989,  1052, 1115, 1178, 1241, 1304, 1367, 1430, 1493,
+  1556, 1619, 1682, 1745, 1808, 1871, 1934, 1997, 45,   108,  171,  234,  297,
+  360,  423,  486,  549,  612,  675,  738,  801,  864,  927,  990,  1053, 1116,
+  1179, 1242, 1305, 1368, 1431, 1494, 1557, 1620, 1683, 1746, 1809, 1872, 1935,
+  1998, 46,   109,  172,  235,  298,  361,  424,  487,  550,  613,  676,  739,
+  802,  865,  928,  991,  1054, 1117, 1180, 1243, 1306, 1369, 1432, 1495, 1558,
+  1621, 1684, 1747, 1810, 1873, 1936, 1999, 47,   110,  173,  236,  299,  362,
+  425,  488,  551,  614,  677,  740,  803,  866,  929,  992,  1055, 1118, 1181,
+  1244, 1307, 1370, 1433, 1496, 1559, 1622, 1685, 1748, 1811, 1874, 1937, 2000,
+  48,   111,  174,  237,  300,  363,  426,  489,  552,  615,  678,  741,  804,
+  867,  930,  993,  1056, 1119, 1182, 1245, 1308, 1371, 1434, 1497, 1560, 1623,
+  1686, 1749, 1812, 1875, 1938, 2001, 49,   112,  175,  238,  301,  364,  427,
+  490,  553,  616,  679,  742,  805,  868,  931,  994,  1057, 1120, 1183, 1246,
+  1309, 1372, 1435, 1498, 1561, 1624, 1687, 1750, 1813, 1876, 1939, 2002, 50,
+  113,  176,  239,  302,  365,  428,  491,  554,  617,  680,  743,  806,  869,
+  932,  995,  1058, 1121, 1184, 1247, 1310, 1373, 1436, 1499, 1562, 1625, 1688,
+  1751, 1814, 1877, 1940, 2003, 51,   114,  177,  240,  303,  366,  429,  492,
+  555,  618,  681,  744,  807,  870,  933,  996,  1059, 1122, 1185, 1248, 1311,
+  1374, 1437, 1500, 1563, 1626, 1689, 1752, 1815, 1878, 1941, 2004, 52,   115,
+  178,  241,  304,  367,  430,  493,  556,  619,  682,  745,  808,  871,  934,
+  997,  1060, 1123, 1186, 1249, 1312, 1375, 1438, 1501, 1564, 1627, 1690, 1753,
+  1816, 1879, 1942, 2005, 53,   116,  179,  242,  305,  368,  431,  494,  557,
+  620,  683,  746,  809,  872,  935,  998,  1061, 1124, 1187, 1250, 1313, 1376,
+  1439, 1502, 1565, 1628, 1691, 1754, 1817, 1880, 1943, 2006, 54,   117,  180,
+  243,  306,  369,  432,  495,  558,  621,  684,  747,  810,  873,  936,  999,
+  1062, 1125, 1188, 1251, 1314, 1377, 1440, 1503, 1566, 1629, 1692, 1755, 1818,
+  1881, 1944, 2007, 55,   118,  181,  244,  307,  370,  433,  496,  559,  622,
+  685,  748,  811,  874,  937,  1000, 1063, 1126, 1189, 1252, 1315, 1378, 1441,
+  1504, 1567, 1630, 1693, 1756, 1819, 1882, 1945, 2008, 56,   119,  182,  245,
+  308,  371,  434,  497,  560,  623,  686,  749,  812,  875,  938,  1001, 1064,
+  1127, 1190, 1253, 1316, 1379, 1442, 1505, 1568, 1631, 1694, 1757, 1820, 1883,
+  1946, 2009, 57,   120,  183,  246,  309,  372,  435,  498,  561,  624,  687,
+  750,  813,  876,  939,  1002, 1065, 1128, 1191, 1254, 1317, 1380, 1443, 1506,
+  1569, 1632, 1695, 1758, 1821, 1884, 1947, 2010, 58,   121,  184,  247,  310,
+  373,  436,  499,  562,  625,  688,  751,  814,  877,  940,  1003, 1066, 1129,
+  1192, 1255, 1318, 1381, 1444, 1507, 1570, 1633, 1696, 1759, 1822, 1885, 1948,
+  2011, 59,   122,  185,  248,  311,  374,  437,  500,  563,  626,  689,  752,
+  815,  878,  941,  1004, 1067, 1130, 1193, 1256, 1319, 1382, 1445, 1508, 1571,
+  1634, 1697, 1760, 1823, 1886, 1949, 2012, 60,   123,  186,  249,  312,  375,
+  438,  501,  564,  627,  690,  753,  816,  879,  942,  1005, 1068, 1131, 1194,
+  1257, 1320, 1383, 1446, 1509, 1572, 1635, 1698, 1761, 1824, 1887, 1950, 2013,
+  61,   124,  187,  250,  313,  376,  439,  502,  565,  628,  691,  754,  817,
+  880,  943,  1006, 1069, 1132, 1195, 1258, 1321, 1384, 1447, 1510, 1573, 1636,
+  1699, 1762, 1825, 1888, 1951, 2014, 62,   125,  188,  251,  314,  377,  440,
+  503,  566,  629,  692,  755,  818,  881,  944,  1007, 1070, 1133, 1196, 1259,
+  1322, 1385, 1448, 1511, 1574, 1637, 1700, 1763, 1826, 1889, 1952, 2015, 63,
+  126,  189,  252,  315,  378,  441,  504,  567,  630,  693,  756,  819,  882,
+  945,  1008, 1071, 1134, 1197, 1260, 1323, 1386, 1449, 1512, 1575, 1638, 1701,
+  1764, 1827, 1890, 1953, 2016, 127,  190,  253,  316,  379,  442,  505,  568,
+  631,  694,  757,  820,  883,  946,  1009, 1072, 1135, 1198, 1261, 1324, 1387,
+  1450, 1513, 1576, 1639, 1702, 1765, 1828, 1891, 1954, 2017, 191,  254,  317,
+  380,  443,  506,  569,  632,  695,  758,  821,  884,  947,  1010, 1073, 1136,
+  1199, 1262, 1325, 1388, 1451, 1514, 1577, 1640, 1703, 1766, 1829, 1892, 1955,
+  2018, 255,  318,  381,  444,  507,  570,  633,  696,  759,  822,  885,  948,
+  1011, 1074, 1137, 1200, 1263, 1326, 1389, 1452, 1515, 1578, 1641, 1704, 1767,
+  1830, 1893, 1956, 2019, 319,  382,  445,  508,  571,  634,  697,  760,  823,
+  886,  949,  1012, 1075, 1138, 1201, 1264, 1327, 1390, 1453, 1516, 1579, 1642,
+  1705, 1768, 1831, 1894, 1957, 2020, 383,  446,  509,  572,  635,  698,  761,
+  824,  887,  950,  1013, 1076, 1139, 1202, 1265, 1328, 1391, 1454, 1517, 1580,
+  1643, 1706, 1769, 1832, 1895, 1958, 2021, 447,  510,  573,  636,  699,  762,
+  825,  888,  951,  1014, 1077, 1140, 1203, 1266, 1329, 1392, 1455, 1518, 1581,
+  1644, 1707, 1770, 1833, 1896, 1959, 2022, 511,  574,  637,  700,  763,  826,
+  889,  952,  1015, 1078, 1141, 1204, 1267, 1330, 1393, 1456, 1519, 1582, 1645,
+  1708, 1771, 1834, 1897, 1960, 2023, 575,  638,  701,  764,  827,  890,  953,
+  1016, 1079, 1142, 1205, 1268, 1331, 1394, 1457, 1520, 1583, 1646, 1709, 1772,
+  1835, 1898, 1961, 2024, 639,  702,  765,  828,  891,  954,  1017, 1080, 1143,
+  1206, 1269, 1332, 1395, 1458, 1521, 1584, 1647, 1710, 1773, 1836, 1899, 1962,
+  2025, 703,  766,  829,  892,  955,  1018, 1081, 1144, 1207, 1270, 1333, 1396,
+  1459, 1522, 1585, 1648, 1711, 1774, 1837, 1900, 1963, 2026, 767,  830,  893,
+  956,  1019, 1082, 1145, 1208, 1271, 1334, 1397, 1460, 1523, 1586, 1649, 1712,
+  1775, 1838, 1901, 1964, 2027, 831,  894,  957,  1020, 1083, 1146, 1209, 1272,
+  1335, 1398, 1461, 1524, 1587, 1650, 1713, 1776, 1839, 1902, 1965, 2028, 895,
+  958,  1021, 1084, 1147, 1210, 1273, 1336, 1399, 1462, 1525, 1588, 1651, 1714,
+  1777, 1840, 1903, 1966, 2029, 959,  1022, 1085, 1148, 1211, 1274, 1337, 1400,
+  1463, 1526, 1589, 1652, 1715, 1778, 1841, 1904, 1967, 2030, 1023, 1086, 1149,
+  1212, 1275, 1338, 1401, 1464, 1527, 1590, 1653, 1716, 1779, 1842, 1905, 1968,
+  2031, 1087, 1150, 1213, 1276, 1339, 1402, 1465, 1528, 1591, 1654, 1717, 1780,
+  1843, 1906, 1969, 2032, 1151, 1214, 1277, 1340, 1403, 1466, 1529, 1592, 1655,
+  1718, 1781, 1844, 1907, 1970, 2033, 1215, 1278, 1341, 1404, 1467, 1530, 1593,
+  1656, 1719, 1782, 1845, 1908, 1971, 2034, 1279, 1342, 1405, 1468, 1531, 1594,
+  1657, 1720, 1783, 1846, 1909, 1972, 2035, 1343, 1406, 1469, 1532, 1595, 1658,
+  1721, 1784, 1847, 1910, 1973, 2036, 1407, 1470, 1533, 1596, 1659, 1722, 1785,
+  1848, 1911, 1974, 2037, 1471, 1534, 1597, 1660, 1723, 1786, 1849, 1912, 1975,
+  2038, 1535, 1598, 1661, 1724, 1787, 1850, 1913, 1976, 2039, 1599, 1662, 1725,
+  1788, 1851, 1914, 1977, 2040, 1663, 1726, 1789, 1852, 1915, 1978, 2041, 1727,
+  1790, 1853, 1916, 1979, 2042, 1791, 1854, 1917, 1980, 2043, 1855, 1918, 1981,
+  2044, 1919, 1982, 2045, 1983, 2046, 2047,
+};
+
 DECLARE_ALIGNED(16, static const int16_t, default_scan_64x64[4096]) = {
   0,    1,    64,   65,   2,    128,  66,   129,  130,  3,    192,  67,   193,
   131,  194,  4,    256,  68,   257,  195,  132,  258,  5,    196,  259,  320,
@@ -3614,6 +3936,646 @@
 
 #if CONFIG_TX64X64
 DECLARE_ALIGNED(16, static const int16_t,
+                default_scan_32x64_neighbors[2049 * MAX_NEIGHBORS]) = {
+  0,    0,    0,    0,    0,    0,    1,    1,    1,    32,   32,   32,   2,
+  2,    2,    33,   33,   64,   64,   64,   3,    3,    3,    34,   34,   65,
+  65,   96,   96,   96,   4,    4,    4,    35,   35,   66,   66,   97,   97,
+  128,  128,  128,  5,    5,    5,    36,   36,   67,   67,   98,   98,   129,
+  129,  160,  160,  160,  6,    6,    6,    37,   37,   68,   68,   99,   99,
+  130,  130,  161,  161,  192,  192,  192,  7,    7,    7,    38,   38,   69,
+  69,   100,  100,  131,  131,  162,  162,  193,  193,  224,  224,  224,  8,
+  8,    8,    39,   39,   70,   70,   101,  101,  132,  132,  163,  163,  194,
+  194,  225,  225,  256,  256,  256,  9,    9,    9,    40,   40,   71,   71,
+  102,  102,  133,  133,  164,  164,  195,  195,  226,  226,  257,  257,  288,
+  288,  288,  10,   10,   10,   41,   41,   72,   72,   103,  103,  134,  134,
+  165,  165,  196,  196,  227,  227,  258,  258,  289,  289,  320,  320,  320,
+  11,   11,   11,   42,   42,   73,   73,   104,  104,  135,  135,  166,  166,
+  197,  197,  228,  228,  259,  259,  290,  290,  321,  321,  352,  352,  352,
+  12,   12,   12,   43,   43,   74,   74,   105,  105,  136,  136,  167,  167,
+  198,  198,  229,  229,  260,  260,  291,  291,  322,  322,  353,  353,  384,
+  384,  384,  13,   13,   13,   44,   44,   75,   75,   106,  106,  137,  137,
+  168,  168,  199,  199,  230,  230,  261,  261,  292,  292,  323,  323,  354,
+  354,  385,  385,  416,  416,  416,  14,   14,   14,   45,   45,   76,   76,
+  107,  107,  138,  138,  169,  169,  200,  200,  231,  231,  262,  262,  293,
+  293,  324,  324,  355,  355,  386,  386,  417,  417,  448,  448,  448,  15,
+  15,   15,   46,   46,   77,   77,   108,  108,  139,  139,  170,  170,  201,
+  201,  232,  232,  263,  263,  294,  294,  325,  325,  356,  356,  387,  387,
+  418,  418,  449,  449,  480,  480,  480,  16,   16,   16,   47,   47,   78,
+  78,   109,  109,  140,  140,  171,  171,  202,  202,  233,  233,  264,  264,
+  295,  295,  326,  326,  357,  357,  388,  388,  419,  419,  450,  450,  481,
+  481,  512,  512,  512,  17,   17,   17,   48,   48,   79,   79,   110,  110,
+  141,  141,  172,  172,  203,  203,  234,  234,  265,  265,  296,  296,  327,
+  327,  358,  358,  389,  389,  420,  420,  451,  451,  482,  482,  513,  513,
+  544,  544,  544,  18,   18,   18,   49,   49,   80,   80,   111,  111,  142,
+  142,  173,  173,  204,  204,  235,  235,  266,  266,  297,  297,  328,  328,
+  359,  359,  390,  390,  421,  421,  452,  452,  483,  483,  514,  514,  545,
+  545,  576,  576,  576,  19,   19,   19,   50,   50,   81,   81,   112,  112,
+  143,  143,  174,  174,  205,  205,  236,  236,  267,  267,  298,  298,  329,
+  329,  360,  360,  391,  391,  422,  422,  453,  453,  484,  484,  515,  515,
+  546,  546,  577,  577,  608,  608,  608,  20,   20,   20,   51,   51,   82,
+  82,   113,  113,  144,  144,  175,  175,  206,  206,  237,  237,  268,  268,
+  299,  299,  330,  330,  361,  361,  392,  392,  423,  423,  454,  454,  485,
+  485,  516,  516,  547,  547,  578,  578,  609,  609,  640,  640,  640,  21,
+  21,   21,   52,   52,   83,   83,   114,  114,  145,  145,  176,  176,  207,
+  207,  238,  238,  269,  269,  300,  300,  331,  331,  362,  362,  393,  393,
+  424,  424,  455,  455,  486,  486,  517,  517,  548,  548,  579,  579,  610,
+  610,  641,  641,  672,  672,  672,  22,   22,   22,   53,   53,   84,   84,
+  115,  115,  146,  146,  177,  177,  208,  208,  239,  239,  270,  270,  301,
+  301,  332,  332,  363,  363,  394,  394,  425,  425,  456,  456,  487,  487,
+  518,  518,  549,  549,  580,  580,  611,  611,  642,  642,  673,  673,  704,
+  704,  704,  23,   23,   23,   54,   54,   85,   85,   116,  116,  147,  147,
+  178,  178,  209,  209,  240,  240,  271,  271,  302,  302,  333,  333,  364,
+  364,  395,  395,  426,  426,  457,  457,  488,  488,  519,  519,  550,  550,
+  581,  581,  612,  612,  643,  643,  674,  674,  705,  705,  736,  736,  736,
+  24,   24,   24,   55,   55,   86,   86,   117,  117,  148,  148,  179,  179,
+  210,  210,  241,  241,  272,  272,  303,  303,  334,  334,  365,  365,  396,
+  396,  427,  427,  458,  458,  489,  489,  520,  520,  551,  551,  582,  582,
+  613,  613,  644,  644,  675,  675,  706,  706,  737,  737,  768,  768,  768,
+  25,   25,   25,   56,   56,   87,   87,   118,  118,  149,  149,  180,  180,
+  211,  211,  242,  242,  273,  273,  304,  304,  335,  335,  366,  366,  397,
+  397,  428,  428,  459,  459,  490,  490,  521,  521,  552,  552,  583,  583,
+  614,  614,  645,  645,  676,  676,  707,  707,  738,  738,  769,  769,  800,
+  800,  800,  26,   26,   26,   57,   57,   88,   88,   119,  119,  150,  150,
+  181,  181,  212,  212,  243,  243,  274,  274,  305,  305,  336,  336,  367,
+  367,  398,  398,  429,  429,  460,  460,  491,  491,  522,  522,  553,  553,
+  584,  584,  615,  615,  646,  646,  677,  677,  708,  708,  739,  739,  770,
+  770,  801,  801,  832,  832,  832,  27,   27,   27,   58,   58,   89,   89,
+  120,  120,  151,  151,  182,  182,  213,  213,  244,  244,  275,  275,  306,
+  306,  337,  337,  368,  368,  399,  399,  430,  430,  461,  461,  492,  492,
+  523,  523,  554,  554,  585,  585,  616,  616,  647,  647,  678,  678,  709,
+  709,  740,  740,  771,  771,  802,  802,  833,  833,  864,  864,  864,  28,
+  28,   28,   59,   59,   90,   90,   121,  121,  152,  152,  183,  183,  214,
+  214,  245,  245,  276,  276,  307,  307,  338,  338,  369,  369,  400,  400,
+  431,  431,  462,  462,  493,  493,  524,  524,  555,  555,  586,  586,  617,
+  617,  648,  648,  679,  679,  710,  710,  741,  741,  772,  772,  803,  803,
+  834,  834,  865,  865,  896,  896,  896,  29,   29,   29,   60,   60,   91,
+  91,   122,  122,  153,  153,  184,  184,  215,  215,  246,  246,  277,  277,
+  308,  308,  339,  339,  370,  370,  401,  401,  432,  432,  463,  463,  494,
+  494,  525,  525,  556,  556,  587,  587,  618,  618,  649,  649,  680,  680,
+  711,  711,  742,  742,  773,  773,  804,  804,  835,  835,  866,  866,  897,
+  897,  928,  928,  928,  30,   30,   30,   61,   61,   92,   92,   123,  123,
+  154,  154,  185,  185,  216,  216,  247,  247,  278,  278,  309,  309,  340,
+  340,  371,  371,  402,  402,  433,  433,  464,  464,  495,  495,  526,  526,
+  557,  557,  588,  588,  619,  619,  650,  650,  681,  681,  712,  712,  743,
+  743,  774,  774,  805,  805,  836,  836,  867,  867,  898,  898,  929,  929,
+  960,  960,  960,  31,   62,   62,   93,   93,   124,  124,  155,  155,  186,
+  186,  217,  217,  248,  248,  279,  279,  310,  310,  341,  341,  372,  372,
+  403,  403,  434,  434,  465,  465,  496,  496,  527,  527,  558,  558,  589,
+  589,  620,  620,  651,  651,  682,  682,  713,  713,  744,  744,  775,  775,
+  806,  806,  837,  837,  868,  868,  899,  899,  930,  930,  961,  961,  992,
+  992,  992,  63,   94,   94,   125,  125,  156,  156,  187,  187,  218,  218,
+  249,  249,  280,  280,  311,  311,  342,  342,  373,  373,  404,  404,  435,
+  435,  466,  466,  497,  497,  528,  528,  559,  559,  590,  590,  621,  621,
+  652,  652,  683,  683,  714,  714,  745,  745,  776,  776,  807,  807,  838,
+  838,  869,  869,  900,  900,  931,  931,  962,  962,  993,  993,  1024, 1024,
+  1024, 95,   126,  126,  157,  157,  188,  188,  219,  219,  250,  250,  281,
+  281,  312,  312,  343,  343,  374,  374,  405,  405,  436,  436,  467,  467,
+  498,  498,  529,  529,  560,  560,  591,  591,  622,  622,  653,  653,  684,
+  684,  715,  715,  746,  746,  777,  777,  808,  808,  839,  839,  870,  870,
+  901,  901,  932,  932,  963,  963,  994,  994,  1025, 1025, 1056, 1056, 1056,
+  127,  158,  158,  189,  189,  220,  220,  251,  251,  282,  282,  313,  313,
+  344,  344,  375,  375,  406,  406,  437,  437,  468,  468,  499,  499,  530,
+  530,  561,  561,  592,  592,  623,  623,  654,  654,  685,  685,  716,  716,
+  747,  747,  778,  778,  809,  809,  840,  840,  871,  871,  902,  902,  933,
+  933,  964,  964,  995,  995,  1026, 1026, 1057, 1057, 1088, 1088, 1088, 159,
+  190,  190,  221,  221,  252,  252,  283,  283,  314,  314,  345,  345,  376,
+  376,  407,  407,  438,  438,  469,  469,  500,  500,  531,  531,  562,  562,
+  593,  593,  624,  624,  655,  655,  686,  686,  717,  717,  748,  748,  779,
+  779,  810,  810,  841,  841,  872,  872,  903,  903,  934,  934,  965,  965,
+  996,  996,  1027, 1027, 1058, 1058, 1089, 1089, 1120, 1120, 1120, 191,  222,
+  222,  253,  253,  284,  284,  315,  315,  346,  346,  377,  377,  408,  408,
+  439,  439,  470,  470,  501,  501,  532,  532,  563,  563,  594,  594,  625,
+  625,  656,  656,  687,  687,  718,  718,  749,  749,  780,  780,  811,  811,
+  842,  842,  873,  873,  904,  904,  935,  935,  966,  966,  997,  997,  1028,
+  1028, 1059, 1059, 1090, 1090, 1121, 1121, 1152, 1152, 1152, 223,  254,  254,
+  285,  285,  316,  316,  347,  347,  378,  378,  409,  409,  440,  440,  471,
+  471,  502,  502,  533,  533,  564,  564,  595,  595,  626,  626,  657,  657,
+  688,  688,  719,  719,  750,  750,  781,  781,  812,  812,  843,  843,  874,
+  874,  905,  905,  936,  936,  967,  967,  998,  998,  1029, 1029, 1060, 1060,
+  1091, 1091, 1122, 1122, 1153, 1153, 1184, 1184, 1184, 255,  286,  286,  317,
+  317,  348,  348,  379,  379,  410,  410,  441,  441,  472,  472,  503,  503,
+  534,  534,  565,  565,  596,  596,  627,  627,  658,  658,  689,  689,  720,
+  720,  751,  751,  782,  782,  813,  813,  844,  844,  875,  875,  906,  906,
+  937,  937,  968,  968,  999,  999,  1030, 1030, 1061, 1061, 1092, 1092, 1123,
+  1123, 1154, 1154, 1185, 1185, 1216, 1216, 1216, 287,  318,  318,  349,  349,
+  380,  380,  411,  411,  442,  442,  473,  473,  504,  504,  535,  535,  566,
+  566,  597,  597,  628,  628,  659,  659,  690,  690,  721,  721,  752,  752,
+  783,  783,  814,  814,  845,  845,  876,  876,  907,  907,  938,  938,  969,
+  969,  1000, 1000, 1031, 1031, 1062, 1062, 1093, 1093, 1124, 1124, 1155, 1155,
+  1186, 1186, 1217, 1217, 1248, 1248, 1248, 319,  350,  350,  381,  381,  412,
+  412,  443,  443,  474,  474,  505,  505,  536,  536,  567,  567,  598,  598,
+  629,  629,  660,  660,  691,  691,  722,  722,  753,  753,  784,  784,  815,
+  815,  846,  846,  877,  877,  908,  908,  939,  939,  970,  970,  1001, 1001,
+  1032, 1032, 1063, 1063, 1094, 1094, 1125, 1125, 1156, 1156, 1187, 1187, 1218,
+  1218, 1249, 1249, 1280, 1280, 1280, 351,  382,  382,  413,  413,  444,  444,
+  475,  475,  506,  506,  537,  537,  568,  568,  599,  599,  630,  630,  661,
+  661,  692,  692,  723,  723,  754,  754,  785,  785,  816,  816,  847,  847,
+  878,  878,  909,  909,  940,  940,  971,  971,  1002, 1002, 1033, 1033, 1064,
+  1064, 1095, 1095, 1126, 1126, 1157, 1157, 1188, 1188, 1219, 1219, 1250, 1250,
+  1281, 1281, 1312, 1312, 1312, 383,  414,  414,  445,  445,  476,  476,  507,
+  507,  538,  538,  569,  569,  600,  600,  631,  631,  662,  662,  693,  693,
+  724,  724,  755,  755,  786,  786,  817,  817,  848,  848,  879,  879,  910,
+  910,  941,  941,  972,  972,  1003, 1003, 1034, 1034, 1065, 1065, 1096, 1096,
+  1127, 1127, 1158, 1158, 1189, 1189, 1220, 1220, 1251, 1251, 1282, 1282, 1313,
+  1313, 1344, 1344, 1344, 415,  446,  446,  477,  477,  508,  508,  539,  539,
+  570,  570,  601,  601,  632,  632,  663,  663,  694,  694,  725,  725,  756,
+  756,  787,  787,  818,  818,  849,  849,  880,  880,  911,  911,  942,  942,
+  973,  973,  1004, 1004, 1035, 1035, 1066, 1066, 1097, 1097, 1128, 1128, 1159,
+  1159, 1190, 1190, 1221, 1221, 1252, 1252, 1283, 1283, 1314, 1314, 1345, 1345,
+  1376, 1376, 1376, 447,  478,  478,  509,  509,  540,  540,  571,  571,  602,
+  602,  633,  633,  664,  664,  695,  695,  726,  726,  757,  757,  788,  788,
+  819,  819,  850,  850,  881,  881,  912,  912,  943,  943,  974,  974,  1005,
+  1005, 1036, 1036, 1067, 1067, 1098, 1098, 1129, 1129, 1160, 1160, 1191, 1191,
+  1222, 1222, 1253, 1253, 1284, 1284, 1315, 1315, 1346, 1346, 1377, 1377, 1408,
+  1408, 1408, 479,  510,  510,  541,  541,  572,  572,  603,  603,  634,  634,
+  665,  665,  696,  696,  727,  727,  758,  758,  789,  789,  820,  820,  851,
+  851,  882,  882,  913,  913,  944,  944,  975,  975,  1006, 1006, 1037, 1037,
+  1068, 1068, 1099, 1099, 1130, 1130, 1161, 1161, 1192, 1192, 1223, 1223, 1254,
+  1254, 1285, 1285, 1316, 1316, 1347, 1347, 1378, 1378, 1409, 1409, 1440, 1440,
+  1440, 511,  542,  542,  573,  573,  604,  604,  635,  635,  666,  666,  697,
+  697,  728,  728,  759,  759,  790,  790,  821,  821,  852,  852,  883,  883,
+  914,  914,  945,  945,  976,  976,  1007, 1007, 1038, 1038, 1069, 1069, 1100,
+  1100, 1131, 1131, 1162, 1162, 1193, 1193, 1224, 1224, 1255, 1255, 1286, 1286,
+  1317, 1317, 1348, 1348, 1379, 1379, 1410, 1410, 1441, 1441, 1472, 1472, 1472,
+  543,  574,  574,  605,  605,  636,  636,  667,  667,  698,  698,  729,  729,
+  760,  760,  791,  791,  822,  822,  853,  853,  884,  884,  915,  915,  946,
+  946,  977,  977,  1008, 1008, 1039, 1039, 1070, 1070, 1101, 1101, 1132, 1132,
+  1163, 1163, 1194, 1194, 1225, 1225, 1256, 1256, 1287, 1287, 1318, 1318, 1349,
+  1349, 1380, 1380, 1411, 1411, 1442, 1442, 1473, 1473, 1504, 1504, 1504, 575,
+  606,  606,  637,  637,  668,  668,  699,  699,  730,  730,  761,  761,  792,
+  792,  823,  823,  854,  854,  885,  885,  916,  916,  947,  947,  978,  978,
+  1009, 1009, 1040, 1040, 1071, 1071, 1102, 1102, 1133, 1133, 1164, 1164, 1195,
+  1195, 1226, 1226, 1257, 1257, 1288, 1288, 1319, 1319, 1350, 1350, 1381, 1381,
+  1412, 1412, 1443, 1443, 1474, 1474, 1505, 1505, 1536, 1536, 1536, 607,  638,
+  638,  669,  669,  700,  700,  731,  731,  762,  762,  793,  793,  824,  824,
+  855,  855,  886,  886,  917,  917,  948,  948,  979,  979,  1010, 1010, 1041,
+  1041, 1072, 1072, 1103, 1103, 1134, 1134, 1165, 1165, 1196, 1196, 1227, 1227,
+  1258, 1258, 1289, 1289, 1320, 1320, 1351, 1351, 1382, 1382, 1413, 1413, 1444,
+  1444, 1475, 1475, 1506, 1506, 1537, 1537, 1568, 1568, 1568, 639,  670,  670,
+  701,  701,  732,  732,  763,  763,  794,  794,  825,  825,  856,  856,  887,
+  887,  918,  918,  949,  949,  980,  980,  1011, 1011, 1042, 1042, 1073, 1073,
+  1104, 1104, 1135, 1135, 1166, 1166, 1197, 1197, 1228, 1228, 1259, 1259, 1290,
+  1290, 1321, 1321, 1352, 1352, 1383, 1383, 1414, 1414, 1445, 1445, 1476, 1476,
+  1507, 1507, 1538, 1538, 1569, 1569, 1600, 1600, 1600, 671,  702,  702,  733,
+  733,  764,  764,  795,  795,  826,  826,  857,  857,  888,  888,  919,  919,
+  950,  950,  981,  981,  1012, 1012, 1043, 1043, 1074, 1074, 1105, 1105, 1136,
+  1136, 1167, 1167, 1198, 1198, 1229, 1229, 1260, 1260, 1291, 1291, 1322, 1322,
+  1353, 1353, 1384, 1384, 1415, 1415, 1446, 1446, 1477, 1477, 1508, 1508, 1539,
+  1539, 1570, 1570, 1601, 1601, 1632, 1632, 1632, 703,  734,  734,  765,  765,
+  796,  796,  827,  827,  858,  858,  889,  889,  920,  920,  951,  951,  982,
+  982,  1013, 1013, 1044, 1044, 1075, 1075, 1106, 1106, 1137, 1137, 1168, 1168,
+  1199, 1199, 1230, 1230, 1261, 1261, 1292, 1292, 1323, 1323, 1354, 1354, 1385,
+  1385, 1416, 1416, 1447, 1447, 1478, 1478, 1509, 1509, 1540, 1540, 1571, 1571,
+  1602, 1602, 1633, 1633, 1664, 1664, 1664, 735,  766,  766,  797,  797,  828,
+  828,  859,  859,  890,  890,  921,  921,  952,  952,  983,  983,  1014, 1014,
+  1045, 1045, 1076, 1076, 1107, 1107, 1138, 1138, 1169, 1169, 1200, 1200, 1231,
+  1231, 1262, 1262, 1293, 1293, 1324, 1324, 1355, 1355, 1386, 1386, 1417, 1417,
+  1448, 1448, 1479, 1479, 1510, 1510, 1541, 1541, 1572, 1572, 1603, 1603, 1634,
+  1634, 1665, 1665, 1696, 1696, 1696, 767,  798,  798,  829,  829,  860,  860,
+  891,  891,  922,  922,  953,  953,  984,  984,  1015, 1015, 1046, 1046, 1077,
+  1077, 1108, 1108, 1139, 1139, 1170, 1170, 1201, 1201, 1232, 1232, 1263, 1263,
+  1294, 1294, 1325, 1325, 1356, 1356, 1387, 1387, 1418, 1418, 1449, 1449, 1480,
+  1480, 1511, 1511, 1542, 1542, 1573, 1573, 1604, 1604, 1635, 1635, 1666, 1666,
+  1697, 1697, 1728, 1728, 1728, 799,  830,  830,  861,  861,  892,  892,  923,
+  923,  954,  954,  985,  985,  1016, 1016, 1047, 1047, 1078, 1078, 1109, 1109,
+  1140, 1140, 1171, 1171, 1202, 1202, 1233, 1233, 1264, 1264, 1295, 1295, 1326,
+  1326, 1357, 1357, 1388, 1388, 1419, 1419, 1450, 1450, 1481, 1481, 1512, 1512,
+  1543, 1543, 1574, 1574, 1605, 1605, 1636, 1636, 1667, 1667, 1698, 1698, 1729,
+  1729, 1760, 1760, 1760, 831,  862,  862,  893,  893,  924,  924,  955,  955,
+  986,  986,  1017, 1017, 1048, 1048, 1079, 1079, 1110, 1110, 1141, 1141, 1172,
+  1172, 1203, 1203, 1234, 1234, 1265, 1265, 1296, 1296, 1327, 1327, 1358, 1358,
+  1389, 1389, 1420, 1420, 1451, 1451, 1482, 1482, 1513, 1513, 1544, 1544, 1575,
+  1575, 1606, 1606, 1637, 1637, 1668, 1668, 1699, 1699, 1730, 1730, 1761, 1761,
+  1792, 1792, 1792, 863,  894,  894,  925,  925,  956,  956,  987,  987,  1018,
+  1018, 1049, 1049, 1080, 1080, 1111, 1111, 1142, 1142, 1173, 1173, 1204, 1204,
+  1235, 1235, 1266, 1266, 1297, 1297, 1328, 1328, 1359, 1359, 1390, 1390, 1421,
+  1421, 1452, 1452, 1483, 1483, 1514, 1514, 1545, 1545, 1576, 1576, 1607, 1607,
+  1638, 1638, 1669, 1669, 1700, 1700, 1731, 1731, 1762, 1762, 1793, 1793, 1824,
+  1824, 1824, 895,  926,  926,  957,  957,  988,  988,  1019, 1019, 1050, 1050,
+  1081, 1081, 1112, 1112, 1143, 1143, 1174, 1174, 1205, 1205, 1236, 1236, 1267,
+  1267, 1298, 1298, 1329, 1329, 1360, 1360, 1391, 1391, 1422, 1422, 1453, 1453,
+  1484, 1484, 1515, 1515, 1546, 1546, 1577, 1577, 1608, 1608, 1639, 1639, 1670,
+  1670, 1701, 1701, 1732, 1732, 1763, 1763, 1794, 1794, 1825, 1825, 1856, 1856,
+  1856, 927,  958,  958,  989,  989,  1020, 1020, 1051, 1051, 1082, 1082, 1113,
+  1113, 1144, 1144, 1175, 1175, 1206, 1206, 1237, 1237, 1268, 1268, 1299, 1299,
+  1330, 1330, 1361, 1361, 1392, 1392, 1423, 1423, 1454, 1454, 1485, 1485, 1516,
+  1516, 1547, 1547, 1578, 1578, 1609, 1609, 1640, 1640, 1671, 1671, 1702, 1702,
+  1733, 1733, 1764, 1764, 1795, 1795, 1826, 1826, 1857, 1857, 1888, 1888, 1888,
+  959,  990,  990,  1021, 1021, 1052, 1052, 1083, 1083, 1114, 1114, 1145, 1145,
+  1176, 1176, 1207, 1207, 1238, 1238, 1269, 1269, 1300, 1300, 1331, 1331, 1362,
+  1362, 1393, 1393, 1424, 1424, 1455, 1455, 1486, 1486, 1517, 1517, 1548, 1548,
+  1579, 1579, 1610, 1610, 1641, 1641, 1672, 1672, 1703, 1703, 1734, 1734, 1765,
+  1765, 1796, 1796, 1827, 1827, 1858, 1858, 1889, 1889, 1920, 1920, 1920, 991,
+  1022, 1022, 1053, 1053, 1084, 1084, 1115, 1115, 1146, 1146, 1177, 1177, 1208,
+  1208, 1239, 1239, 1270, 1270, 1301, 1301, 1332, 1332, 1363, 1363, 1394, 1394,
+  1425, 1425, 1456, 1456, 1487, 1487, 1518, 1518, 1549, 1549, 1580, 1580, 1611,
+  1611, 1642, 1642, 1673, 1673, 1704, 1704, 1735, 1735, 1766, 1766, 1797, 1797,
+  1828, 1828, 1859, 1859, 1890, 1890, 1921, 1921, 1952, 1952, 1952, 1023, 1054,
+  1054, 1085, 1085, 1116, 1116, 1147, 1147, 1178, 1178, 1209, 1209, 1240, 1240,
+  1271, 1271, 1302, 1302, 1333, 1333, 1364, 1364, 1395, 1395, 1426, 1426, 1457,
+  1457, 1488, 1488, 1519, 1519, 1550, 1550, 1581, 1581, 1612, 1612, 1643, 1643,
+  1674, 1674, 1705, 1705, 1736, 1736, 1767, 1767, 1798, 1798, 1829, 1829, 1860,
+  1860, 1891, 1891, 1922, 1922, 1953, 1953, 1984, 1984, 1984, 1055, 1086, 1086,
+  1117, 1117, 1148, 1148, 1179, 1179, 1210, 1210, 1241, 1241, 1272, 1272, 1303,
+  1303, 1334, 1334, 1365, 1365, 1396, 1396, 1427, 1427, 1458, 1458, 1489, 1489,
+  1520, 1520, 1551, 1551, 1582, 1582, 1613, 1613, 1644, 1644, 1675, 1675, 1706,
+  1706, 1737, 1737, 1768, 1768, 1799, 1799, 1830, 1830, 1861, 1861, 1892, 1892,
+  1923, 1923, 1954, 1954, 1985, 1985, 2016, 1087, 1118, 1118, 1149, 1149, 1180,
+  1180, 1211, 1211, 1242, 1242, 1273, 1273, 1304, 1304, 1335, 1335, 1366, 1366,
+  1397, 1397, 1428, 1428, 1459, 1459, 1490, 1490, 1521, 1521, 1552, 1552, 1583,
+  1583, 1614, 1614, 1645, 1645, 1676, 1676, 1707, 1707, 1738, 1738, 1769, 1769,
+  1800, 1800, 1831, 1831, 1862, 1862, 1893, 1893, 1924, 1924, 1955, 1955, 1986,
+  1986, 2017, 1119, 1150, 1150, 1181, 1181, 1212, 1212, 1243, 1243, 1274, 1274,
+  1305, 1305, 1336, 1336, 1367, 1367, 1398, 1398, 1429, 1429, 1460, 1460, 1491,
+  1491, 1522, 1522, 1553, 1553, 1584, 1584, 1615, 1615, 1646, 1646, 1677, 1677,
+  1708, 1708, 1739, 1739, 1770, 1770, 1801, 1801, 1832, 1832, 1863, 1863, 1894,
+  1894, 1925, 1925, 1956, 1956, 1987, 1987, 2018, 1151, 1182, 1182, 1213, 1213,
+  1244, 1244, 1275, 1275, 1306, 1306, 1337, 1337, 1368, 1368, 1399, 1399, 1430,
+  1430, 1461, 1461, 1492, 1492, 1523, 1523, 1554, 1554, 1585, 1585, 1616, 1616,
+  1647, 1647, 1678, 1678, 1709, 1709, 1740, 1740, 1771, 1771, 1802, 1802, 1833,
+  1833, 1864, 1864, 1895, 1895, 1926, 1926, 1957, 1957, 1988, 1988, 2019, 1183,
+  1214, 1214, 1245, 1245, 1276, 1276, 1307, 1307, 1338, 1338, 1369, 1369, 1400,
+  1400, 1431, 1431, 1462, 1462, 1493, 1493, 1524, 1524, 1555, 1555, 1586, 1586,
+  1617, 1617, 1648, 1648, 1679, 1679, 1710, 1710, 1741, 1741, 1772, 1772, 1803,
+  1803, 1834, 1834, 1865, 1865, 1896, 1896, 1927, 1927, 1958, 1958, 1989, 1989,
+  2020, 1215, 1246, 1246, 1277, 1277, 1308, 1308, 1339, 1339, 1370, 1370, 1401,
+  1401, 1432, 1432, 1463, 1463, 1494, 1494, 1525, 1525, 1556, 1556, 1587, 1587,
+  1618, 1618, 1649, 1649, 1680, 1680, 1711, 1711, 1742, 1742, 1773, 1773, 1804,
+  1804, 1835, 1835, 1866, 1866, 1897, 1897, 1928, 1928, 1959, 1959, 1990, 1990,
+  2021, 1247, 1278, 1278, 1309, 1309, 1340, 1340, 1371, 1371, 1402, 1402, 1433,
+  1433, 1464, 1464, 1495, 1495, 1526, 1526, 1557, 1557, 1588, 1588, 1619, 1619,
+  1650, 1650, 1681, 1681, 1712, 1712, 1743, 1743, 1774, 1774, 1805, 1805, 1836,
+  1836, 1867, 1867, 1898, 1898, 1929, 1929, 1960, 1960, 1991, 1991, 2022, 1279,
+  1310, 1310, 1341, 1341, 1372, 1372, 1403, 1403, 1434, 1434, 1465, 1465, 1496,
+  1496, 1527, 1527, 1558, 1558, 1589, 1589, 1620, 1620, 1651, 1651, 1682, 1682,
+  1713, 1713, 1744, 1744, 1775, 1775, 1806, 1806, 1837, 1837, 1868, 1868, 1899,
+  1899, 1930, 1930, 1961, 1961, 1992, 1992, 2023, 1311, 1342, 1342, 1373, 1373,
+  1404, 1404, 1435, 1435, 1466, 1466, 1497, 1497, 1528, 1528, 1559, 1559, 1590,
+  1590, 1621, 1621, 1652, 1652, 1683, 1683, 1714, 1714, 1745, 1745, 1776, 1776,
+  1807, 1807, 1838, 1838, 1869, 1869, 1900, 1900, 1931, 1931, 1962, 1962, 1993,
+  1993, 2024, 1343, 1374, 1374, 1405, 1405, 1436, 1436, 1467, 1467, 1498, 1498,
+  1529, 1529, 1560, 1560, 1591, 1591, 1622, 1622, 1653, 1653, 1684, 1684, 1715,
+  1715, 1746, 1746, 1777, 1777, 1808, 1808, 1839, 1839, 1870, 1870, 1901, 1901,
+  1932, 1932, 1963, 1963, 1994, 1994, 2025, 1375, 1406, 1406, 1437, 1437, 1468,
+  1468, 1499, 1499, 1530, 1530, 1561, 1561, 1592, 1592, 1623, 1623, 1654, 1654,
+  1685, 1685, 1716, 1716, 1747, 1747, 1778, 1778, 1809, 1809, 1840, 1840, 1871,
+  1871, 1902, 1902, 1933, 1933, 1964, 1964, 1995, 1995, 2026, 1407, 1438, 1438,
+  1469, 1469, 1500, 1500, 1531, 1531, 1562, 1562, 1593, 1593, 1624, 1624, 1655,
+  1655, 1686, 1686, 1717, 1717, 1748, 1748, 1779, 1779, 1810, 1810, 1841, 1841,
+  1872, 1872, 1903, 1903, 1934, 1934, 1965, 1965, 1996, 1996, 2027, 1439, 1470,
+  1470, 1501, 1501, 1532, 1532, 1563, 1563, 1594, 1594, 1625, 1625, 1656, 1656,
+  1687, 1687, 1718, 1718, 1749, 1749, 1780, 1780, 1811, 1811, 1842, 1842, 1873,
+  1873, 1904, 1904, 1935, 1935, 1966, 1966, 1997, 1997, 2028, 1471, 1502, 1502,
+  1533, 1533, 1564, 1564, 1595, 1595, 1626, 1626, 1657, 1657, 1688, 1688, 1719,
+  1719, 1750, 1750, 1781, 1781, 1812, 1812, 1843, 1843, 1874, 1874, 1905, 1905,
+  1936, 1936, 1967, 1967, 1998, 1998, 2029, 1503, 1534, 1534, 1565, 1565, 1596,
+  1596, 1627, 1627, 1658, 1658, 1689, 1689, 1720, 1720, 1751, 1751, 1782, 1782,
+  1813, 1813, 1844, 1844, 1875, 1875, 1906, 1906, 1937, 1937, 1968, 1968, 1999,
+  1999, 2030, 1535, 1566, 1566, 1597, 1597, 1628, 1628, 1659, 1659, 1690, 1690,
+  1721, 1721, 1752, 1752, 1783, 1783, 1814, 1814, 1845, 1845, 1876, 1876, 1907,
+  1907, 1938, 1938, 1969, 1969, 2000, 2000, 2031, 1567, 1598, 1598, 1629, 1629,
+  1660, 1660, 1691, 1691, 1722, 1722, 1753, 1753, 1784, 1784, 1815, 1815, 1846,
+  1846, 1877, 1877, 1908, 1908, 1939, 1939, 1970, 1970, 2001, 2001, 2032, 1599,
+  1630, 1630, 1661, 1661, 1692, 1692, 1723, 1723, 1754, 1754, 1785, 1785, 1816,
+  1816, 1847, 1847, 1878, 1878, 1909, 1909, 1940, 1940, 1971, 1971, 2002, 2002,
+  2033, 1631, 1662, 1662, 1693, 1693, 1724, 1724, 1755, 1755, 1786, 1786, 1817,
+  1817, 1848, 1848, 1879, 1879, 1910, 1910, 1941, 1941, 1972, 1972, 2003, 2003,
+  2034, 1663, 1694, 1694, 1725, 1725, 1756, 1756, 1787, 1787, 1818, 1818, 1849,
+  1849, 1880, 1880, 1911, 1911, 1942, 1942, 1973, 1973, 2004, 2004, 2035, 1695,
+  1726, 1726, 1757, 1757, 1788, 1788, 1819, 1819, 1850, 1850, 1881, 1881, 1912,
+  1912, 1943, 1943, 1974, 1974, 2005, 2005, 2036, 1727, 1758, 1758, 1789, 1789,
+  1820, 1820, 1851, 1851, 1882, 1882, 1913, 1913, 1944, 1944, 1975, 1975, 2006,
+  2006, 2037, 1759, 1790, 1790, 1821, 1821, 1852, 1852, 1883, 1883, 1914, 1914,
+  1945, 1945, 1976, 1976, 2007, 2007, 2038, 1791, 1822, 1822, 1853, 1853, 1884,
+  1884, 1915, 1915, 1946, 1946, 1977, 1977, 2008, 2008, 2039, 1823, 1854, 1854,
+  1885, 1885, 1916, 1916, 1947, 1947, 1978, 1978, 2009, 2009, 2040, 1855, 1886,
+  1886, 1917, 1917, 1948, 1948, 1979, 1979, 2010, 2010, 2041, 1887, 1918, 1918,
+  1949, 1949, 1980, 1980, 2011, 2011, 2042, 1919, 1950, 1950, 1981, 1981, 2012,
+  2012, 2043, 1951, 1982, 1982, 2013, 2013, 2044, 1983, 2014, 2014, 2045, 2015,
+  2046, 0,    0
+};
+
+DECLARE_ALIGNED(16, static const int16_t,
+                default_scan_64x32_neighbors[2049 * MAX_NEIGHBORS]) = {
+  0,    0,    0,    0,    0,    0,    1,    1,    1,    64,   64,   64,   2,
+  2,    2,    65,   65,   128,  128,  128,  3,    3,    3,    66,   66,   129,
+  129,  192,  192,  192,  4,    4,    4,    67,   67,   130,  130,  193,  193,
+  256,  256,  256,  5,    5,    5,    68,   68,   131,  131,  194,  194,  257,
+  257,  320,  320,  320,  6,    6,    6,    69,   69,   132,  132,  195,  195,
+  258,  258,  321,  321,  384,  384,  384,  7,    7,    7,    70,   70,   133,
+  133,  196,  196,  259,  259,  322,  322,  385,  385,  448,  448,  448,  8,
+  8,    8,    71,   71,   134,  134,  197,  197,  260,  260,  323,  323,  386,
+  386,  449,  449,  512,  512,  512,  9,    9,    9,    72,   72,   135,  135,
+  198,  198,  261,  261,  324,  324,  387,  387,  450,  450,  513,  513,  576,
+  576,  576,  10,   10,   10,   73,   73,   136,  136,  199,  199,  262,  262,
+  325,  325,  388,  388,  451,  451,  514,  514,  577,  577,  640,  640,  640,
+  11,   11,   11,   74,   74,   137,  137,  200,  200,  263,  263,  326,  326,
+  389,  389,  452,  452,  515,  515,  578,  578,  641,  641,  704,  704,  704,
+  12,   12,   12,   75,   75,   138,  138,  201,  201,  264,  264,  327,  327,
+  390,  390,  453,  453,  516,  516,  579,  579,  642,  642,  705,  705,  768,
+  768,  768,  13,   13,   13,   76,   76,   139,  139,  202,  202,  265,  265,
+  328,  328,  391,  391,  454,  454,  517,  517,  580,  580,  643,  643,  706,
+  706,  769,  769,  832,  832,  832,  14,   14,   14,   77,   77,   140,  140,
+  203,  203,  266,  266,  329,  329,  392,  392,  455,  455,  518,  518,  581,
+  581,  644,  644,  707,  707,  770,  770,  833,  833,  896,  896,  896,  15,
+  15,   15,   78,   78,   141,  141,  204,  204,  267,  267,  330,  330,  393,
+  393,  456,  456,  519,  519,  582,  582,  645,  645,  708,  708,  771,  771,
+  834,  834,  897,  897,  960,  960,  960,  16,   16,   16,   79,   79,   142,
+  142,  205,  205,  268,  268,  331,  331,  394,  394,  457,  457,  520,  520,
+  583,  583,  646,  646,  709,  709,  772,  772,  835,  835,  898,  898,  961,
+  961,  1024, 1024, 1024, 17,   17,   17,   80,   80,   143,  143,  206,  206,
+  269,  269,  332,  332,  395,  395,  458,  458,  521,  521,  584,  584,  647,
+  647,  710,  710,  773,  773,  836,  836,  899,  899,  962,  962,  1025, 1025,
+  1088, 1088, 1088, 18,   18,   18,   81,   81,   144,  144,  207,  207,  270,
+  270,  333,  333,  396,  396,  459,  459,  522,  522,  585,  585,  648,  648,
+  711,  711,  774,  774,  837,  837,  900,  900,  963,  963,  1026, 1026, 1089,
+  1089, 1152, 1152, 1152, 19,   19,   19,   82,   82,   145,  145,  208,  208,
+  271,  271,  334,  334,  397,  397,  460,  460,  523,  523,  586,  586,  649,
+  649,  712,  712,  775,  775,  838,  838,  901,  901,  964,  964,  1027, 1027,
+  1090, 1090, 1153, 1153, 1216, 1216, 1216, 20,   20,   20,   83,   83,   146,
+  146,  209,  209,  272,  272,  335,  335,  398,  398,  461,  461,  524,  524,
+  587,  587,  650,  650,  713,  713,  776,  776,  839,  839,  902,  902,  965,
+  965,  1028, 1028, 1091, 1091, 1154, 1154, 1217, 1217, 1280, 1280, 1280, 21,
+  21,   21,   84,   84,   147,  147,  210,  210,  273,  273,  336,  336,  399,
+  399,  462,  462,  525,  525,  588,  588,  651,  651,  714,  714,  777,  777,
+  840,  840,  903,  903,  966,  966,  1029, 1029, 1092, 1092, 1155, 1155, 1218,
+  1218, 1281, 1281, 1344, 1344, 1344, 22,   22,   22,   85,   85,   148,  148,
+  211,  211,  274,  274,  337,  337,  400,  400,  463,  463,  526,  526,  589,
+  589,  652,  652,  715,  715,  778,  778,  841,  841,  904,  904,  967,  967,
+  1030, 1030, 1093, 1093, 1156, 1156, 1219, 1219, 1282, 1282, 1345, 1345, 1408,
+  1408, 1408, 23,   23,   23,   86,   86,   149,  149,  212,  212,  275,  275,
+  338,  338,  401,  401,  464,  464,  527,  527,  590,  590,  653,  653,  716,
+  716,  779,  779,  842,  842,  905,  905,  968,  968,  1031, 1031, 1094, 1094,
+  1157, 1157, 1220, 1220, 1283, 1283, 1346, 1346, 1409, 1409, 1472, 1472, 1472,
+  24,   24,   24,   87,   87,   150,  150,  213,  213,  276,  276,  339,  339,
+  402,  402,  465,  465,  528,  528,  591,  591,  654,  654,  717,  717,  780,
+  780,  843,  843,  906,  906,  969,  969,  1032, 1032, 1095, 1095, 1158, 1158,
+  1221, 1221, 1284, 1284, 1347, 1347, 1410, 1410, 1473, 1473, 1536, 1536, 1536,
+  25,   25,   25,   88,   88,   151,  151,  214,  214,  277,  277,  340,  340,
+  403,  403,  466,  466,  529,  529,  592,  592,  655,  655,  718,  718,  781,
+  781,  844,  844,  907,  907,  970,  970,  1033, 1033, 1096, 1096, 1159, 1159,
+  1222, 1222, 1285, 1285, 1348, 1348, 1411, 1411, 1474, 1474, 1537, 1537, 1600,
+  1600, 1600, 26,   26,   26,   89,   89,   152,  152,  215,  215,  278,  278,
+  341,  341,  404,  404,  467,  467,  530,  530,  593,  593,  656,  656,  719,
+  719,  782,  782,  845,  845,  908,  908,  971,  971,  1034, 1034, 1097, 1097,
+  1160, 1160, 1223, 1223, 1286, 1286, 1349, 1349, 1412, 1412, 1475, 1475, 1538,
+  1538, 1601, 1601, 1664, 1664, 1664, 27,   27,   27,   90,   90,   153,  153,
+  216,  216,  279,  279,  342,  342,  405,  405,  468,  468,  531,  531,  594,
+  594,  657,  657,  720,  720,  783,  783,  846,  846,  909,  909,  972,  972,
+  1035, 1035, 1098, 1098, 1161, 1161, 1224, 1224, 1287, 1287, 1350, 1350, 1413,
+  1413, 1476, 1476, 1539, 1539, 1602, 1602, 1665, 1665, 1728, 1728, 1728, 28,
+  28,   28,   91,   91,   154,  154,  217,  217,  280,  280,  343,  343,  406,
+  406,  469,  469,  532,  532,  595,  595,  658,  658,  721,  721,  784,  784,
+  847,  847,  910,  910,  973,  973,  1036, 1036, 1099, 1099, 1162, 1162, 1225,
+  1225, 1288, 1288, 1351, 1351, 1414, 1414, 1477, 1477, 1540, 1540, 1603, 1603,
+  1666, 1666, 1729, 1729, 1792, 1792, 1792, 29,   29,   29,   92,   92,   155,
+  155,  218,  218,  281,  281,  344,  344,  407,  407,  470,  470,  533,  533,
+  596,  596,  659,  659,  722,  722,  785,  785,  848,  848,  911,  911,  974,
+  974,  1037, 1037, 1100, 1100, 1163, 1163, 1226, 1226, 1289, 1289, 1352, 1352,
+  1415, 1415, 1478, 1478, 1541, 1541, 1604, 1604, 1667, 1667, 1730, 1730, 1793,
+  1793, 1856, 1856, 1856, 30,   30,   30,   93,   93,   156,  156,  219,  219,
+  282,  282,  345,  345,  408,  408,  471,  471,  534,  534,  597,  597,  660,
+  660,  723,  723,  786,  786,  849,  849,  912,  912,  975,  975,  1038, 1038,
+  1101, 1101, 1164, 1164, 1227, 1227, 1290, 1290, 1353, 1353, 1416, 1416, 1479,
+  1479, 1542, 1542, 1605, 1605, 1668, 1668, 1731, 1731, 1794, 1794, 1857, 1857,
+  1920, 1920, 1920, 31,   31,   31,   94,   94,   157,  157,  220,  220,  283,
+  283,  346,  346,  409,  409,  472,  472,  535,  535,  598,  598,  661,  661,
+  724,  724,  787,  787,  850,  850,  913,  913,  976,  976,  1039, 1039, 1102,
+  1102, 1165, 1165, 1228, 1228, 1291, 1291, 1354, 1354, 1417, 1417, 1480, 1480,
+  1543, 1543, 1606, 1606, 1669, 1669, 1732, 1732, 1795, 1795, 1858, 1858, 1921,
+  1921, 1984, 32,   32,   32,   95,   95,   158,  158,  221,  221,  284,  284,
+  347,  347,  410,  410,  473,  473,  536,  536,  599,  599,  662,  662,  725,
+  725,  788,  788,  851,  851,  914,  914,  977,  977,  1040, 1040, 1103, 1103,
+  1166, 1166, 1229, 1229, 1292, 1292, 1355, 1355, 1418, 1418, 1481, 1481, 1544,
+  1544, 1607, 1607, 1670, 1670, 1733, 1733, 1796, 1796, 1859, 1859, 1922, 1922,
+  1985, 33,   33,   33,   96,   96,   159,  159,  222,  222,  285,  285,  348,
+  348,  411,  411,  474,  474,  537,  537,  600,  600,  663,  663,  726,  726,
+  789,  789,  852,  852,  915,  915,  978,  978,  1041, 1041, 1104, 1104, 1167,
+  1167, 1230, 1230, 1293, 1293, 1356, 1356, 1419, 1419, 1482, 1482, 1545, 1545,
+  1608, 1608, 1671, 1671, 1734, 1734, 1797, 1797, 1860, 1860, 1923, 1923, 1986,
+  34,   34,   34,   97,   97,   160,  160,  223,  223,  286,  286,  349,  349,
+  412,  412,  475,  475,  538,  538,  601,  601,  664,  664,  727,  727,  790,
+  790,  853,  853,  916,  916,  979,  979,  1042, 1042, 1105, 1105, 1168, 1168,
+  1231, 1231, 1294, 1294, 1357, 1357, 1420, 1420, 1483, 1483, 1546, 1546, 1609,
+  1609, 1672, 1672, 1735, 1735, 1798, 1798, 1861, 1861, 1924, 1924, 1987, 35,
+  35,   35,   98,   98,   161,  161,  224,  224,  287,  287,  350,  350,  413,
+  413,  476,  476,  539,  539,  602,  602,  665,  665,  728,  728,  791,  791,
+  854,  854,  917,  917,  980,  980,  1043, 1043, 1106, 1106, 1169, 1169, 1232,
+  1232, 1295, 1295, 1358, 1358, 1421, 1421, 1484, 1484, 1547, 1547, 1610, 1610,
+  1673, 1673, 1736, 1736, 1799, 1799, 1862, 1862, 1925, 1925, 1988, 36,   36,
+  36,   99,   99,   162,  162,  225,  225,  288,  288,  351,  351,  414,  414,
+  477,  477,  540,  540,  603,  603,  666,  666,  729,  729,  792,  792,  855,
+  855,  918,  918,  981,  981,  1044, 1044, 1107, 1107, 1170, 1170, 1233, 1233,
+  1296, 1296, 1359, 1359, 1422, 1422, 1485, 1485, 1548, 1548, 1611, 1611, 1674,
+  1674, 1737, 1737, 1800, 1800, 1863, 1863, 1926, 1926, 1989, 37,   37,   37,
+  100,  100,  163,  163,  226,  226,  289,  289,  352,  352,  415,  415,  478,
+  478,  541,  541,  604,  604,  667,  667,  730,  730,  793,  793,  856,  856,
+  919,  919,  982,  982,  1045, 1045, 1108, 1108, 1171, 1171, 1234, 1234, 1297,
+  1297, 1360, 1360, 1423, 1423, 1486, 1486, 1549, 1549, 1612, 1612, 1675, 1675,
+  1738, 1738, 1801, 1801, 1864, 1864, 1927, 1927, 1990, 38,   38,   38,   101,
+  101,  164,  164,  227,  227,  290,  290,  353,  353,  416,  416,  479,  479,
+  542,  542,  605,  605,  668,  668,  731,  731,  794,  794,  857,  857,  920,
+  920,  983,  983,  1046, 1046, 1109, 1109, 1172, 1172, 1235, 1235, 1298, 1298,
+  1361, 1361, 1424, 1424, 1487, 1487, 1550, 1550, 1613, 1613, 1676, 1676, 1739,
+  1739, 1802, 1802, 1865, 1865, 1928, 1928, 1991, 39,   39,   39,   102,  102,
+  165,  165,  228,  228,  291,  291,  354,  354,  417,  417,  480,  480,  543,
+  543,  606,  606,  669,  669,  732,  732,  795,  795,  858,  858,  921,  921,
+  984,  984,  1047, 1047, 1110, 1110, 1173, 1173, 1236, 1236, 1299, 1299, 1362,
+  1362, 1425, 1425, 1488, 1488, 1551, 1551, 1614, 1614, 1677, 1677, 1740, 1740,
+  1803, 1803, 1866, 1866, 1929, 1929, 1992, 40,   40,   40,   103,  103,  166,
+  166,  229,  229,  292,  292,  355,  355,  418,  418,  481,  481,  544,  544,
+  607,  607,  670,  670,  733,  733,  796,  796,  859,  859,  922,  922,  985,
+  985,  1048, 1048, 1111, 1111, 1174, 1174, 1237, 1237, 1300, 1300, 1363, 1363,
+  1426, 1426, 1489, 1489, 1552, 1552, 1615, 1615, 1678, 1678, 1741, 1741, 1804,
+  1804, 1867, 1867, 1930, 1930, 1993, 41,   41,   41,   104,  104,  167,  167,
+  230,  230,  293,  293,  356,  356,  419,  419,  482,  482,  545,  545,  608,
+  608,  671,  671,  734,  734,  797,  797,  860,  860,  923,  923,  986,  986,
+  1049, 1049, 1112, 1112, 1175, 1175, 1238, 1238, 1301, 1301, 1364, 1364, 1427,
+  1427, 1490, 1490, 1553, 1553, 1616, 1616, 1679, 1679, 1742, 1742, 1805, 1805,
+  1868, 1868, 1931, 1931, 1994, 42,   42,   42,   105,  105,  168,  168,  231,
+  231,  294,  294,  357,  357,  420,  420,  483,  483,  546,  546,  609,  609,
+  672,  672,  735,  735,  798,  798,  861,  861,  924,  924,  987,  987,  1050,
+  1050, 1113, 1113, 1176, 1176, 1239, 1239, 1302, 1302, 1365, 1365, 1428, 1428,
+  1491, 1491, 1554, 1554, 1617, 1617, 1680, 1680, 1743, 1743, 1806, 1806, 1869,
+  1869, 1932, 1932, 1995, 43,   43,   43,   106,  106,  169,  169,  232,  232,
+  295,  295,  358,  358,  421,  421,  484,  484,  547,  547,  610,  610,  673,
+  673,  736,  736,  799,  799,  862,  862,  925,  925,  988,  988,  1051, 1051,
+  1114, 1114, 1177, 1177, 1240, 1240, 1303, 1303, 1366, 1366, 1429, 1429, 1492,
+  1492, 1555, 1555, 1618, 1618, 1681, 1681, 1744, 1744, 1807, 1807, 1870, 1870,
+  1933, 1933, 1996, 44,   44,   44,   107,  107,  170,  170,  233,  233,  296,
+  296,  359,  359,  422,  422,  485,  485,  548,  548,  611,  611,  674,  674,
+  737,  737,  800,  800,  863,  863,  926,  926,  989,  989,  1052, 1052, 1115,
+  1115, 1178, 1178, 1241, 1241, 1304, 1304, 1367, 1367, 1430, 1430, 1493, 1493,
+  1556, 1556, 1619, 1619, 1682, 1682, 1745, 1745, 1808, 1808, 1871, 1871, 1934,
+  1934, 1997, 45,   45,   45,   108,  108,  171,  171,  234,  234,  297,  297,
+  360,  360,  423,  423,  486,  486,  549,  549,  612,  612,  675,  675,  738,
+  738,  801,  801,  864,  864,  927,  927,  990,  990,  1053, 1053, 1116, 1116,
+  1179, 1179, 1242, 1242, 1305, 1305, 1368, 1368, 1431, 1431, 1494, 1494, 1557,
+  1557, 1620, 1620, 1683, 1683, 1746, 1746, 1809, 1809, 1872, 1872, 1935, 1935,
+  1998, 46,   46,   46,   109,  109,  172,  172,  235,  235,  298,  298,  361,
+  361,  424,  424,  487,  487,  550,  550,  613,  613,  676,  676,  739,  739,
+  802,  802,  865,  865,  928,  928,  991,  991,  1054, 1054, 1117, 1117, 1180,
+  1180, 1243, 1243, 1306, 1306, 1369, 1369, 1432, 1432, 1495, 1495, 1558, 1558,
+  1621, 1621, 1684, 1684, 1747, 1747, 1810, 1810, 1873, 1873, 1936, 1936, 1999,
+  47,   47,   47,   110,  110,  173,  173,  236,  236,  299,  299,  362,  362,
+  425,  425,  488,  488,  551,  551,  614,  614,  677,  677,  740,  740,  803,
+  803,  866,  866,  929,  929,  992,  992,  1055, 1055, 1118, 1118, 1181, 1181,
+  1244, 1244, 1307, 1307, 1370, 1370, 1433, 1433, 1496, 1496, 1559, 1559, 1622,
+  1622, 1685, 1685, 1748, 1748, 1811, 1811, 1874, 1874, 1937, 1937, 2000, 48,
+  48,   48,   111,  111,  174,  174,  237,  237,  300,  300,  363,  363,  426,
+  426,  489,  489,  552,  552,  615,  615,  678,  678,  741,  741,  804,  804,
+  867,  867,  930,  930,  993,  993,  1056, 1056, 1119, 1119, 1182, 1182, 1245,
+  1245, 1308, 1308, 1371, 1371, 1434, 1434, 1497, 1497, 1560, 1560, 1623, 1623,
+  1686, 1686, 1749, 1749, 1812, 1812, 1875, 1875, 1938, 1938, 2001, 49,   49,
+  49,   112,  112,  175,  175,  238,  238,  301,  301,  364,  364,  427,  427,
+  490,  490,  553,  553,  616,  616,  679,  679,  742,  742,  805,  805,  868,
+  868,  931,  931,  994,  994,  1057, 1057, 1120, 1120, 1183, 1183, 1246, 1246,
+  1309, 1309, 1372, 1372, 1435, 1435, 1498, 1498, 1561, 1561, 1624, 1624, 1687,
+  1687, 1750, 1750, 1813, 1813, 1876, 1876, 1939, 1939, 2002, 50,   50,   50,
+  113,  113,  176,  176,  239,  239,  302,  302,  365,  365,  428,  428,  491,
+  491,  554,  554,  617,  617,  680,  680,  743,  743,  806,  806,  869,  869,
+  932,  932,  995,  995,  1058, 1058, 1121, 1121, 1184, 1184, 1247, 1247, 1310,
+  1310, 1373, 1373, 1436, 1436, 1499, 1499, 1562, 1562, 1625, 1625, 1688, 1688,
+  1751, 1751, 1814, 1814, 1877, 1877, 1940, 1940, 2003, 51,   51,   51,   114,
+  114,  177,  177,  240,  240,  303,  303,  366,  366,  429,  429,  492,  492,
+  555,  555,  618,  618,  681,  681,  744,  744,  807,  807,  870,  870,  933,
+  933,  996,  996,  1059, 1059, 1122, 1122, 1185, 1185, 1248, 1248, 1311, 1311,
+  1374, 1374, 1437, 1437, 1500, 1500, 1563, 1563, 1626, 1626, 1689, 1689, 1752,
+  1752, 1815, 1815, 1878, 1878, 1941, 1941, 2004, 52,   52,   52,   115,  115,
+  178,  178,  241,  241,  304,  304,  367,  367,  430,  430,  493,  493,  556,
+  556,  619,  619,  682,  682,  745,  745,  808,  808,  871,  871,  934,  934,
+  997,  997,  1060, 1060, 1123, 1123, 1186, 1186, 1249, 1249, 1312, 1312, 1375,
+  1375, 1438, 1438, 1501, 1501, 1564, 1564, 1627, 1627, 1690, 1690, 1753, 1753,
+  1816, 1816, 1879, 1879, 1942, 1942, 2005, 53,   53,   53,   116,  116,  179,
+  179,  242,  242,  305,  305,  368,  368,  431,  431,  494,  494,  557,  557,
+  620,  620,  683,  683,  746,  746,  809,  809,  872,  872,  935,  935,  998,
+  998,  1061, 1061, 1124, 1124, 1187, 1187, 1250, 1250, 1313, 1313, 1376, 1376,
+  1439, 1439, 1502, 1502, 1565, 1565, 1628, 1628, 1691, 1691, 1754, 1754, 1817,
+  1817, 1880, 1880, 1943, 1943, 2006, 54,   54,   54,   117,  117,  180,  180,
+  243,  243,  306,  306,  369,  369,  432,  432,  495,  495,  558,  558,  621,
+  621,  684,  684,  747,  747,  810,  810,  873,  873,  936,  936,  999,  999,
+  1062, 1062, 1125, 1125, 1188, 1188, 1251, 1251, 1314, 1314, 1377, 1377, 1440,
+  1440, 1503, 1503, 1566, 1566, 1629, 1629, 1692, 1692, 1755, 1755, 1818, 1818,
+  1881, 1881, 1944, 1944, 2007, 55,   55,   55,   118,  118,  181,  181,  244,
+  244,  307,  307,  370,  370,  433,  433,  496,  496,  559,  559,  622,  622,
+  685,  685,  748,  748,  811,  811,  874,  874,  937,  937,  1000, 1000, 1063,
+  1063, 1126, 1126, 1189, 1189, 1252, 1252, 1315, 1315, 1378, 1378, 1441, 1441,
+  1504, 1504, 1567, 1567, 1630, 1630, 1693, 1693, 1756, 1756, 1819, 1819, 1882,
+  1882, 1945, 1945, 2008, 56,   56,   56,   119,  119,  182,  182,  245,  245,
+  308,  308,  371,  371,  434,  434,  497,  497,  560,  560,  623,  623,  686,
+  686,  749,  749,  812,  812,  875,  875,  938,  938,  1001, 1001, 1064, 1064,
+  1127, 1127, 1190, 1190, 1253, 1253, 1316, 1316, 1379, 1379, 1442, 1442, 1505,
+  1505, 1568, 1568, 1631, 1631, 1694, 1694, 1757, 1757, 1820, 1820, 1883, 1883,
+  1946, 1946, 2009, 57,   57,   57,   120,  120,  183,  183,  246,  246,  309,
+  309,  372,  372,  435,  435,  498,  498,  561,  561,  624,  624,  687,  687,
+  750,  750,  813,  813,  876,  876,  939,  939,  1002, 1002, 1065, 1065, 1128,
+  1128, 1191, 1191, 1254, 1254, 1317, 1317, 1380, 1380, 1443, 1443, 1506, 1506,
+  1569, 1569, 1632, 1632, 1695, 1695, 1758, 1758, 1821, 1821, 1884, 1884, 1947,
+  1947, 2010, 58,   58,   58,   121,  121,  184,  184,  247,  247,  310,  310,
+  373,  373,  436,  436,  499,  499,  562,  562,  625,  625,  688,  688,  751,
+  751,  814,  814,  877,  877,  940,  940,  1003, 1003, 1066, 1066, 1129, 1129,
+  1192, 1192, 1255, 1255, 1318, 1318, 1381, 1381, 1444, 1444, 1507, 1507, 1570,
+  1570, 1633, 1633, 1696, 1696, 1759, 1759, 1822, 1822, 1885, 1885, 1948, 1948,
+  2011, 59,   59,   59,   122,  122,  185,  185,  248,  248,  311,  311,  374,
+  374,  437,  437,  500,  500,  563,  563,  626,  626,  689,  689,  752,  752,
+  815,  815,  878,  878,  941,  941,  1004, 1004, 1067, 1067, 1130, 1130, 1193,
+  1193, 1256, 1256, 1319, 1319, 1382, 1382, 1445, 1445, 1508, 1508, 1571, 1571,
+  1634, 1634, 1697, 1697, 1760, 1760, 1823, 1823, 1886, 1886, 1949, 1949, 2012,
+  60,   60,   60,   123,  123,  186,  186,  249,  249,  312,  312,  375,  375,
+  438,  438,  501,  501,  564,  564,  627,  627,  690,  690,  753,  753,  816,
+  816,  879,  879,  942,  942,  1005, 1005, 1068, 1068, 1131, 1131, 1194, 1194,
+  1257, 1257, 1320, 1320, 1383, 1383, 1446, 1446, 1509, 1509, 1572, 1572, 1635,
+  1635, 1698, 1698, 1761, 1761, 1824, 1824, 1887, 1887, 1950, 1950, 2013, 61,
+  61,   61,   124,  124,  187,  187,  250,  250,  313,  313,  376,  376,  439,
+  439,  502,  502,  565,  565,  628,  628,  691,  691,  754,  754,  817,  817,
+  880,  880,  943,  943,  1006, 1006, 1069, 1069, 1132, 1132, 1195, 1195, 1258,
+  1258, 1321, 1321, 1384, 1384, 1447, 1447, 1510, 1510, 1573, 1573, 1636, 1636,
+  1699, 1699, 1762, 1762, 1825, 1825, 1888, 1888, 1951, 1951, 2014, 62,   62,
+  62,   125,  125,  188,  188,  251,  251,  314,  314,  377,  377,  440,  440,
+  503,  503,  566,  566,  629,  629,  692,  692,  755,  755,  818,  818,  881,
+  881,  944,  944,  1007, 1007, 1070, 1070, 1133, 1133, 1196, 1196, 1259, 1259,
+  1322, 1322, 1385, 1385, 1448, 1448, 1511, 1511, 1574, 1574, 1637, 1637, 1700,
+  1700, 1763, 1763, 1826, 1826, 1889, 1889, 1952, 1952, 2015, 63,   126,  126,
+  189,  189,  252,  252,  315,  315,  378,  378,  441,  441,  504,  504,  567,
+  567,  630,  630,  693,  693,  756,  756,  819,  819,  882,  882,  945,  945,
+  1008, 1008, 1071, 1071, 1134, 1134, 1197, 1197, 1260, 1260, 1323, 1323, 1386,
+  1386, 1449, 1449, 1512, 1512, 1575, 1575, 1638, 1638, 1701, 1701, 1764, 1764,
+  1827, 1827, 1890, 1890, 1953, 1953, 2016, 127,  190,  190,  253,  253,  316,
+  316,  379,  379,  442,  442,  505,  505,  568,  568,  631,  631,  694,  694,
+  757,  757,  820,  820,  883,  883,  946,  946,  1009, 1009, 1072, 1072, 1135,
+  1135, 1198, 1198, 1261, 1261, 1324, 1324, 1387, 1387, 1450, 1450, 1513, 1513,
+  1576, 1576, 1639, 1639, 1702, 1702, 1765, 1765, 1828, 1828, 1891, 1891, 1954,
+  1954, 2017, 191,  254,  254,  317,  317,  380,  380,  443,  443,  506,  506,
+  569,  569,  632,  632,  695,  695,  758,  758,  821,  821,  884,  884,  947,
+  947,  1010, 1010, 1073, 1073, 1136, 1136, 1199, 1199, 1262, 1262, 1325, 1325,
+  1388, 1388, 1451, 1451, 1514, 1514, 1577, 1577, 1640, 1640, 1703, 1703, 1766,
+  1766, 1829, 1829, 1892, 1892, 1955, 1955, 2018, 255,  318,  318,  381,  381,
+  444,  444,  507,  507,  570,  570,  633,  633,  696,  696,  759,  759,  822,
+  822,  885,  885,  948,  948,  1011, 1011, 1074, 1074, 1137, 1137, 1200, 1200,
+  1263, 1263, 1326, 1326, 1389, 1389, 1452, 1452, 1515, 1515, 1578, 1578, 1641,
+  1641, 1704, 1704, 1767, 1767, 1830, 1830, 1893, 1893, 1956, 1956, 2019, 319,
+  382,  382,  445,  445,  508,  508,  571,  571,  634,  634,  697,  697,  760,
+  760,  823,  823,  886,  886,  949,  949,  1012, 1012, 1075, 1075, 1138, 1138,
+  1201, 1201, 1264, 1264, 1327, 1327, 1390, 1390, 1453, 1453, 1516, 1516, 1579,
+  1579, 1642, 1642, 1705, 1705, 1768, 1768, 1831, 1831, 1894, 1894, 1957, 1957,
+  2020, 383,  446,  446,  509,  509,  572,  572,  635,  635,  698,  698,  761,
+  761,  824,  824,  887,  887,  950,  950,  1013, 1013, 1076, 1076, 1139, 1139,
+  1202, 1202, 1265, 1265, 1328, 1328, 1391, 1391, 1454, 1454, 1517, 1517, 1580,
+  1580, 1643, 1643, 1706, 1706, 1769, 1769, 1832, 1832, 1895, 1895, 1958, 1958,
+  2021, 447,  510,  510,  573,  573,  636,  636,  699,  699,  762,  762,  825,
+  825,  888,  888,  951,  951,  1014, 1014, 1077, 1077, 1140, 1140, 1203, 1203,
+  1266, 1266, 1329, 1329, 1392, 1392, 1455, 1455, 1518, 1518, 1581, 1581, 1644,
+  1644, 1707, 1707, 1770, 1770, 1833, 1833, 1896, 1896, 1959, 1959, 2022, 511,
+  574,  574,  637,  637,  700,  700,  763,  763,  826,  826,  889,  889,  952,
+  952,  1015, 1015, 1078, 1078, 1141, 1141, 1204, 1204, 1267, 1267, 1330, 1330,
+  1393, 1393, 1456, 1456, 1519, 1519, 1582, 1582, 1645, 1645, 1708, 1708, 1771,
+  1771, 1834, 1834, 1897, 1897, 1960, 1960, 2023, 575,  638,  638,  701,  701,
+  764,  764,  827,  827,  890,  890,  953,  953,  1016, 1016, 1079, 1079, 1142,
+  1142, 1205, 1205, 1268, 1268, 1331, 1331, 1394, 1394, 1457, 1457, 1520, 1520,
+  1583, 1583, 1646, 1646, 1709, 1709, 1772, 1772, 1835, 1835, 1898, 1898, 1961,
+  1961, 2024, 639,  702,  702,  765,  765,  828,  828,  891,  891,  954,  954,
+  1017, 1017, 1080, 1080, 1143, 1143, 1206, 1206, 1269, 1269, 1332, 1332, 1395,
+  1395, 1458, 1458, 1521, 1521, 1584, 1584, 1647, 1647, 1710, 1710, 1773, 1773,
+  1836, 1836, 1899, 1899, 1962, 1962, 2025, 703,  766,  766,  829,  829,  892,
+  892,  955,  955,  1018, 1018, 1081, 1081, 1144, 1144, 1207, 1207, 1270, 1270,
+  1333, 1333, 1396, 1396, 1459, 1459, 1522, 1522, 1585, 1585, 1648, 1648, 1711,
+  1711, 1774, 1774, 1837, 1837, 1900, 1900, 1963, 1963, 2026, 767,  830,  830,
+  893,  893,  956,  956,  1019, 1019, 1082, 1082, 1145, 1145, 1208, 1208, 1271,
+  1271, 1334, 1334, 1397, 1397, 1460, 1460, 1523, 1523, 1586, 1586, 1649, 1649,
+  1712, 1712, 1775, 1775, 1838, 1838, 1901, 1901, 1964, 1964, 2027, 831,  894,
+  894,  957,  957,  1020, 1020, 1083, 1083, 1146, 1146, 1209, 1209, 1272, 1272,
+  1335, 1335, 1398, 1398, 1461, 1461, 1524, 1524, 1587, 1587, 1650, 1650, 1713,
+  1713, 1776, 1776, 1839, 1839, 1902, 1902, 1965, 1965, 2028, 895,  958,  958,
+  1021, 1021, 1084, 1084, 1147, 1147, 1210, 1210, 1273, 1273, 1336, 1336, 1399,
+  1399, 1462, 1462, 1525, 1525, 1588, 1588, 1651, 1651, 1714, 1714, 1777, 1777,
+  1840, 1840, 1903, 1903, 1966, 1966, 2029, 959,  1022, 1022, 1085, 1085, 1148,
+  1148, 1211, 1211, 1274, 1274, 1337, 1337, 1400, 1400, 1463, 1463, 1526, 1526,
+  1589, 1589, 1652, 1652, 1715, 1715, 1778, 1778, 1841, 1841, 1904, 1904, 1967,
+  1967, 2030, 1023, 1086, 1086, 1149, 1149, 1212, 1212, 1275, 1275, 1338, 1338,
+  1401, 1401, 1464, 1464, 1527, 1527, 1590, 1590, 1653, 1653, 1716, 1716, 1779,
+  1779, 1842, 1842, 1905, 1905, 1968, 1968, 2031, 1087, 1150, 1150, 1213, 1213,
+  1276, 1276, 1339, 1339, 1402, 1402, 1465, 1465, 1528, 1528, 1591, 1591, 1654,
+  1654, 1717, 1717, 1780, 1780, 1843, 1843, 1906, 1906, 1969, 1969, 2032, 1151,
+  1214, 1214, 1277, 1277, 1340, 1340, 1403, 1403, 1466, 1466, 1529, 1529, 1592,
+  1592, 1655, 1655, 1718, 1718, 1781, 1781, 1844, 1844, 1907, 1907, 1970, 1970,
+  2033, 1215, 1278, 1278, 1341, 1341, 1404, 1404, 1467, 1467, 1530, 1530, 1593,
+  1593, 1656, 1656, 1719, 1719, 1782, 1782, 1845, 1845, 1908, 1908, 1971, 1971,
+  2034, 1279, 1342, 1342, 1405, 1405, 1468, 1468, 1531, 1531, 1594, 1594, 1657,
+  1657, 1720, 1720, 1783, 1783, 1846, 1846, 1909, 1909, 1972, 1972, 2035, 1343,
+  1406, 1406, 1469, 1469, 1532, 1532, 1595, 1595, 1658, 1658, 1721, 1721, 1784,
+  1784, 1847, 1847, 1910, 1910, 1973, 1973, 2036, 1407, 1470, 1470, 1533, 1533,
+  1596, 1596, 1659, 1659, 1722, 1722, 1785, 1785, 1848, 1848, 1911, 1911, 1974,
+  1974, 2037, 1471, 1534, 1534, 1597, 1597, 1660, 1660, 1723, 1723, 1786, 1786,
+  1849, 1849, 1912, 1912, 1975, 1975, 2038, 1535, 1598, 1598, 1661, 1661, 1724,
+  1724, 1787, 1787, 1850, 1850, 1913, 1913, 1976, 1976, 2039, 1599, 1662, 1662,
+  1725, 1725, 1788, 1788, 1851, 1851, 1914, 1914, 1977, 1977, 2040, 1663, 1726,
+  1726, 1789, 1789, 1852, 1852, 1915, 1915, 1978, 1978, 2041, 1727, 1790, 1790,
+  1853, 1853, 1916, 1916, 1979, 1979, 2042, 1791, 1854, 1854, 1917, 1917, 1980,
+  1980, 2043, 1855, 1918, 1918, 1981, 1981, 2044, 1919, 1982, 1982, 2045, 1983,
+  2046,
+};
+
+DECLARE_ALIGNED(16, static const int16_t,
                 default_scan_64x64_neighbors[4097 * MAX_NEIGHBORS]) = {
   0,    0,    0,    0,    0,    0,    1,    64,   1,    1,    64,   64,   2,
   65,   65,   128,  66,   129,  2,    2,    128,  128,  3,    66,   129,  192,
@@ -5398,6 +6360,328 @@
 };
 
 #if CONFIG_TX64X64
+DECLARE_ALIGNED(16, static const int16_t, av1_default_iscan_32x64[2048]) = {
+  0,    1,    3,    6,    10,   15,   21,   28,   36,   45,   55,   66,   78,
+  91,   105,  120,  136,  153,  171,  190,  210,  231,  253,  276,  300,  325,
+  351,  378,  406,  435,  465,  496,  2,    4,    7,    11,   16,   22,   29,
+  37,   46,   56,   67,   79,   92,   106,  121,  137,  154,  172,  191,  211,
+  232,  254,  277,  301,  326,  352,  379,  407,  436,  466,  497,  528,  5,
+  8,    12,   17,   23,   30,   38,   47,   57,   68,   80,   93,   107,  122,
+  138,  155,  173,  192,  212,  233,  255,  278,  302,  327,  353,  380,  408,
+  437,  467,  498,  529,  560,  9,    13,   18,   24,   31,   39,   48,   58,
+  69,   81,   94,   108,  123,  139,  156,  174,  193,  213,  234,  256,  279,
+  303,  328,  354,  381,  409,  438,  468,  499,  530,  561,  592,  14,   19,
+  25,   32,   40,   49,   59,   70,   82,   95,   109,  124,  140,  157,  175,
+  194,  214,  235,  257,  280,  304,  329,  355,  382,  410,  439,  469,  500,
+  531,  562,  593,  624,  20,   26,   33,   41,   50,   60,   71,   83,   96,
+  110,  125,  141,  158,  176,  195,  215,  236,  258,  281,  305,  330,  356,
+  383,  411,  440,  470,  501,  532,  563,  594,  625,  656,  27,   34,   42,
+  51,   61,   72,   84,   97,   111,  126,  142,  159,  177,  196,  216,  237,
+  259,  282,  306,  331,  357,  384,  412,  441,  471,  502,  533,  564,  595,
+  626,  657,  688,  35,   43,   52,   62,   73,   85,   98,   112,  127,  143,
+  160,  178,  197,  217,  238,  260,  283,  307,  332,  358,  385,  413,  442,
+  472,  503,  534,  565,  596,  627,  658,  689,  720,  44,   53,   63,   74,
+  86,   99,   113,  128,  144,  161,  179,  198,  218,  239,  261,  284,  308,
+  333,  359,  386,  414,  443,  473,  504,  535,  566,  597,  628,  659,  690,
+  721,  752,  54,   64,   75,   87,   100,  114,  129,  145,  162,  180,  199,
+  219,  240,  262,  285,  309,  334,  360,  387,  415,  444,  474,  505,  536,
+  567,  598,  629,  660,  691,  722,  753,  784,  65,   76,   88,   101,  115,
+  130,  146,  163,  181,  200,  220,  241,  263,  286,  310,  335,  361,  388,
+  416,  445,  475,  506,  537,  568,  599,  630,  661,  692,  723,  754,  785,
+  816,  77,   89,   102,  116,  131,  147,  164,  182,  201,  221,  242,  264,
+  287,  311,  336,  362,  389,  417,  446,  476,  507,  538,  569,  600,  631,
+  662,  693,  724,  755,  786,  817,  848,  90,   103,  117,  132,  148,  165,
+  183,  202,  222,  243,  265,  288,  312,  337,  363,  390,  418,  447,  477,
+  508,  539,  570,  601,  632,  663,  694,  725,  756,  787,  818,  849,  880,
+  104,  118,  133,  149,  166,  184,  203,  223,  244,  266,  289,  313,  338,
+  364,  391,  419,  448,  478,  509,  540,  571,  602,  633,  664,  695,  726,
+  757,  788,  819,  850,  881,  912,  119,  134,  150,  167,  185,  204,  224,
+  245,  267,  290,  314,  339,  365,  392,  420,  449,  479,  510,  541,  572,
+  603,  634,  665,  696,  727,  758,  789,  820,  851,  882,  913,  944,  135,
+  151,  168,  186,  205,  225,  246,  268,  291,  315,  340,  366,  393,  421,
+  450,  480,  511,  542,  573,  604,  635,  666,  697,  728,  759,  790,  821,
+  852,  883,  914,  945,  976,  152,  169,  187,  206,  226,  247,  269,  292,
+  316,  341,  367,  394,  422,  451,  481,  512,  543,  574,  605,  636,  667,
+  698,  729,  760,  791,  822,  853,  884,  915,  946,  977,  1008, 170,  188,
+  207,  227,  248,  270,  293,  317,  342,  368,  395,  423,  452,  482,  513,
+  544,  575,  606,  637,  668,  699,  730,  761,  792,  823,  854,  885,  916,
+  947,  978,  1009, 1040, 189,  208,  228,  249,  271,  294,  318,  343,  369,
+  396,  424,  453,  483,  514,  545,  576,  607,  638,  669,  700,  731,  762,
+  793,  824,  855,  886,  917,  948,  979,  1010, 1041, 1072, 209,  229,  250,
+  272,  295,  319,  344,  370,  397,  425,  454,  484,  515,  546,  577,  608,
+  639,  670,  701,  732,  763,  794,  825,  856,  887,  918,  949,  980,  1011,
+  1042, 1073, 1104, 230,  251,  273,  296,  320,  345,  371,  398,  426,  455,
+  485,  516,  547,  578,  609,  640,  671,  702,  733,  764,  795,  826,  857,
+  888,  919,  950,  981,  1012, 1043, 1074, 1105, 1136, 252,  274,  297,  321,
+  346,  372,  399,  427,  456,  486,  517,  548,  579,  610,  641,  672,  703,
+  734,  765,  796,  827,  858,  889,  920,  951,  982,  1013, 1044, 1075, 1106,
+  1137, 1168, 275,  298,  322,  347,  373,  400,  428,  457,  487,  518,  549,
+  580,  611,  642,  673,  704,  735,  766,  797,  828,  859,  890,  921,  952,
+  983,  1014, 1045, 1076, 1107, 1138, 1169, 1200, 299,  323,  348,  374,  401,
+  429,  458,  488,  519,  550,  581,  612,  643,  674,  705,  736,  767,  798,
+  829,  860,  891,  922,  953,  984,  1015, 1046, 1077, 1108, 1139, 1170, 1201,
+  1232, 324,  349,  375,  402,  430,  459,  489,  520,  551,  582,  613,  644,
+  675,  706,  737,  768,  799,  830,  861,  892,  923,  954,  985,  1016, 1047,
+  1078, 1109, 1140, 1171, 1202, 1233, 1264, 350,  376,  403,  431,  460,  490,
+  521,  552,  583,  614,  645,  676,  707,  738,  769,  800,  831,  862,  893,
+  924,  955,  986,  1017, 1048, 1079, 1110, 1141, 1172, 1203, 1234, 1265, 1296,
+  377,  404,  432,  461,  491,  522,  553,  584,  615,  646,  677,  708,  739,
+  770,  801,  832,  863,  894,  925,  956,  987,  1018, 1049, 1080, 1111, 1142,
+  1173, 1204, 1235, 1266, 1297, 1328, 405,  433,  462,  492,  523,  554,  585,
+  616,  647,  678,  709,  740,  771,  802,  833,  864,  895,  926,  957,  988,
+  1019, 1050, 1081, 1112, 1143, 1174, 1205, 1236, 1267, 1298, 1329, 1360, 434,
+  463,  493,  524,  555,  586,  617,  648,  679,  710,  741,  772,  803,  834,
+  865,  896,  927,  958,  989,  1020, 1051, 1082, 1113, 1144, 1175, 1206, 1237,
+  1268, 1299, 1330, 1361, 1392, 464,  494,  525,  556,  587,  618,  649,  680,
+  711,  742,  773,  804,  835,  866,  897,  928,  959,  990,  1021, 1052, 1083,
+  1114, 1145, 1176, 1207, 1238, 1269, 1300, 1331, 1362, 1393, 1424, 495,  526,
+  557,  588,  619,  650,  681,  712,  743,  774,  805,  836,  867,  898,  929,
+  960,  991,  1022, 1053, 1084, 1115, 1146, 1177, 1208, 1239, 1270, 1301, 1332,
+  1363, 1394, 1425, 1456, 527,  558,  589,  620,  651,  682,  713,  744,  775,
+  806,  837,  868,  899,  930,  961,  992,  1023, 1054, 1085, 1116, 1147, 1178,
+  1209, 1240, 1271, 1302, 1333, 1364, 1395, 1426, 1457, 1488, 559,  590,  621,
+  652,  683,  714,  745,  776,  807,  838,  869,  900,  931,  962,  993,  1024,
+  1055, 1086, 1117, 1148, 1179, 1210, 1241, 1272, 1303, 1334, 1365, 1396, 1427,
+  1458, 1489, 1520, 591,  622,  653,  684,  715,  746,  777,  808,  839,  870,
+  901,  932,  963,  994,  1025, 1056, 1087, 1118, 1149, 1180, 1211, 1242, 1273,
+  1304, 1335, 1366, 1397, 1428, 1459, 1490, 1521, 1552, 623,  654,  685,  716,
+  747,  778,  809,  840,  871,  902,  933,  964,  995,  1026, 1057, 1088, 1119,
+  1150, 1181, 1212, 1243, 1274, 1305, 1336, 1367, 1398, 1429, 1460, 1491, 1522,
+  1553, 1583, 655,  686,  717,  748,  779,  810,  841,  872,  903,  934,  965,
+  996,  1027, 1058, 1089, 1120, 1151, 1182, 1213, 1244, 1275, 1306, 1337, 1368,
+  1399, 1430, 1461, 1492, 1523, 1554, 1584, 1613, 687,  718,  749,  780,  811,
+  842,  873,  904,  935,  966,  997,  1028, 1059, 1090, 1121, 1152, 1183, 1214,
+  1245, 1276, 1307, 1338, 1369, 1400, 1431, 1462, 1493, 1524, 1555, 1585, 1614,
+  1642, 719,  750,  781,  812,  843,  874,  905,  936,  967,  998,  1029, 1060,
+  1091, 1122, 1153, 1184, 1215, 1246, 1277, 1308, 1339, 1370, 1401, 1432, 1463,
+  1494, 1525, 1556, 1586, 1615, 1643, 1670, 751,  782,  813,  844,  875,  906,
+  937,  968,  999,  1030, 1061, 1092, 1123, 1154, 1185, 1216, 1247, 1278, 1309,
+  1340, 1371, 1402, 1433, 1464, 1495, 1526, 1557, 1587, 1616, 1644, 1671, 1697,
+  783,  814,  845,  876,  907,  938,  969,  1000, 1031, 1062, 1093, 1124, 1155,
+  1186, 1217, 1248, 1279, 1310, 1341, 1372, 1403, 1434, 1465, 1496, 1527, 1558,
+  1588, 1617, 1645, 1672, 1698, 1723, 815,  846,  877,  908,  939,  970,  1001,
+  1032, 1063, 1094, 1125, 1156, 1187, 1218, 1249, 1280, 1311, 1342, 1373, 1404,
+  1435, 1466, 1497, 1528, 1559, 1589, 1618, 1646, 1673, 1699, 1724, 1748, 847,
+  878,  909,  940,  971,  1002, 1033, 1064, 1095, 1126, 1157, 1188, 1219, 1250,
+  1281, 1312, 1343, 1374, 1405, 1436, 1467, 1498, 1529, 1560, 1590, 1619, 1647,
+  1674, 1700, 1725, 1749, 1772, 879,  910,  941,  972,  1003, 1034, 1065, 1096,
+  1127, 1158, 1189, 1220, 1251, 1282, 1313, 1344, 1375, 1406, 1437, 1468, 1499,
+  1530, 1561, 1591, 1620, 1648, 1675, 1701, 1726, 1750, 1773, 1795, 911,  942,
+  973,  1004, 1035, 1066, 1097, 1128, 1159, 1190, 1221, 1252, 1283, 1314, 1345,
+  1376, 1407, 1438, 1469, 1500, 1531, 1562, 1592, 1621, 1649, 1676, 1702, 1727,
+  1751, 1774, 1796, 1817, 943,  974,  1005, 1036, 1067, 1098, 1129, 1160, 1191,
+  1222, 1253, 1284, 1315, 1346, 1377, 1408, 1439, 1470, 1501, 1532, 1563, 1593,
+  1622, 1650, 1677, 1703, 1728, 1752, 1775, 1797, 1818, 1838, 975,  1006, 1037,
+  1068, 1099, 1130, 1161, 1192, 1223, 1254, 1285, 1316, 1347, 1378, 1409, 1440,
+  1471, 1502, 1533, 1564, 1594, 1623, 1651, 1678, 1704, 1729, 1753, 1776, 1798,
+  1819, 1839, 1858, 1007, 1038, 1069, 1100, 1131, 1162, 1193, 1224, 1255, 1286,
+  1317, 1348, 1379, 1410, 1441, 1472, 1503, 1534, 1565, 1595, 1624, 1652, 1679,
+  1705, 1730, 1754, 1777, 1799, 1820, 1840, 1859, 1877, 1039, 1070, 1101, 1132,
+  1163, 1194, 1225, 1256, 1287, 1318, 1349, 1380, 1411, 1442, 1473, 1504, 1535,
+  1566, 1596, 1625, 1653, 1680, 1706, 1731, 1755, 1778, 1800, 1821, 1841, 1860,
+  1878, 1895, 1071, 1102, 1133, 1164, 1195, 1226, 1257, 1288, 1319, 1350, 1381,
+  1412, 1443, 1474, 1505, 1536, 1567, 1597, 1626, 1654, 1681, 1707, 1732, 1756,
+  1779, 1801, 1822, 1842, 1861, 1879, 1896, 1912, 1103, 1134, 1165, 1196, 1227,
+  1258, 1289, 1320, 1351, 1382, 1413, 1444, 1475, 1506, 1537, 1568, 1598, 1627,
+  1655, 1682, 1708, 1733, 1757, 1780, 1802, 1823, 1843, 1862, 1880, 1897, 1913,
+  1928, 1135, 1166, 1197, 1228, 1259, 1290, 1321, 1352, 1383, 1414, 1445, 1476,
+  1507, 1538, 1569, 1599, 1628, 1656, 1683, 1709, 1734, 1758, 1781, 1803, 1824,
+  1844, 1863, 1881, 1898, 1914, 1929, 1943, 1167, 1198, 1229, 1260, 1291, 1322,
+  1353, 1384, 1415, 1446, 1477, 1508, 1539, 1570, 1600, 1629, 1657, 1684, 1710,
+  1735, 1759, 1782, 1804, 1825, 1845, 1864, 1882, 1899, 1915, 1930, 1944, 1957,
+  1199, 1230, 1261, 1292, 1323, 1354, 1385, 1416, 1447, 1478, 1509, 1540, 1571,
+  1601, 1630, 1658, 1685, 1711, 1736, 1760, 1783, 1805, 1826, 1846, 1865, 1883,
+  1900, 1916, 1931, 1945, 1958, 1970, 1231, 1262, 1293, 1324, 1355, 1386, 1417,
+  1448, 1479, 1510, 1541, 1572, 1602, 1631, 1659, 1686, 1712, 1737, 1761, 1784,
+  1806, 1827, 1847, 1866, 1884, 1901, 1917, 1932, 1946, 1959, 1971, 1982, 1263,
+  1294, 1325, 1356, 1387, 1418, 1449, 1480, 1511, 1542, 1573, 1603, 1632, 1660,
+  1687, 1713, 1738, 1762, 1785, 1807, 1828, 1848, 1867, 1885, 1902, 1918, 1933,
+  1947, 1960, 1972, 1983, 1993, 1295, 1326, 1357, 1388, 1419, 1450, 1481, 1512,
+  1543, 1574, 1604, 1633, 1661, 1688, 1714, 1739, 1763, 1786, 1808, 1829, 1849,
+  1868, 1886, 1903, 1919, 1934, 1948, 1961, 1973, 1984, 1994, 2003, 1327, 1358,
+  1389, 1420, 1451, 1482, 1513, 1544, 1575, 1605, 1634, 1662, 1689, 1715, 1740,
+  1764, 1787, 1809, 1830, 1850, 1869, 1887, 1904, 1920, 1935, 1949, 1962, 1974,
+  1985, 1995, 2004, 2012, 1359, 1390, 1421, 1452, 1483, 1514, 1545, 1576, 1606,
+  1635, 1663, 1690, 1716, 1741, 1765, 1788, 1810, 1831, 1851, 1870, 1888, 1905,
+  1921, 1936, 1950, 1963, 1975, 1986, 1996, 2005, 2013, 2020, 1391, 1422, 1453,
+  1484, 1515, 1546, 1577, 1607, 1636, 1664, 1691, 1717, 1742, 1766, 1789, 1811,
+  1832, 1852, 1871, 1889, 1906, 1922, 1937, 1951, 1964, 1976, 1987, 1997, 2006,
+  2014, 2021, 2027, 1423, 1454, 1485, 1516, 1547, 1578, 1608, 1637, 1665, 1692,
+  1718, 1743, 1767, 1790, 1812, 1833, 1853, 1872, 1890, 1907, 1923, 1938, 1952,
+  1965, 1977, 1988, 1998, 2007, 2015, 2022, 2028, 2033, 1455, 1486, 1517, 1548,
+  1579, 1609, 1638, 1666, 1693, 1719, 1744, 1768, 1791, 1813, 1834, 1854, 1873,
+  1891, 1908, 1924, 1939, 1953, 1966, 1978, 1989, 1999, 2008, 2016, 2023, 2029,
+  2034, 2038, 1487, 1518, 1549, 1580, 1610, 1639, 1667, 1694, 1720, 1745, 1769,
+  1792, 1814, 1835, 1855, 1874, 1892, 1909, 1925, 1940, 1954, 1967, 1979, 1990,
+  2000, 2009, 2017, 2024, 2030, 2035, 2039, 2042, 1519, 1550, 1581, 1611, 1640,
+  1668, 1695, 1721, 1746, 1770, 1793, 1815, 1836, 1856, 1875, 1893, 1910, 1926,
+  1941, 1955, 1968, 1980, 1991, 2001, 2010, 2018, 2025, 2031, 2036, 2040, 2043,
+  2045, 1551, 1582, 1612, 1641, 1669, 1696, 1722, 1747, 1771, 1794, 1816, 1837,
+  1857, 1876, 1894, 1911, 1927, 1942, 1956, 1969, 1981, 1992, 2002, 2011, 2019,
+  2026, 2032, 2037, 2041, 2044, 2046, 2047,
+};
+
+DECLARE_ALIGNED(16, static const int16_t, av1_default_iscan_64x32[2048]) = {
+  0,    1,    3,    6,    10,   15,   21,   28,   36,   45,   55,   66,   78,
+  91,   105,  120,  136,  153,  171,  190,  210,  231,  253,  276,  300,  325,
+  351,  378,  406,  435,  465,  496,  528,  560,  592,  624,  656,  688,  720,
+  752,  784,  816,  848,  880,  912,  944,  976,  1008, 1040, 1072, 1104, 1136,
+  1168, 1200, 1232, 1264, 1296, 1328, 1360, 1392, 1424, 1456, 1488, 1520, 2,
+  4,    7,    11,   16,   22,   29,   37,   46,   56,   67,   79,   92,   106,
+  121,  137,  154,  172,  191,  211,  232,  254,  277,  301,  326,  352,  379,
+  407,  436,  466,  497,  529,  561,  593,  625,  657,  689,  721,  753,  785,
+  817,  849,  881,  913,  945,  977,  1009, 1041, 1073, 1105, 1137, 1169, 1201,
+  1233, 1265, 1297, 1329, 1361, 1393, 1425, 1457, 1489, 1521, 1552, 5,    8,
+  12,   17,   23,   30,   38,   47,   57,   68,   80,   93,   107,  122,  138,
+  155,  173,  192,  212,  233,  255,  278,  302,  327,  353,  380,  408,  437,
+  467,  498,  530,  562,  594,  626,  658,  690,  722,  754,  786,  818,  850,
+  882,  914,  946,  978,  1010, 1042, 1074, 1106, 1138, 1170, 1202, 1234, 1266,
+  1298, 1330, 1362, 1394, 1426, 1458, 1490, 1522, 1553, 1583, 9,    13,   18,
+  24,   31,   39,   48,   58,   69,   81,   94,   108,  123,  139,  156,  174,
+  193,  213,  234,  256,  279,  303,  328,  354,  381,  409,  438,  468,  499,
+  531,  563,  595,  627,  659,  691,  723,  755,  787,  819,  851,  883,  915,
+  947,  979,  1011, 1043, 1075, 1107, 1139, 1171, 1203, 1235, 1267, 1299, 1331,
+  1363, 1395, 1427, 1459, 1491, 1523, 1554, 1584, 1613, 14,   19,   25,   32,
+  40,   49,   59,   70,   82,   95,   109,  124,  140,  157,  175,  194,  214,
+  235,  257,  280,  304,  329,  355,  382,  410,  439,  469,  500,  532,  564,
+  596,  628,  660,  692,  724,  756,  788,  820,  852,  884,  916,  948,  980,
+  1012, 1044, 1076, 1108, 1140, 1172, 1204, 1236, 1268, 1300, 1332, 1364, 1396,
+  1428, 1460, 1492, 1524, 1555, 1585, 1614, 1642, 20,   26,   33,   41,   50,
+  60,   71,   83,   96,   110,  125,  141,  158,  176,  195,  215,  236,  258,
+  281,  305,  330,  356,  383,  411,  440,  470,  501,  533,  565,  597,  629,
+  661,  693,  725,  757,  789,  821,  853,  885,  917,  949,  981,  1013, 1045,
+  1077, 1109, 1141, 1173, 1205, 1237, 1269, 1301, 1333, 1365, 1397, 1429, 1461,
+  1493, 1525, 1556, 1586, 1615, 1643, 1670, 27,   34,   42,   51,   61,   72,
+  84,   97,   111,  126,  142,  159,  177,  196,  216,  237,  259,  282,  306,
+  331,  357,  384,  412,  441,  471,  502,  534,  566,  598,  630,  662,  694,
+  726,  758,  790,  822,  854,  886,  918,  950,  982,  1014, 1046, 1078, 1110,
+  1142, 1174, 1206, 1238, 1270, 1302, 1334, 1366, 1398, 1430, 1462, 1494, 1526,
+  1557, 1587, 1616, 1644, 1671, 1697, 35,   43,   52,   62,   73,   85,   98,
+  112,  127,  143,  160,  178,  197,  217,  238,  260,  283,  307,  332,  358,
+  385,  413,  442,  472,  503,  535,  567,  599,  631,  663,  695,  727,  759,
+  791,  823,  855,  887,  919,  951,  983,  1015, 1047, 1079, 1111, 1143, 1175,
+  1207, 1239, 1271, 1303, 1335, 1367, 1399, 1431, 1463, 1495, 1527, 1558, 1588,
+  1617, 1645, 1672, 1698, 1723, 44,   53,   63,   74,   86,   99,   113,  128,
+  144,  161,  179,  198,  218,  239,  261,  284,  308,  333,  359,  386,  414,
+  443,  473,  504,  536,  568,  600,  632,  664,  696,  728,  760,  792,  824,
+  856,  888,  920,  952,  984,  1016, 1048, 1080, 1112, 1144, 1176, 1208, 1240,
+  1272, 1304, 1336, 1368, 1400, 1432, 1464, 1496, 1528, 1559, 1589, 1618, 1646,
+  1673, 1699, 1724, 1748, 54,   64,   75,   87,   100,  114,  129,  145,  162,
+  180,  199,  219,  240,  262,  285,  309,  334,  360,  387,  415,  444,  474,
+  505,  537,  569,  601,  633,  665,  697,  729,  761,  793,  825,  857,  889,
+  921,  953,  985,  1017, 1049, 1081, 1113, 1145, 1177, 1209, 1241, 1273, 1305,
+  1337, 1369, 1401, 1433, 1465, 1497, 1529, 1560, 1590, 1619, 1647, 1674, 1700,
+  1725, 1749, 1772, 65,   76,   88,   101,  115,  130,  146,  163,  181,  200,
+  220,  241,  263,  286,  310,  335,  361,  388,  416,  445,  475,  506,  538,
+  570,  602,  634,  666,  698,  730,  762,  794,  826,  858,  890,  922,  954,
+  986,  1018, 1050, 1082, 1114, 1146, 1178, 1210, 1242, 1274, 1306, 1338, 1370,
+  1402, 1434, 1466, 1498, 1530, 1561, 1591, 1620, 1648, 1675, 1701, 1726, 1750,
+  1773, 1795, 77,   89,   102,  116,  131,  147,  164,  182,  201,  221,  242,
+  264,  287,  311,  336,  362,  389,  417,  446,  476,  507,  539,  571,  603,
+  635,  667,  699,  731,  763,  795,  827,  859,  891,  923,  955,  987,  1019,
+  1051, 1083, 1115, 1147, 1179, 1211, 1243, 1275, 1307, 1339, 1371, 1403, 1435,
+  1467, 1499, 1531, 1562, 1592, 1621, 1649, 1676, 1702, 1727, 1751, 1774, 1796,
+  1817, 90,   103,  117,  132,  148,  165,  183,  202,  222,  243,  265,  288,
+  312,  337,  363,  390,  418,  447,  477,  508,  540,  572,  604,  636,  668,
+  700,  732,  764,  796,  828,  860,  892,  924,  956,  988,  1020, 1052, 1084,
+  1116, 1148, 1180, 1212, 1244, 1276, 1308, 1340, 1372, 1404, 1436, 1468, 1500,
+  1532, 1563, 1593, 1622, 1650, 1677, 1703, 1728, 1752, 1775, 1797, 1818, 1838,
+  104,  118,  133,  149,  166,  184,  203,  223,  244,  266,  289,  313,  338,
+  364,  391,  419,  448,  478,  509,  541,  573,  605,  637,  669,  701,  733,
+  765,  797,  829,  861,  893,  925,  957,  989,  1021, 1053, 1085, 1117, 1149,
+  1181, 1213, 1245, 1277, 1309, 1341, 1373, 1405, 1437, 1469, 1501, 1533, 1564,
+  1594, 1623, 1651, 1678, 1704, 1729, 1753, 1776, 1798, 1819, 1839, 1858, 119,
+  134,  150,  167,  185,  204,  224,  245,  267,  290,  314,  339,  365,  392,
+  420,  449,  479,  510,  542,  574,  606,  638,  670,  702,  734,  766,  798,
+  830,  862,  894,  926,  958,  990,  1022, 1054, 1086, 1118, 1150, 1182, 1214,
+  1246, 1278, 1310, 1342, 1374, 1406, 1438, 1470, 1502, 1534, 1565, 1595, 1624,
+  1652, 1679, 1705, 1730, 1754, 1777, 1799, 1820, 1840, 1859, 1877, 135,  151,
+  168,  186,  205,  225,  246,  268,  291,  315,  340,  366,  393,  421,  450,
+  480,  511,  543,  575,  607,  639,  671,  703,  735,  767,  799,  831,  863,
+  895,  927,  959,  991,  1023, 1055, 1087, 1119, 1151, 1183, 1215, 1247, 1279,
+  1311, 1343, 1375, 1407, 1439, 1471, 1503, 1535, 1566, 1596, 1625, 1653, 1680,
+  1706, 1731, 1755, 1778, 1800, 1821, 1841, 1860, 1878, 1895, 152,  169,  187,
+  206,  226,  247,  269,  292,  316,  341,  367,  394,  422,  451,  481,  512,
+  544,  576,  608,  640,  672,  704,  736,  768,  800,  832,  864,  896,  928,
+  960,  992,  1024, 1056, 1088, 1120, 1152, 1184, 1216, 1248, 1280, 1312, 1344,
+  1376, 1408, 1440, 1472, 1504, 1536, 1567, 1597, 1626, 1654, 1681, 1707, 1732,
+  1756, 1779, 1801, 1822, 1842, 1861, 1879, 1896, 1912, 170,  188,  207,  227,
+  248,  270,  293,  317,  342,  368,  395,  423,  452,  482,  513,  545,  577,
+  609,  641,  673,  705,  737,  769,  801,  833,  865,  897,  929,  961,  993,
+  1025, 1057, 1089, 1121, 1153, 1185, 1217, 1249, 1281, 1313, 1345, 1377, 1409,
+  1441, 1473, 1505, 1537, 1568, 1598, 1627, 1655, 1682, 1708, 1733, 1757, 1780,
+  1802, 1823, 1843, 1862, 1880, 1897, 1913, 1928, 189,  208,  228,  249,  271,
+  294,  318,  343,  369,  396,  424,  453,  483,  514,  546,  578,  610,  642,
+  674,  706,  738,  770,  802,  834,  866,  898,  930,  962,  994,  1026, 1058,
+  1090, 1122, 1154, 1186, 1218, 1250, 1282, 1314, 1346, 1378, 1410, 1442, 1474,
+  1506, 1538, 1569, 1599, 1628, 1656, 1683, 1709, 1734, 1758, 1781, 1803, 1824,
+  1844, 1863, 1881, 1898, 1914, 1929, 1943, 209,  229,  250,  272,  295,  319,
+  344,  370,  397,  425,  454,  484,  515,  547,  579,  611,  643,  675,  707,
+  739,  771,  803,  835,  867,  899,  931,  963,  995,  1027, 1059, 1091, 1123,
+  1155, 1187, 1219, 1251, 1283, 1315, 1347, 1379, 1411, 1443, 1475, 1507, 1539,
+  1570, 1600, 1629, 1657, 1684, 1710, 1735, 1759, 1782, 1804, 1825, 1845, 1864,
+  1882, 1899, 1915, 1930, 1944, 1957, 230,  251,  273,  296,  320,  345,  371,
+  398,  426,  455,  485,  516,  548,  580,  612,  644,  676,  708,  740,  772,
+  804,  836,  868,  900,  932,  964,  996,  1028, 1060, 1092, 1124, 1156, 1188,
+  1220, 1252, 1284, 1316, 1348, 1380, 1412, 1444, 1476, 1508, 1540, 1571, 1601,
+  1630, 1658, 1685, 1711, 1736, 1760, 1783, 1805, 1826, 1846, 1865, 1883, 1900,
+  1916, 1931, 1945, 1958, 1970, 252,  274,  297,  321,  346,  372,  399,  427,
+  456,  486,  517,  549,  581,  613,  645,  677,  709,  741,  773,  805,  837,
+  869,  901,  933,  965,  997,  1029, 1061, 1093, 1125, 1157, 1189, 1221, 1253,
+  1285, 1317, 1349, 1381, 1413, 1445, 1477, 1509, 1541, 1572, 1602, 1631, 1659,
+  1686, 1712, 1737, 1761, 1784, 1806, 1827, 1847, 1866, 1884, 1901, 1917, 1932,
+  1946, 1959, 1971, 1982, 275,  298,  322,  347,  373,  400,  428,  457,  487,
+  518,  550,  582,  614,  646,  678,  710,  742,  774,  806,  838,  870,  902,
+  934,  966,  998,  1030, 1062, 1094, 1126, 1158, 1190, 1222, 1254, 1286, 1318,
+  1350, 1382, 1414, 1446, 1478, 1510, 1542, 1573, 1603, 1632, 1660, 1687, 1713,
+  1738, 1762, 1785, 1807, 1828, 1848, 1867, 1885, 1902, 1918, 1933, 1947, 1960,
+  1972, 1983, 1993, 299,  323,  348,  374,  401,  429,  458,  488,  519,  551,
+  583,  615,  647,  679,  711,  743,  775,  807,  839,  871,  903,  935,  967,
+  999,  1031, 1063, 1095, 1127, 1159, 1191, 1223, 1255, 1287, 1319, 1351, 1383,
+  1415, 1447, 1479, 1511, 1543, 1574, 1604, 1633, 1661, 1688, 1714, 1739, 1763,
+  1786, 1808, 1829, 1849, 1868, 1886, 1903, 1919, 1934, 1948, 1961, 1973, 1984,
+  1994, 2003, 324,  349,  375,  402,  430,  459,  489,  520,  552,  584,  616,
+  648,  680,  712,  744,  776,  808,  840,  872,  904,  936,  968,  1000, 1032,
+  1064, 1096, 1128, 1160, 1192, 1224, 1256, 1288, 1320, 1352, 1384, 1416, 1448,
+  1480, 1512, 1544, 1575, 1605, 1634, 1662, 1689, 1715, 1740, 1764, 1787, 1809,
+  1830, 1850, 1869, 1887, 1904, 1920, 1935, 1949, 1962, 1974, 1985, 1995, 2004,
+  2012, 350,  376,  403,  431,  460,  490,  521,  553,  585,  617,  649,  681,
+  713,  745,  777,  809,  841,  873,  905,  937,  969,  1001, 1033, 1065, 1097,
+  1129, 1161, 1193, 1225, 1257, 1289, 1321, 1353, 1385, 1417, 1449, 1481, 1513,
+  1545, 1576, 1606, 1635, 1663, 1690, 1716, 1741, 1765, 1788, 1810, 1831, 1851,
+  1870, 1888, 1905, 1921, 1936, 1950, 1963, 1975, 1986, 1996, 2005, 2013, 2020,
+  377,  404,  432,  461,  491,  522,  554,  586,  618,  650,  682,  714,  746,
+  778,  810,  842,  874,  906,  938,  970,  1002, 1034, 1066, 1098, 1130, 1162,
+  1194, 1226, 1258, 1290, 1322, 1354, 1386, 1418, 1450, 1482, 1514, 1546, 1577,
+  1607, 1636, 1664, 1691, 1717, 1742, 1766, 1789, 1811, 1832, 1852, 1871, 1889,
+  1906, 1922, 1937, 1951, 1964, 1976, 1987, 1997, 2006, 2014, 2021, 2027, 405,
+  433,  462,  492,  523,  555,  587,  619,  651,  683,  715,  747,  779,  811,
+  843,  875,  907,  939,  971,  1003, 1035, 1067, 1099, 1131, 1163, 1195, 1227,
+  1259, 1291, 1323, 1355, 1387, 1419, 1451, 1483, 1515, 1547, 1578, 1608, 1637,
+  1665, 1692, 1718, 1743, 1767, 1790, 1812, 1833, 1853, 1872, 1890, 1907, 1923,
+  1938, 1952, 1965, 1977, 1988, 1998, 2007, 2015, 2022, 2028, 2033, 434,  463,
+  493,  524,  556,  588,  620,  652,  684,  716,  748,  780,  812,  844,  876,
+  908,  940,  972,  1004, 1036, 1068, 1100, 1132, 1164, 1196, 1228, 1260, 1292,
+  1324, 1356, 1388, 1420, 1452, 1484, 1516, 1548, 1579, 1609, 1638, 1666, 1693,
+  1719, 1744, 1768, 1791, 1813, 1834, 1854, 1873, 1891, 1908, 1924, 1939, 1953,
+  1966, 1978, 1989, 1999, 2008, 2016, 2023, 2029, 2034, 2038, 464,  494,  525,
+  557,  589,  621,  653,  685,  717,  749,  781,  813,  845,  877,  909,  941,
+  973,  1005, 1037, 1069, 1101, 1133, 1165, 1197, 1229, 1261, 1293, 1325, 1357,
+  1389, 1421, 1453, 1485, 1517, 1549, 1580, 1610, 1639, 1667, 1694, 1720, 1745,
+  1769, 1792, 1814, 1835, 1855, 1874, 1892, 1909, 1925, 1940, 1954, 1967, 1979,
+  1990, 2000, 2009, 2017, 2024, 2030, 2035, 2039, 2042, 495,  526,  558,  590,
+  622,  654,  686,  718,  750,  782,  814,  846,  878,  910,  942,  974,  1006,
+  1038, 1070, 1102, 1134, 1166, 1198, 1230, 1262, 1294, 1326, 1358, 1390, 1422,
+  1454, 1486, 1518, 1550, 1581, 1611, 1640, 1668, 1695, 1721, 1746, 1770, 1793,
+  1815, 1836, 1856, 1875, 1893, 1910, 1926, 1941, 1955, 1968, 1980, 1991, 2001,
+  2010, 2018, 2025, 2031, 2036, 2040, 2043, 2045, 527,  559,  591,  623,  655,
+  687,  719,  751,  783,  815,  847,  879,  911,  943,  975,  1007, 1039, 1071,
+  1103, 1135, 1167, 1199, 1231, 1263, 1295, 1327, 1359, 1391, 1423, 1455, 1487,
+  1519, 1551, 1582, 1612, 1641, 1669, 1696, 1722, 1747, 1771, 1794, 1816, 1837,
+  1857, 1876, 1894, 1911, 1927, 1942, 1956, 1969, 1981, 1992, 2002, 2011, 2019,
+  2026, 2032, 2037, 2041, 2044, 2046, 2047,
+};
+
 DECLARE_ALIGNED(16, static const int16_t, av1_default_iscan_64x64[4096]) = {
   0,    1,    4,    9,    15,   22,   33,   43,   56,   71,   86,   104,  121,
   142,  166,  189,  214,  239,  269,  300,  331,  363,  400,  435,  471,  510,
@@ -6040,6 +7324,82 @@
       { mcol_scan_32x16, av1_mcol_iscan_32x16, mcol_scan_32x16_neighbors },
 #endif  // CONFIG_EXT_TX
   },
+#if CONFIG_TX64X64
+  {
+      // TX_32X64
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+#if CONFIG_EXT_TX
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+#endif  // CONFIG_EXT_TX
+  },
+  {
+      // TX_64X32
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+#if CONFIG_EXT_TX
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+#endif  // CONFIG_EXT_TX
+  }
+#endif  // CONFIG_TX64X64
 };
 
 const SCAN_ORDER av1_inter_scan_orders[TX_SIZES_ALL][TX_TYPES] = {
@@ -6361,6 +7721,82 @@
       { mcol_scan_32x16, av1_mcol_iscan_32x16, mcol_scan_32x16_neighbors },
 #endif  // CONFIG_EXT_TX
   },
+#if CONFIG_TX64X64
+  {
+      // TX_32X64
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+#if CONFIG_EXT_TX
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+      { default_scan_32x64, av1_default_iscan_32x64,
+        default_scan_32x64_neighbors },
+#endif  // CONFIG_EXT_TX
+  },
+  {
+      // TX_64X32
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+#if CONFIG_EXT_TX
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+      { default_scan_64x32, av1_default_iscan_64x32,
+        default_scan_64x32_neighbors },
+#endif  // CONFIG_EXT_TX
+  },
+#endif  // CONFIG_TX64X64
   {
       // TX_4X16
       { default_scan_4x16, av1_default_iscan_4x16,
diff --git a/av1/common/x86/av1_fwd_txfm2d_sse4.c b/av1/common/x86/av1_fwd_txfm2d_sse4.c
index f7824b6..f36a2eb 100644
--- a/av1/common/x86/av1_fwd_txfm2d_sse4.c
+++ b/av1/common/x86/av1_fwd_txfm2d_sse4.c
@@ -81,6 +81,7 @@
   fwd_txfm2d_sse4_1(input, output, stride, &cfg, txfm_buf);
 }
 
+#if CONFIG_TX64X64
 void av1_fwd_txfm2d_64x64_sse4_1(const int16_t *input, int32_t *output,
                                  int stride, int tx_type, int bd) {
   DECLARE_ALIGNED(16, int32_t, txfm_buf[4096]);
@@ -88,3 +89,4 @@
   (void)bd;
   fwd_txfm2d_sse4_1(input, output, stride, &cfg, txfm_buf);
 }
+#endif  // CONFIG_TX64X64
diff --git a/av1/encoder/dct.c b/av1/encoder/dct.c
index e1aa190..af2bf06 100644
--- a/av1/encoder/dct.c
+++ b/av1/encoder/dct.c
@@ -2446,7 +2446,7 @@
     { daala_idtx64, daala_fdst64 },  // H_ADST
     { daala_fdst64, daala_idtx64 },  // V_FLIPADST
     { daala_idtx64, daala_fdst64 },  // H_FLIPADST
-#endif
+#endif                               // CONFIG_EXT_TX
 #else
     { fdct64_col, fdct64_row },      // DCT_DCT
 #if CONFIG_EXT_TX
@@ -2465,8 +2465,8 @@
     { fidtx64, fhalfright64 },       // H_ADST
     { fhalfright64, fidtx64 },       // V_FLIPADST
     { fidtx64, fhalfright64 },       // H_FLIPADST
-#endif
-#endif
+#endif  // CONFIG_EXT_TX
+#endif  // CONFIG_DAALA_DCT64
   };
   const transform_2d ht = FHT[tx_type];
   tran_low_t out[4096];
@@ -2506,19 +2506,137 @@
 #endif
   }
 }
+
+void av1_fht64x32_c(const int16_t *input, tran_low_t *output, int stride,
+                    TxfmParam *txfm_param) {
+  int tx_type = txfm_param->tx_type;
+#if CONFIG_MRC_TX
+  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
+#endif  // CONFIG_MRC_TX
+#if CONFIG_DCT_ONLY
+  assert(tx_type == DCT_DCT);
+#endif
+  static const transform_2d FHT[] = {
+    { fdct32, fdct64_row },  // DCT_DCT
+#if CONFIG_EXT_TX
+    { fhalfright32, fdct64_row },    // ADST_DCT
+    { fdct32, fhalfright64 },        // DCT_ADST
+    { fhalfright32, fhalfright64 },  // ADST_ADST
+    { fhalfright32, fdct64_row },    // FLIPADST_DCT
+    { fdct32, fhalfright64 },        // DCT_FLIPADST
+    { fhalfright32, fhalfright64 },  // FLIPADST_FLIPADST
+    { fhalfright32, fhalfright64 },  // ADST_FLIPADST
+    { fhalfright32, fhalfright64 },  // FLIPADST_ADST
+    { fidtx32, fidtx64 },            // IDTX
+    { fdct32, fidtx64 },             // V_DCT
+    { fidtx32, fdct64_row },         // H_DCT
+    { fhalfright32, fidtx64 },       // V_ADST
+    { fidtx32, fhalfright64 },       // H_ADST
+    { fhalfright32, fidtx64 },       // V_FLIPADST
+    { fidtx32, fhalfright64 },       // H_FLIPADST
+#endif                               // CONFIG_EXT_TX
+  };
+  const transform_2d ht = FHT[tx_type];
+  tran_low_t out[2048];
+  int i, j;
+  tran_low_t temp_in[64], temp_out[64];
+  const int n = 32;
+  const int n2 = 64;
+#if CONFIG_EXT_TX
+  int16_t flipped_input[32 * 64];
+  maybe_flip_input(&input, &stride, n, n2, flipped_input, tx_type);
+#endif
+
+  // Columns
+  for (i = 0; i < n2; ++i) {
+    for (j = 0; j < n; ++j)
+      temp_in[j] = (tran_low_t)fdct_round_shift(input[j * stride + i] * Sqrt2);
+    ht.cols(temp_in, temp_out);
+    for (j = 0; j < n; ++j)
+      out[j * n2 + i] = (tran_low_t)ROUND_POWER_OF_TWO_SIGNED(temp_out[j], 2);
+  }
+
+  // Rows
+  for (i = 0; i < n; ++i) {
+    for (j = 0; j < n2; ++j) temp_in[j] = out[j + i * n2];
+    ht.rows(temp_in, temp_out);
+    for (j = 0; j < n2; ++j)
+      output[j + i * n2] =
+          (tran_low_t)ROUND_POWER_OF_TWO_SIGNED(temp_out[j], 2);
+  }
+}
+
+void av1_fht32x64_c(const int16_t *input, tran_low_t *output, int stride,
+                    TxfmParam *txfm_param) {
+  int tx_type = txfm_param->tx_type;
+#if CONFIG_MRC_TX
+  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
+#endif  // CONFIG_MRC_TX
+#if CONFIG_DCT_ONLY
+  assert(tx_type == DCT_DCT);
+#endif
+  static const transform_2d FHT[] = {
+    { fdct64_row, fdct32 },  // DCT_DCT
+#if CONFIG_EXT_TX
+    { fhalfright64, fdct32 },        // ADST_DCT
+    { fdct64_row, fhalfright32 },    // DCT_ADST
+    { fhalfright64, fhalfright32 },  // ADST_ADST
+    { fhalfright64, fdct32 },        // FLIPADST_DCT
+    { fdct64_row, fhalfright32 },    // DCT_FLIPADST
+    { fhalfright64, fhalfright32 },  // FLIPADST_FLIPADST
+    { fhalfright64, fhalfright32 },  // ADST_FLIPADST
+    { fhalfright64, fhalfright32 },  // FLIPADST_ADST
+    { fidtx64, fidtx32 },            // IDTX
+    { fdct64_row, fidtx32 },         // V_DCT
+    { fidtx64, fdct32 },             // H_DCT
+    { fhalfright64, fidtx32 },       // V_ADST
+    { fidtx64, fhalfright32 },       // H_ADST
+    { fhalfright64, fidtx32 },       // V_FLIPADST
+    { fidtx64, fhalfright32 },       // H_FLIPADST
+#endif                               // CONFIG_EXT_TX
+  };
+  const transform_2d ht = FHT[tx_type];
+  tran_low_t out[32 * 64];
+  int i, j;
+  tran_low_t temp_in[64], temp_out[64];
+  const int n = 32;
+  const int n2 = 64;
+#if CONFIG_EXT_TX
+  int16_t flipped_input[32 * 64];
+  maybe_flip_input(&input, &stride, n2, n, flipped_input, tx_type);
+#endif
+
+  // Rows
+  for (i = 0; i < n2; ++i) {
+    for (j = 0; j < n; ++j)
+      temp_in[j] = (tran_low_t)fdct_round_shift(input[i * stride + j] * Sqrt2);
+    ht.rows(temp_in, temp_out);
+    for (j = 0; j < n; ++j)
+      out[j * n2 + i] = (tran_low_t)ROUND_POWER_OF_TWO_SIGNED(temp_out[j], 2);
+  }
+
+  // Columns
+  for (i = 0; i < n; ++i) {
+    for (j = 0; j < n2; ++j) temp_in[j] = out[j + i * n2];
+    ht.cols(temp_in, temp_out);
+    for (j = 0; j < n2; ++j)
+      output[i + j * n] = (tran_low_t)ROUND_POWER_OF_TWO_SIGNED(temp_out[j], 2);
+  }
+}
 #endif  // CONFIG_TX64X64
 
 #if CONFIG_EXT_TX
 // Forward identity transform.
 void av1_fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride,
-                    int bs, int tx_type) {
+                    int bsx, int bsy, int tx_type) {
   int r, c;
-  const int shift = bs < 32 ? 3 : (bs < 64 ? 2 : 1);
+  const int pels = bsx * bsy;
+  const int shift = 3 - ((pels > 256) + (pels > 1024));
   if (tx_type == IDTX) {
-    for (r = 0; r < bs; ++r) {
-      for (c = 0; c < bs; ++c) coeff[c] = src_diff[c] * (1 << shift);
+    for (r = 0; r < bsy; ++r) {
+      for (c = 0; c < bsx; ++c) coeff[c] = src_diff[c] * (1 << shift);
       src_diff += stride;
-      coeff += bs;
+      coeff += bsx;
     }
   }
 }
diff --git a/av1/encoder/hybrid_fwd_txfm.c b/av1/encoder/hybrid_fwd_txfm.c
index 629de70..cc3bb07 100644
--- a/av1/encoder/hybrid_fwd_txfm.c
+++ b/av1/encoder/hybrid_fwd_txfm.c
@@ -140,11 +140,31 @@
                            int diff_stride, TxfmParam *txfm_param) {
 #if CONFIG_EXT_TX
   if (txfm_param->tx_type == IDTX)
-    av1_fwd_idtx_c(src_diff, coeff, diff_stride, 64, txfm_param->tx_type);
+    av1_fwd_idtx_c(src_diff, coeff, diff_stride, 64, 64, txfm_param->tx_type);
   else
 #endif
     av1_fht64x64(src_diff, coeff, diff_stride, txfm_param);
 }
+
+static void fwd_txfm_32x64(const int16_t *src_diff, tran_low_t *coeff,
+                           int diff_stride, TxfmParam *txfm_param) {
+#if CONFIG_EXT_TX
+  if (txfm_param->tx_type == IDTX)
+    av1_fwd_idtx_c(src_diff, coeff, diff_stride, 32, 64, txfm_param->tx_type);
+  else
+#endif
+    av1_fht32x64(src_diff, coeff, diff_stride, txfm_param);
+}
+
+static void fwd_txfm_64x32(const int16_t *src_diff, tran_low_t *coeff,
+                           int diff_stride, TxfmParam *txfm_param) {
+#if CONFIG_EXT_TX
+  if (txfm_param->tx_type == IDTX)
+    av1_fwd_idtx_c(src_diff, coeff, diff_stride, 64, 32, txfm_param->tx_type);
+  else
+#endif
+    av1_fht64x32(src_diff, coeff, diff_stride, txfm_param);
+}
 #endif  // CONFIG_TX64X64
 
 #if CONFIG_RECT_TX_EXT && (CONFIG_EXT_TX || CONFIG_VAR_TX)
@@ -412,6 +432,85 @@
 }
 
 #if CONFIG_TX64X64
+static void highbd_fwd_txfm_32x64(const int16_t *src_diff, tran_low_t *coeff,
+                                  int diff_stride, TxfmParam *txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  const int tx_type = txfm_param->tx_type;
+  const int bd = txfm_param->bd;
+  switch (tx_type) {
+    case DCT_DCT:
+      av1_fwd_txfm2d_32x64_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
+      break;
+#if CONFIG_EXT_TX
+    case ADST_DCT:
+    case DCT_ADST:
+    case ADST_ADST:
+    case FLIPADST_DCT:
+    case DCT_FLIPADST:
+    case FLIPADST_FLIPADST:
+    case ADST_FLIPADST:
+    case FLIPADST_ADST:
+    case V_DCT:
+    case H_DCT:
+    case V_ADST:
+    case H_ADST:
+    case V_FLIPADST:
+    case H_FLIPADST:
+      // TODO(sarahparker)
+      // I've deleted the 64x64 implementations that existed in lieu
+      // of adst, flipadst and identity for simplicity but will bring back
+      // in a later change. This shouldn't impact performance since
+      // DCT_DCT is the only extended type currently allowed for 64x64,
+      // as dictated by get_ext_tx_set_type in blockd.h.
+      av1_fwd_txfm2d_32x64_c(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
+      break;
+    case IDTX:
+      av1_fwd_idtx_c(src_diff, dst_coeff, diff_stride, 32, 64, tx_type);
+      break;
+#endif  // CONFIG_EXT_TX
+    default: assert(0); break;
+  }
+}
+
+static void highbd_fwd_txfm_64x32(const int16_t *src_diff, tran_low_t *coeff,
+                                  int diff_stride, TxfmParam *txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  const int tx_type = txfm_param->tx_type;
+  const int bd = txfm_param->bd;
+  switch (tx_type) {
+    case DCT_DCT:
+      av1_fwd_txfm2d_64x32_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
+      break;
+#if CONFIG_EXT_TX
+    case ADST_DCT:
+    case DCT_ADST:
+    case ADST_ADST:
+    case FLIPADST_DCT:
+    case DCT_FLIPADST:
+    case FLIPADST_FLIPADST:
+    case ADST_FLIPADST:
+    case FLIPADST_ADST:
+    case V_DCT:
+    case H_DCT:
+    case V_ADST:
+    case H_ADST:
+    case V_FLIPADST:
+    case H_FLIPADST:
+      // TODO(sarahparker)
+      // I've deleted the 64x64 implementations that existed in lieu
+      // of adst, flipadst and identity for simplicity but will bring back
+      // in a later change. This shouldn't impact performance since
+      // DCT_DCT is the only extended type currently allowed for 64x64,
+      // as dictated by get_ext_tx_set_type in blockd.h.
+      av1_fwd_txfm2d_64x32_c(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
+      break;
+    case IDTX:
+      av1_fwd_idtx_c(src_diff, dst_coeff, diff_stride, 64, 32, tx_type);
+      break;
+#endif  // CONFIG_EXT_TX
+    default: assert(0); break;
+  }
+}
 static void highbd_fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff,
                                   int diff_stride, TxfmParam *txfm_param) {
   int32_t *dst_coeff = (int32_t *)coeff;
@@ -445,7 +544,7 @@
       av1_fwd_txfm2d_64x64_c(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
       break;
     case IDTX:
-      av1_fwd_idtx_c(src_diff, dst_coeff, diff_stride, 64, tx_type);
+      av1_fwd_idtx_c(src_diff, dst_coeff, diff_stride, 64, 64, tx_type);
       break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
@@ -461,6 +560,12 @@
     case TX_64X64:
       fwd_txfm_64x64(src_diff, coeff, diff_stride, txfm_param);
       break;
+    case TX_32X64:
+      fwd_txfm_32x64(src_diff, coeff, diff_stride, txfm_param);
+      break;
+    case TX_64X32:
+      fwd_txfm_64x32(src_diff, coeff, diff_stride, txfm_param);
+      break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
       fwd_txfm_32x32(src_diff, coeff, diff_stride, txfm_param);
@@ -513,6 +618,12 @@
     case TX_64X64:
       highbd_fwd_txfm_64x64(src_diff, coeff, diff_stride, txfm_param);
       break;
+    case TX_32X64:
+      highbd_fwd_txfm_32x64(src_diff, coeff, diff_stride, txfm_param);
+      break;
+    case TX_64X32:
+      highbd_fwd_txfm_64x32(src_diff, coeff, diff_stride, txfm_param);
+      break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
       highbd_fwd_txfm_32x32(src_diff, coeff, diff_stride, txfm_param);
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 20f279a..e250ded 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -879,6 +879,26 @@
             !!(*(const uint64_t *)&left[i] | *(const uint64_t *)&left[i + 8]);
       break;
 #if CONFIG_TX64X64
+    case TX_32X64:
+      for (i = 0; i < num_4x4_w; i += 16)
+        t_above[i] =
+            !!(*(const uint64_t *)&above[i] | *(const uint64_t *)&above[i + 8]);
+      for (i = 0; i < num_4x4_h; i += 32)
+        t_left[i] =
+            !!(*(const uint64_t *)&left[i] | *(const uint64_t *)&left[i + 8] |
+               *(const uint64_t *)&left[i + 16] |
+               *(const uint64_t *)&left[i + 24]);
+      break;
+    case TX_64X32:
+      for (i = 0; i < num_4x4_w; i += 32)
+        t_above[i] =
+            !!(*(const uint64_t *)&above[i] | *(const uint64_t *)&above[i + 8] |
+               *(const uint64_t *)&above[i + 16] |
+               *(const uint64_t *)&above[i + 24]);
+      for (i = 0; i < num_4x4_h; i += 16)
+        t_left[i] =
+            !!(*(const uint64_t *)&left[i] | *(const uint64_t *)&left[i + 8]);
+      break;
     case TX_64X64:
       for (i = 0; i < num_4x4_w; i += 32)
         t_above[i] =
@@ -988,6 +1008,20 @@
         t_left[i] = !!*(const uint64_t *)&left[i];
       break;
 #if CONFIG_TX64X64
+    case TX_32X64:
+      for (i = 0; i < num_4x4_w; i += 8)
+        t_above[i] = !!*(const uint64_t *)&above[i];
+      for (i = 0; i < num_4x4_h; i += 16)
+        t_left[i] =
+            !!(*(const uint64_t *)&left[i] | *(const uint64_t *)&left[i + 8]);
+      break;
+    case TX_64X32:
+      for (i = 0; i < num_4x4_w; i += 16)
+        t_above[i] =
+            !!(*(const uint64_t *)&above[i] | *(const uint64_t *)&above[i + 8]);
+      for (i = 0; i < num_4x4_h; i += 8)
+        t_left[i] = !!*(const uint64_t *)&left[i];
+      break;
     case TX_64X64:
       for (i = 0; i < num_4x4_w; i += 16)
         t_above[i] =