]> granicus.if.org Git - libvpx/commitdiff
Add extended transforms for 32x32 and 64x64
authorDebargha Mukherjee <debargha@google.com>
Fri, 17 Jul 2015 05:13:40 +0000 (22:13 -0700)
committerDebargha Mukherjee <debargha@google.com>
Fri, 24 Jul 2015 01:01:22 +0000 (18:01 -0700)
Framework for alternate transforms for inter 32x32 and larger based
on dwt-dct hybrid is implemented.
Further experiments are to be condcuted with different
variations of hybrid dct/dwt or plain dwt, as well as super-resolution
mode.

Change-Id: I9a2bf49ba317e7668002cf1499211d7da6fa14ad

24 files changed:
test/quantize_test.cc
vp9/common/vp9_blockd.h
vp9/common/vp9_entropy.h
vp9/common/vp9_entropymode.c
vp9/common/vp9_entropymode.h
vp9/common/vp9_enums.h
vp9/common/vp9_idct.c
vp9/common/vp9_idct.h
vp9/common/vp9_idwt.c
vp9/common/vp9_idwt.h
vp9/common/vp9_rtcd_defs.pl
vp9/common/vp9_scan.c
vp9/common/vp9_scan.h
vp9/decoder/vp9_decodeframe.c
vp9/decoder/vp9_decodemv.c
vp9/encoder/vp9_bitstream.c
vp9/encoder/vp9_dwt.c
vp9/encoder/vp9_dwt.h
vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_encodemb.c
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_encoder.h
vp9/encoder/vp9_rd.c
vp9/encoder/vp9_rdopt.c

index 872d77a64aae814db3314cd3611cd5a0ea69ed39..fa02936d58f4f9ad374e738f26d85b8737e726d1 100644 (file)
@@ -95,7 +95,7 @@ TEST_P(QuantizeTest, OperationCheck) {
     int skip_block = i == 0;
     TX_SIZE sz = (TX_SIZE)(i % 3);  // TX_4X4, TX_8X8 TX_16X16
     TX_TYPE tx_type = (TX_TYPE)((i >> 2) % 3);
-    const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
+    const scan_order *scan_order = &vp9_intra_scan_orders[sz][tx_type];
     int count = (4 << sz) * (4 << sz);  // 16, 64, 256
     int err_count = 0;
     *eob_ptr = rnd.Rand16();
@@ -154,7 +154,7 @@ TEST_P(Quantize32Test, OperationCheck) {
     TX_SIZE sz = TX_32X32;
     TX_TYPE tx_type = (TX_TYPE)(i % 4);
 
-    const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
+    const scan_order *scan_order = &vp9_intra_scan_orders[sz][tx_type];
     int count = (4 << sz) * (4 << sz);  // 1024
     int err_count = 0;
     *eob_ptr = rnd.Rand16();
@@ -212,7 +212,7 @@ TEST_P(QuantizeTest, EOBCheck) {
     int skip_block = i == 0;
     TX_SIZE sz = (TX_SIZE)(i % 3);  // TX_4X4, TX_8X8 TX_16X16
     TX_TYPE tx_type = (TX_TYPE)((i >> 2) % 3);
-    const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
+    const scan_order *scan_order = &vp9_intra_scan_orders[sz][tx_type];
     int count = (4 << sz) * (4 << sz);  // 16, 64, 256
     int err_count = 0;
     *eob_ptr = rnd.Rand16();
@@ -275,7 +275,7 @@ TEST_P(Quantize32Test, EOBCheck) {
     int skip_block = i == 0;
     TX_SIZE sz = TX_32X32;
     TX_TYPE tx_type = (TX_TYPE)(i % 4);
-    const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
+    const scan_order *scan_order = &vp9_intra_scan_orders[sz][tx_type];
     int count = (4 << sz) * (4 << sz);  // 1024
     int err_count = 0;
     *eob_ptr = rnd.Rand16();
index e32f054957c751d90e92f96c168d39bd12ab8550..c6cffb673214475c605c975724d1b4891136b318 100644 (file)
@@ -474,6 +474,22 @@ static INLINE int supertx_enabled(const MB_MODE_INFO *mbmi) {
 #endif  // CONFIG_SUPERTX
 
 #if CONFIG_EXT_TX
+#if CONFIG_WAVELETS
+#define GET_EXT_TX_TYPES(tx_size) \
+    ((tx_size) >= TX_32X32 ? EXT_TX_TYPES_LARGE : EXT_TX_TYPES)
+#define GET_EXT_TX_TREE(tx_size) \
+    ((tx_size) >= TX_32X32 ? vp9_ext_tx_large_tree : vp9_ext_tx_tree)
+#define GET_EXT_TX_ENCODINGS(tx_size) \
+    ((tx_size) >= TX_32X32 ? ext_tx_large_encodings : ext_tx_encodings)
+#else
+#define GET_EXT_TX_TYPES(tx_size) \
+    ((tx_size) >= TX_32X32 ? 1 : EXT_TX_TYPES)
+#define GET_EXT_TX_TREE(tx_size) \
+    ((tx_size) >= TX_32X32 ? NULL : vp9_ext_tx_tree)
+#define GET_EXT_TX_ENCODINGS(tx_size) \
+    ((tx_size) >= TX_32X32 ? NULL : ext_tx_encodings)
+#endif  // CONFIG_WAVELETS
+
 static TX_TYPE ext_tx_to_txtype[EXT_TX_TYPES] = {
   DCT_DCT,
   ADST_ADST,
@@ -485,8 +501,31 @@ static TX_TYPE ext_tx_to_txtype[EXT_TX_TYPES] = {
   FLIPADST_DCT,
   DCT_FLIPADST,
 };
+
+#if CONFIG_WAVELETS
+static TX_TYPE ext_tx_to_txtype_large[EXT_TX_TYPES_LARGE] = {
+  DCT_DCT,
+  WAVELET1_DCT_DCT
+};
+#endif  // CONFIG_WAVELETS
 #endif  // CONFIG_EXT_TX
 
+static INLINE TX_TYPE get_tx_type_large(PLANE_TYPE plane_type,
+                                        const MACROBLOCKD *xd) {
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+  const MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi;
+  if (plane_type != PLANE_TYPE_Y || xd->lossless)
+      return DCT_DCT;
+
+  if (is_inter_block(mbmi)) {
+    return ext_tx_to_txtype_large[mbmi->ext_txfrm];
+  }
+#endif  // CONFIG_EXT_TX  && CONFIG_WAVELETS
+  (void) plane_type;
+  (void) xd;
+  return DCT_DCT;
+}
+
 static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type,
                                   const MACROBLOCKD *xd) {
   const MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi;
@@ -501,7 +540,7 @@ static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type,
 #else
   if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(mbmi))
     return DCT_DCT;
-#endif
+#endif  // CONFIG_EXT_TX
 #if CONFIG_INTRABC
   if (is_intrabc_mode(mbmi->mode))
     return DCT_DCT;
index ff4df6f79b0e8e9bc3122b1e3d8fd16bec3b59f2..41311bb8c037d69af1147dc8e9b23b5a4638bfa0 100644 (file)
@@ -273,15 +273,23 @@ static INLINE const scan_order *get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size,
     return &vp9_default_scan_orders_pxd[tx_size];
 #endif  // CONFIG_TX_SKIP
 
-  if (is_inter_block(&mi->mbmi) || type != PLANE_TYPE_Y || xd->lossless
+  if (type != PLANE_TYPE_Y || xd->lossless
 #if CONFIG_INTRABC
       || is_intrabc_mode(mi->mbmi.mode)
 #endif
       ) {
     return &vp9_default_scan_orders[tx_size];
+  } else if (is_inter_block(&mi->mbmi)) {
+#if CONFIG_EXT_TX
+    TX_TYPE tx_type = (tx_size <= TX_16X16) ?
+        get_tx_type_4x4(type, xd, block_idx) : get_tx_type_large(type, xd);
+    return &vp9_inter_scan_orders[tx_size][tx_type];
+#else
+    return &vp9_default_scan_orders[tx_size];
+#endif
   } else {
     const PREDICTION_MODE mode = get_y_mode(mi, block_idx);
-    return &vp9_scan_orders[tx_size][intra_mode_to_tx_type_lookup[mode]];
+    return &vp9_intra_scan_orders[tx_size][intra_mode_to_tx_type_lookup[mode]];
   }
 }
 
index 6a28acfc6868f83d8412adaff0f5b2355fec92c5..e93484de7371d4758817f08e3b1cbba35bf3e6ce 100644 (file)
@@ -434,11 +434,27 @@ const vp9_tree_index vp9_ext_tx_tree[TREE_SIZE(EXT_TX_TYPES)] = {
   -ALT7, -ALT8,
 };
 
+#if CONFIG_WAVELETS
+static const vp9_prob default_ext_tx_prob[TX_SIZES][EXT_TX_TYPES - 1] = {
+  { 240, 128, 128, 128, 128, 128, 128, 128 },
+  { 208, 128, 128, 128, 128, 128, 128, 128 },
+  { 176, 128, 128, 128, 128, 128, 128, 128 },
+  { 160, 128, 128, 128, 128, 128, 128, 128 },
+#if CONFIG_TX64X64
+  { 160, 128, 128, 128, 128, 128, 128, 128 },
+#endif
+};
+
+const vp9_tree_index vp9_ext_tx_large_tree[TREE_SIZE(EXT_TX_TYPES_LARGE)] = {
+  -NORM, -ALT1,
+};
+#else   // CONFIG_WAVELETS
 static const vp9_prob default_ext_tx_prob[3][EXT_TX_TYPES - 1] = {
   { 240, 128, 128, 128, 128, 128, 128, 128 },
   { 208, 128, 128, 128, 128, 128, 128, 128 },
   { 176, 128, 128, 128, 128, 128, 128, 128 },
 };
+#endif  // CONFIG_WAVELETS
 #endif  // CONFIG_EXT_TX
 
 #if CONFIG_PALETTE
@@ -1041,6 +1057,12 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
     adapt_probs(vp9_ext_tx_tree, pre_fc->ext_tx_prob[i], counts->ext_tx[i],
                 fc->ext_tx_prob[i]);
   }
+#if CONFIG_WAVELETS
+  for (; i < TX_SIZES; ++i) {
+    adapt_probs(vp9_ext_tx_large_tree, pre_fc->ext_tx_prob[i],
+                counts->ext_tx[i], fc->ext_tx_prob[i]);
+  }
+#endif
 #endif  // CONFIG_EXT_TX
 
 #if CONFIG_SUPERTX
index d35148483d82599b66184139ecd1f5dddf60d505..a86333c94863c6e1e601eda2f03678819d903610 100644 (file)
@@ -75,7 +75,11 @@ typedef struct frame_contexts {
   vp9_prob filterintra_prob[TX_SIZES][INTRA_MODES];
 #endif  // CONFIG_FILTERINTRA
 #if CONFIG_EXT_TX
+#if CONFIG_WAVELETS
+  vp9_prob ext_tx_prob[TX_SIZES][EXT_TX_TYPES - 1];
+#else
   vp9_prob ext_tx_prob[3][EXT_TX_TYPES - 1];
+#endif  // CONFIG_WAVELETS
 #endif  // CONFIG_EXT_TX
 #if CONFIG_PALETTE
   vp9_prob palette_enabled_prob[10][3];
@@ -145,7 +149,11 @@ typedef struct {
   unsigned int filterintra[TX_SIZES][INTRA_MODES][2];
 #endif  // CONFIG_FILTERINTRA
 #if CONFIG_EXT_TX
+#if CONFIG_WAVELETS
+  unsigned int ext_tx[TX_SIZES][EXT_TX_TYPES];
+#else
   unsigned int ext_tx[3][EXT_TX_TYPES];
+#endif  // CONFIG_WAVELETS
 #endif  // CONFIG_EXT_TX
 #if CONFIG_SUPERTX
   unsigned int supertx[PARTITION_SUPERTX_CONTEXTS][TX_SIZES][2];
@@ -203,6 +211,10 @@ extern const vp9_tree_index vp9_switchable_interp_tree
                                 [TREE_SIZE(SWITCHABLE_FILTERS)];
 #if CONFIG_EXT_TX
 extern const vp9_tree_index vp9_ext_tx_tree[TREE_SIZE(EXT_TX_TYPES)];
+#if CONFIG_WAVELETS
+extern const
+    vp9_tree_index vp9_ext_tx_large_tree[TREE_SIZE(EXT_TX_TYPES_LARGE)];
+#endif  // CONFIG_WAVELETS
 #endif  // CONFIG_EXT_TX
 #if CONFIG_PALETTE
 extern const vp9_tree_index vp9_palette_size_tree[TREE_SIZE(PALETTE_SIZES)];
index 6babac84e1e2b087704f3474744cd4c8e85ad686..ed480a075d1ac52d58b14a64cf4681b35e44787a 100644 (file)
@@ -124,14 +124,20 @@ typedef enum {
   FLIPADST_FLIPADST = 6,
   ADST_FLIPADST = 7,
   FLIPADST_ADST = 8,
-  TOTAL_TX_TYPES
-#endif
+#if CONFIG_WAVELETS
+  WAVELET1_DCT_DCT = 9,
+#endif  // CONFIG_WAVELETS
+  TOTAL_TX_TYPES,
+#endif  // CONFIG_EXT_TX
 } TX_TYPE;
 
 #if CONFIG_EXT_TX
 typedef enum {
   NORM = 0,
   ALT1 = 1,
+#if CONFIG_WAVELETS
+  EXT_TX_TYPES_LARGE = 2,
+#endif  // CONFIG_WAVELETS
   ALT2 = 2,
   ALT3 = 3,
   ALT4 = 4,
@@ -141,7 +147,7 @@ typedef enum {
   ALT8 = 8,
   EXT_TX_TYPES
 } EXT_TX_TYPE;
-#endif
+#endif  // CONFIG_EXT_TX
 
 #if CONFIG_PALETTE
 typedef enum {
index 8496a215ea821bf278b6989c8ec67fac4618997f..2444c00e55f8b2847364d894d88663901f830486 100644 (file)
 #include "vp9/common/vp9_blockd.h"
 #include "vp9/common/vp9_idct.h"
 
-static INLINE uint8_t clip_pixel_add(uint8_t dest, tran_high_t trans) {
-  trans = WRAPLOW(trans, 8);
-  return clip_pixel(WRAPLOW(dest + trans, 8));
-}
-
 void vp9_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int stride) {
 /* 4-point reversible, orthonormal inverse Walsh-Hadamard in 3.5 adds,
    0.5 shifts per pixel. */
index 3876cf451c72ead02ffc36c83ed34c890bcd3d50..3fc42e88ebe25473a3d15582f440390ff259fbee 100644 (file)
@@ -143,6 +143,11 @@ typedef struct {
 #define WRAPLOW(x, bd) (x)
 #endif  // CONFIG_EMULATE_HARDWARE
 
+static INLINE uint8_t clip_pixel_add(uint8_t dest, tran_high_t trans) {
+  trans = WRAPLOW(trans, 8);
+  return clip_pixel(WRAPLOW(dest + trans, 8));
+}
+
 void vp9_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
                      int eob);
 void vp9_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
index beca543d2b918c7665b2fc4b7136d3c15fb0f5a6..13759731e899f13e82d4d11361a4f6639bc0ccfa 100644 (file)
@@ -15,7 +15,6 @@
 #include "vp9/common/vp9_blockd.h"
 #include "vp9/common/vp9_idwt.h"
 
-
 // Note: block length must be even for this implementation
 static void synthesis_53_row(int length,
                              tran_low_t *lowpass, tran_low_t *highpass,
@@ -286,17 +285,20 @@ static void dyadic_synthesize_97(int levels, int width, int height,
                                  (1 << dwt_scale_bits));
 }
 
-void vp9_idwt32x32_c(tran_low_t *input, tran_low_t *output, int stride) {
+void vp9_idwt32x32_c(const tran_low_t *input, tran_low_t *output, int stride) {
+  tran_low_t in[32 * 32];
+  vpx_memcpy(in, input, sizeof(in));
 #if DWT_TYPE == 26
-  dyadic_synthesize_26(4, 32, 32, input, 32, output, stride, 2);
+  dyadic_synthesize_26(4, 32, 32, in, 32, output, stride, 2);
 #elif DWT_TYPE == 97
-  dyadic_synthesize_97(4, 32, 32, input, 32, output, stride, 2);
+  dyadic_synthesize_97(4, 32, 32, in, 32, output, stride, 2);
 #elif DWT_TYPE == 53
-  dyadic_synthesize_53(4, 32, 32, input, 32, output, stride, 2);
+  dyadic_synthesize_53(4, 32, 32, in, 32, output, stride, 2);
 #endif
 }
 
-void vp9_idwtdct32x32_c(tran_low_t *input, tran_low_t *output, int stride) {
+void vp9_idwtdct32x32_c(const tran_low_t *input, tran_low_t *output,
+                        int stride) {
   const int dwt_levels = 1;
   tran_low_t buffer[16 * 16];
   tran_low_t buffer2[32 * 32];
@@ -318,18 +320,46 @@ void vp9_idwtdct32x32_c(tran_low_t *input, tran_low_t *output, int stride) {
 #endif
 }
 
+void vp9_idwt32x32_add_c(const tran_low_t *input, uint8_t *dest, int stride) {
+  int i, j;
+  tran_low_t output[32 * 32];
+  vp9_idwt32x32_c(input, output, 32);
+  for (i = 0; i < 32; ++i) {
+    for (j = 0; j < 32; ++j) {
+      dest[j * stride + i] =
+          clip_pixel_add(dest[j * stride + i], output[j * 32 + i]);
+    }
+  }
+}
+
+void vp9_idwtdct32x32_add_c(const tran_low_t *input, uint8_t *dest,
+                            int stride) {
+  int i, j;
+  tran_low_t output[32 * 32];
+  vp9_idwtdct32x32_c(input, output, 32);
+  for (i = 0; i < 32; ++i) {
+    for (j = 0; j < 32; ++j) {
+      dest[j * stride + i] =
+          clip_pixel_add(dest[j * stride + i], output[j * 32 + i]);
+    }
+  }
+}
+
 #if CONFIG_TX64X64
-void vp9_idwt64x64_c(tran_low_t *input, tran_low_t *output, int stride) {
+void vp9_idwt64x64_c(const tran_low_t *input, tran_low_t *output, int stride) {
+  tran_low_t in[64 * 64];
+  vpx_memcpy(in, input, sizeof(in));
 #if DWT_TYPE == 26
-  dyadic_synthesize_26(4, 64, 64, input, 64, output, stride, 1);
+  dyadic_synthesize_26(4, 64, 64, in, 64, output, stride, 1);
 #elif DWT_TYPE == 97
-  dyadic_synthesize_97(4, 64, 64, input, 64, output, stride, 1);
+  dyadic_synthesize_97(4, 64, 64, in, 64, output, stride, 1);
 #elif DWT_TYPE == 53
-  dyadic_synthesize_53(4, 64, 64, input, 64, output, stride, 1);
+  dyadic_synthesize_53(4, 64, 64, in, 64, output, stride, 1);
 #endif
 }
 
-void vp9_idwtdct64x64_c(tran_low_t *input, tran_low_t *output, int stride) {
+void vp9_idwtdct64x64_c(const tran_low_t *input, tran_low_t *output,
+                        int stride) {
   const int dwt_levels = 1;
   tran_low_t buffer[32 * 32];
   tran_low_t buffer2[64 * 64];
@@ -349,4 +379,29 @@ void vp9_idwtdct64x64_c(tran_low_t *input, tran_low_t *output, int stride) {
   dyadic_synthesize_53(dwt_levels, 64, 64, buffer2, 64, output, stride, 1);
 #endif
 }
+
+void vp9_idwt64x64_add_c(const tran_low_t *input, uint8_t *dest, int stride) {
+  int i, j;
+  tran_low_t output[64 * 64];
+  vp9_idwt64x64_c(input, output, 64);
+  for (i = 0; i < 64; ++i) {
+    for (j = 0; j < 64; ++j) {
+      dest[j * stride + i] =
+          clip_pixel_add(dest[j * stride + i], output[j * 64 + i]);
+    }
+  }
+}
+
+void vp9_idwtdct64x64_add_c(const tran_low_t *input, uint8_t *dest,
+                            int stride) {
+  int i, j;
+  tran_low_t output[64 * 64];
+  vp9_idwtdct64x64_c(input, output, 64);
+  for (i = 0; i < 64; ++i) {
+    for (j = 0; j < 64; ++j) {
+      dest[j * stride + i] =
+          clip_pixel_add(dest[j * stride + i], output[j * 64 + i]);
+    }
+  }
+}
 #endif  // CONFIG_TX64X64
index a2806a09d7bc0f0564f36dcce07c871f1f7fa131..3b62a41339301a2029d3503883974638ffc71077 100644 (file)
@@ -19,7 +19,7 @@
 #include "vp9/common/vp9_idct.h"
 
 #define DWT_MAX_LENGTH   64
-#define DWT_TYPE         26    // 26/53/97
+#define DWT_TYPE         53    // 26/53/97
 
 #ifdef __cplusplus
 extern "C" {
index 51183e9881ae4a1298c22508463f3f0b21938e0c..82b97181dbac5d89febba9cd5db0520b8e8dba30 100644 (file)
@@ -413,6 +413,14 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
   add_proto qw/void vp9_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
   specialize qw/vp9_idct32x32_1_add/;
 
+  if (vpx_config("CONFIG_WAVELETS") eq "yes") {
+    add_proto qw/void vp9_idwtdct32x32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+    specialize qw/vp9_idwtdct32x32_add/;
+
+    add_proto qw/void vp9_idwt32x32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+    specialize qw/vp9_idwt32x32_add/;
+  }
+
   if (vpx_config("CONFIG_TX64X64") eq "yes") {
     add_proto qw/void vp9_idct64x64_4096_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
     specialize qw/vp9_idct64x64_4096_add/;
@@ -420,6 +428,12 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
     if (vpx_config("CONFIG_WAVELETS") eq "yes") {
       add_proto qw/void vp9_idct32x32_noscale/, "const tran_low_t *input, int16_t *dest, int dest_stride";
       specialize qw/vp9_idct32x32_noscale/;
+
+      add_proto qw/void vp9_idwtdct64x64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+      specialize qw/vp9_idwtdct64x64_add/;
+
+      add_proto qw/void vp9_idwt64x64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+      specialize qw/vp9_idwt64x64_add/;
     }
   }
 
@@ -481,6 +495,14 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
     add_proto qw/void vp9_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
     specialize qw/vp9_idct32x32_1_add/;
 
+    if (vpx_config("CONFIG_WAVELETS") eq "yes") {
+      add_proto qw/void vp9_idwtdct32x32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+      specialize qw/vp9_idwtdct32x32_add/;
+
+      add_proto qw/void vp9_idwt32x32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+      specialize qw/vp9_idwt32x32_add/;
+    }
+
     if (vpx_config("CONFIG_TX64X64") eq "yes") {
       add_proto qw/void vp9_idct64x64_4096_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
       specialize qw/vp9_idct64x64_4096_add/;
@@ -488,6 +510,12 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
       if (vpx_config("CONFIG_WAVELETS") eq "yes") {
         add_proto qw/void vp9_idct32x32_noscale/, "const tran_low_t *input, int16_t *dest, int dest_stride";
         specialize qw/vp9_idct32x32_noscale/;
+
+        add_proto qw/void vp9_idwtdct64x64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+        specialize qw/vp9_idwtdct64x64_add/;
+
+        add_proto qw/void vp9_idwt64x64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+        specialize qw/vp9_idwt64x64_add/;
       }
     }
 
@@ -557,6 +585,14 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
     specialize qw/vp9_idct32x32_1_add sse2 neon_asm dspr2/;
     $vp9_idct32x32_1_add_neon_asm=vp9_idct32x32_1_add_neon;
 
+    if (vpx_config("CONFIG_WAVELETS") eq "yes") {
+      add_proto qw/void vp9_idwtdct32x32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+      specialize qw/vp9_idwtdct32x32_add/;
+
+      add_proto qw/void vp9_idwt32x32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+      specialize qw/vp9_idwt32x32_add/;
+    }
+
     if (vpx_config("CONFIG_TX64X64") eq "yes") {
       add_proto qw/void vp9_idct64x64_4096_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
       specialize qw/vp9_idct64x64_4096_add/;
@@ -564,6 +600,12 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
       if (vpx_config("CONFIG_WAVELETS") eq "yes") {
         add_proto qw/void vp9_idct32x32_noscale/, "const tran_low_t *input, int16_t *dest, int dest_stride";
         specialize qw/vp9_idct32x32_noscale/;
+
+        add_proto qw/void vp9_idwtdct64x64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+        specialize qw/vp9_idwtdct64x64_add/;
+
+        add_proto qw/void vp9_idwt64x64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
+        specialize qw/vp9_idwt64x64_add/;
       }
     }
 
@@ -1589,6 +1631,12 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
   if (vpx_config("CONFIG_WAVELETS") eq "yes") {
     add_proto qw/void vp9_fdct16x16_noscale/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/vp9_fdct16x16_noscale/;
+
+    add_proto qw/void vp9_fdwtdct32x32/, "const int16_t *input, tran_low_t *output, int stride";
+    specialize qw/vp9_fdwtdct32x32/;
+
+    add_proto qw/void vp9_fdwt32x32/, "const int16_t *input, tran_low_t *output, int stride";
+    specialize qw/vp9_fdwt32x32/;
   }
 
   if (vpx_config("CONFIG_TX64X64") eq "yes") {
@@ -1601,6 +1649,12 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
     if (vpx_config("CONFIG_WAVELETS") eq "yes") {
       add_proto qw/void vp9_fdct32x32_noscale/, "const int16_t *input, tran_low_t *output, int stride";
       specialize qw/vp9_fdct32x32_noscale/;
+
+      add_proto qw/void vp9_fdwtdct64x64/, "const int16_t *input, tran_low_t *output, int stride";
+      specialize qw/vp9_fdwtdct64x64/;
+
+      add_proto qw/void vp9_fdwt64x64/, "const int16_t *input, tran_low_t *output, int stride";
+      specialize qw/vp9_fdwt64x64/;
     }
   }
 }
index 539e290c34a5569b63f8fb6c5982514591478e15..e8471b514b2f6131ba8b009adb8d89264440def3 100644 (file)
@@ -229,6 +229,139 @@ DECLARE_ALIGNED(16, static const int16_t, default_scan_32x32[1024]) = {
   990, 959, 1022, 991, 1023,
 };
 
+#if CONFIG_WAVELETS
+DECLARE_ALIGNED(16, static const int16_t, dwtdct_scan_32x32[1024]) = {
+  0,  1, 32, 33,  2, 64, 34, 65,
+  66,  3, 96, 35, 97, 67, 98,  4,
+  128,  36, 129,  99,  68, 130,   5, 100,
+  131, 160,  37, 161,  69, 162, 132, 101,
+  163,   6, 192,  38, 193,  70, 194, 133,
+  164, 102, 195,   7, 224,  39, 165, 225,
+  134, 196,  71, 226, 103, 227, 166, 197,
+  8, 256,  40, 135, 228, 257,  72, 258,
+  198, 104, 259, 167, 229, 136, 260,   9,
+  288,  41, 289,  73, 199, 230, 290, 168,
+  261, 105, 291, 137, 292, 231,  10, 200,
+  262, 320,  42, 321,  74, 322, 169, 293,
+  106, 323, 232, 263, 138, 324, 201, 294,
+  11, 352,  43, 353,  75, 170, 325, 354,
+  264, 107, 233, 295, 355, 202, 326, 139,
+  356,  12, 384,  44, 265, 296, 385, 171,
+  357,  76, 386, 234, 327, 108, 387, 203,
+  358, 140, 388, 297, 266, 328,  13, 172,
+  389, 416,  45, 235, 359, 417,  77, 418,
+  109, 419, 204, 390, 298, 329, 141, 267,
+  360, 420, 236, 391, 173, 421,  14, 448,
+  46, 449,  78, 330, 450, 299, 361, 110,
+  205, 422, 451, 268, 392, 142, 452, 237,
+  423, 174, 331, 362, 453,  15, 300, 393,
+  480,  47, 481,  79, 482, 206, 454, 269,
+  424, 111, 483, 143, 484, 363, 332, 394,
+  238, 455, 175, 301, 425, 485, 270, 456,
+  207, 486, 364, 395, 333, 426, 239, 487,
+  302, 457, 396, 271, 488, 365, 427, 334,
+  458, 303, 489, 397, 428, 366, 459, 335,
+  490, 429, 398, 460, 367, 491, 430, 461,
+  399, 492, 462, 431, 493, 463, 494, 495,
+  16, 512, 528,  17, 513, 529,  48, 544,
+  560,  49, 545, 561,  18, 514, 530,  80,
+  576, 592,  50, 546, 562,  81, 577, 593,
+  82, 578, 594,  19, 515, 531, 112, 608,
+  624,  51, 547, 563, 113, 609, 625,  83,
+  579, 595, 114, 610, 626,  20, 516, 532,
+  144, 640, 656,  52, 548, 564, 145, 641,
+  657, 115, 611, 627,  84, 580, 596, 146,
+  642, 658,  21, 517, 533, 116, 612, 628,
+  147, 643, 659, 176, 672, 688,  53, 549,
+  565, 177, 673, 689,  85, 581, 597, 178,
+  674, 690, 148, 644, 660, 117, 613, 629,
+  179, 675, 691,  22, 518, 534, 208, 704,
+  720,  54, 550, 566, 209, 705, 721,  86,
+  582, 598, 210, 706, 722, 149, 645, 661,
+  180, 676, 692, 118, 614, 630, 211, 707,
+  723,  23, 519, 535, 240, 736, 752,  55,
+  551, 567, 181, 677, 693, 241, 737, 753,
+  150, 646, 662, 212, 708, 724,  87, 583,
+  599, 242, 738, 754, 119, 615, 631, 243,
+  739, 755, 182, 678, 694, 213, 709, 725,
+  24, 520, 536, 272, 768, 784,  56, 552,
+  568, 151, 647, 663, 244, 740, 756, 273,
+  769, 785,  88, 584, 600, 274, 770, 786,
+  214, 710, 726, 120, 616, 632, 275, 771,
+  787, 183, 679, 695, 245, 741, 757, 152,
+  648, 664, 276, 772, 788,  25, 521, 537,
+  304, 800, 816,  57, 553, 569, 305, 801,
+  817,  89, 585, 601, 215, 711, 727, 246,
+  742, 758, 306, 802, 818, 184, 680, 696,
+  277, 773, 789, 121, 617, 633, 307, 803,
+  819, 153, 649, 665, 308, 804, 820, 247,
+  743, 759,  26, 522, 538, 216, 712, 728,
+  278, 774, 790, 336, 832, 848,  58, 554,
+  570, 337, 833, 849,  90, 586, 602, 338,
+  834, 850, 185, 681, 697, 309, 805, 821,
+  122, 618, 634, 339, 835, 851, 248, 744,
+  760, 279, 775, 791, 154, 650, 666, 340,
+  836, 852, 217, 713, 729, 310, 806, 822,
+  27, 523, 539, 368, 864, 880,  59, 555,
+  571, 369, 865, 881,  91, 587, 603, 186,
+  682, 698, 341, 837, 853, 370, 866, 882,
+  280, 776, 792, 123, 619, 635, 249, 745,
+  761, 311, 807, 823, 371, 867, 883, 218,
+  714, 730, 342, 838, 854, 155, 651, 667,
+  372, 868, 884,  28, 524, 540, 400, 896,
+  912,  60, 556, 572, 281, 777, 793, 312,
+  808, 824, 401, 897, 913, 187, 683, 699,
+  373, 869, 885,  92, 588, 604, 402, 898,
+  914, 250, 746, 762, 343, 839, 855, 124,
+  620, 636, 403, 899, 915, 219, 715, 731,
+  374, 870, 886, 156, 652, 668, 404, 900,
+  916, 313, 809, 825, 282, 778, 794, 344,
+  840, 856,  29, 525, 541, 188, 684, 700,
+  405, 901, 917, 432, 928, 944,  61, 557,
+  573, 251, 747, 763, 375, 871, 887, 433,
+  929, 945,  93, 589, 605, 434, 930, 946,
+  125, 621, 637, 435, 931, 947, 220, 716,
+  732, 406, 902, 918, 314, 810, 826, 345,
+  841, 857, 157, 653, 669, 283, 779, 795,
+  376, 872, 888, 436, 932, 948, 252, 748,
+  764, 407, 903, 919, 189, 685, 701, 437,
+  933, 949,  30, 526, 542, 464, 960, 976,
+  62, 558, 574, 465, 961, 977,  94, 590,
+  606, 346, 842, 858, 466, 962, 978, 315,
+  811, 827, 377, 873, 889, 126, 622, 638,
+  221, 717, 733, 438, 934, 950, 467, 963,
+  979, 284, 780, 796, 408, 904, 920, 158,
+  654, 670, 468, 964, 980, 253, 749, 765,
+  439, 935, 951, 190, 686, 702, 347, 843,
+  859, 378, 874, 890, 469, 965, 981,  31,
+  527, 543, 316, 812, 828, 409, 905, 921,
+  496,  992, 1008,   63,  559,  575,  497,  993,
+  1009,   95,  591,  607,  498,  994, 1010,  222,
+  718, 734, 470, 966, 982, 285, 781, 797,
+  440, 936, 952, 127, 623, 639, 499, 995,
+  1011,  159,  655,  671,  500,  996, 1012,  379,
+  875, 891, 348, 844, 860, 410, 906, 922,
+  254, 750, 766, 471, 967, 983, 191, 687,
+  703, 317, 813, 829, 441, 937, 953, 501,
+  997, 1013,  286,  782,  798,  472,  968,  984,
+  223,  719,  735,  502,  998, 1014,  380,  876,
+  892, 411, 907, 923, 349, 845, 861, 442,
+  938,  954,  255,  751,  767,  503,  999, 1015,
+  318, 814, 830, 473, 969, 985, 412, 908,
+  924,  287,  783,  799,  504, 1000, 1016,  381,
+  877, 893, 443, 939, 955, 350, 846, 862,
+  474,  970,  986,  319,  815,  831,  505, 1001,
+  1017,  413,  909,  925,  444,  940,  956,  382,
+  878, 894, 475, 971, 987, 351, 847, 863,
+  506, 1002, 1018,  445,  941,  957,  414,  910,
+  926, 476, 972, 988, 383, 879, 895, 507,
+  1003, 1019,  446,  942,  958,  477,  973,  989,
+  415,  911,  927,  508, 1004, 1020,  478,  974,
+  990,  447,  943,  959,  509, 1005, 1021,  479,
+  975,  991,  510, 1006, 1022,  511, 1007, 1023,
+};
+#endif  // CONFIG_WAVELETS
+
 #if CONFIG_TX64X64
 DECLARE_ALIGNED(16, static const int16_t, default_scan_64x64[4096]) = {
   0,   1,  64,  65,   2, 128,  66, 129,
@@ -744,7 +877,354 @@ DECLARE_ALIGNED(16, static const int16_t, default_scan_64x64[4096]) = {
   4090, 3965, 3902, 4028, 3839, 4091, 3966, 4029,
   3903, 4092, 4030, 3967, 4093, 4031, 4094, 4095,
 };
-#endif
+
+#if CONFIG_WAVELETS
+DECLARE_ALIGNED(16, static const int16_t, dwtdct_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,  69, 321, 133, 322, 260, 197, 323,   6, 384,  70,
+  385, 134, 386, 261, 324, 198, 387,   7, 448,  71, 325, 449,
+  262, 388, 135, 450, 199, 451, 326, 389,   8, 512,  72, 263,
+  452, 513, 136, 514, 390, 200, 515, 327, 453, 264, 516,   9,
+  576,  73, 577, 137, 391, 454, 578, 328, 517, 201, 579, 265,
+  580, 455,  10, 392, 518, 640,  74, 641, 138, 642, 329, 581,
+  202, 643, 456, 519, 266, 644, 393, 582,  11, 704,  75, 705,
+  139, 330, 645, 706, 520, 203, 457, 583, 707, 394, 646, 267,
+  708,  12, 768,  76, 521, 584, 769, 331, 709, 140, 770, 458,
+  647, 204, 771, 395, 710, 268, 772, 585, 522, 648,  13, 332,
+  773, 832,  77, 459, 711, 833, 141, 834, 205, 835, 396, 774,
+  586, 649, 269, 523, 712, 836, 460, 775, 333, 837,  14, 896,
+  78, 897, 142, 650, 898, 587, 713, 206, 397, 838, 899, 524,
+  776, 270, 900, 461, 839, 334, 651, 714, 901,  15, 588, 777,
+  960,  79, 961, 143, 962, 398, 902, 525, 840, 207, 963, 271,
+  964,  715,  652,  778,  462,  903,  335,  589,  841,  965,   16, 1024,
+  80, 1025,  144,  526,  904, 1026,  399,  966,  208,  716,  779, 1027,
+  653,  842,  272, 1028,  463,  967,  590,  905,  336, 1029,  780,   17,
+  527,  968, 1088,   81,  717,  843, 1089,  400, 1030,  145, 1090,  654,
+  906,  209, 1091,  273,  464, 1031, 1092,  591,  969,  781,  844,  337,
+  1093,  718,  907,  528, 1032,   18, 1152,   82,  401,  655,  970, 1094,
+  1153,  146, 1154,  210, 1155,  592, 1033,  465,  845, 1095,  274,  782,
+  908, 1156,  719,  971,  338, 1157,  529, 1096,  656, 1034,  402, 1158,
+  19, 1216,   83, 1217,  147,  846,  909, 1218,  783,  972,  211,  593,
+  1097, 1219,  466, 1159,  275,  720, 1035, 1220,  339, 1221,  530, 1160,
+  657, 1098,  910,  847,  973,  403, 1222,   20,  784, 1036, 1280,   84,
+  1281,  148, 1282,  594, 1161,  212, 1283,  467,  721, 1099, 1223,  276,
+  1284,  911,  974,  658, 1162,  340,  531,  848, 1037, 1224, 1285,  785,
+  1100,  404, 1286,   21, 1344,   85,  595, 1225, 1345,  149,  722, 1163,
+  1346,  468, 1287,  213,  975, 1347,  912, 1038,  277, 1348,  849, 1101,
+  659, 1226,  532, 1288,  341, 1349,  786, 1164,  405, 1350,  596,  976,
+  1039, 1289,  723, 1227,   22, 1408,   86,  913, 1102, 1409,  150, 1410,
+  469, 1351,  214,  850, 1165, 1411,  278,  660, 1290, 1412,  533,  787,
+  1228, 1352,  342, 1413, 1040,  977, 1103,  406,  914, 1166, 1414,  724,
+  1291,  597, 1353,   23, 1472,   87,  851, 1229, 1473,  151,  470, 1415,
+  1474,  215, 1475,  661, 1354,  788, 1292,  279, 1041, 1104, 1476,  534,
+  1416,  978, 1167,  343, 1477,  915, 1230,  725, 1355,  407,  598, 1417,
+  1478,  852, 1293,   24, 1536,   88, 1537,  471, 1105, 1479,  152, 1042,
+  1168, 1538,  662, 1418,  216,  789, 1356, 1539,  979, 1231,  280, 1540,
+  535, 1480,  916, 1294,  344, 1541,  726, 1419,  599,  853, 1357, 1481,
+  408, 1542, 1106, 1169, 1043, 1232,   25,  472,  980, 1295, 1543, 1600,
+  89, 1601,  790, 1420,  153,  663, 1482, 1602,  217, 1603,  917, 1358,
+  536, 1544,  281, 1604, 1170,  345,  727, 1107, 1233, 1483, 1605,  854,
+  1421, 1044, 1296,  600, 1545,  409, 1606,  981, 1359,  791, 1484,  473,
+  1607,   26,  664, 1546, 1664,   90, 1665,  154,  918, 1422, 1666,  218,
+  1171, 1234, 1667,  537, 1108, 1297, 1608,  282, 1668,  728, 1045, 1360,
+  1547,  855, 1485,  346, 1669,  601, 1609,  982, 1423,  410, 1670,  792,
+  1548, 1235, 1172, 1298,  474,  665,  919, 1486, 1610, 1671,   27, 1728,
+  91, 1109, 1361, 1729,  155, 1730,  219, 1731,  538, 1046, 1424, 1672,
+  283,  856, 1549, 1732,  729, 1611,  347,  983, 1487, 1733,  602, 1673,
+  1236, 1299,  411, 1173, 1362, 1734,  793, 1612,  920, 1550, 1110, 1425,
+  666, 1674,  475, 1735,   28, 1792,   92, 1047, 1488, 1793,  156, 1794,
+  220,  539, 1736, 1795,  857, 1613,  730, 1675,  284, 1300, 1796,  984,
+  1551, 1237, 1363, 1174, 1426,  348, 1797,  603, 1737, 1111, 1489,  412,
+  794, 1676, 1798,  921, 1614,  667, 1738, 1048, 1552,  476, 1799,   29,
+  1301, 1364, 1856,   93, 1857,  157,  858, 1238, 1427, 1677, 1858,  540,
+  1800,  221,  731,  985, 1615, 1739, 1859, 1175, 1490,  285, 1860,  604,
+  1112, 1553, 1801,  349, 1861,  922, 1678,  795, 1740,  413, 1862, 1049,
+  1616, 1365,  668, 1302, 1428, 1802,  477, 1239, 1491, 1863,  859, 1741,
+  30, 1176, 1554, 1920,   94,  986, 1679, 1921,  158, 1922,  541,  732,
+  1803, 1864,  222, 1923, 1113, 1617,  286, 1924,  605, 1865,  350,  923,
+  1366, 1429, 1742, 1925,  796, 1804, 1303, 1492, 1050, 1680,  414, 1926,
+  1240, 1555,  669, 1866,  478, 1177, 1618, 1927,  860, 1805,  987, 1743,
+  31, 1984,   95,  733, 1867, 1985,  542, 1928,  159, 1114, 1681, 1986,
+  1430,  223, 1367, 1493, 1987, 1304, 1556,  287, 1988,  924, 1806,  606,
+  1929,  797, 1051, 1744, 1868,  351, 1241, 1619, 1989,  415, 1990,  670,
+  1178, 1682, 1930,  988, 1807,  479,  861, 1869, 1991, 1431, 1494, 1368,
+  1557, 1115, 1745,  734, 1931,  543, 1305, 1620, 1992,  925, 1242, 1683,
+  1870, 1052, 1808,  607, 1993,  798, 1932, 1179, 1746, 1495, 1432, 1558,
+  671, 1994,  989, 1369, 1621, 1871,  862, 1933, 1116, 1809, 1306, 1684,
+  735, 1995, 1243, 1747,  926, 1934, 1053, 1872,  799, 1496, 1559, 1996,
+  1180, 1810, 1433, 1622, 1370, 1685,  990, 1935, 1307, 1748,  863, 1117,
+  1873, 1997, 1244, 1811, 1560, 1497, 1623, 1054, 1936,  927, 1998, 1434,
+  1686, 1181, 1874, 1371, 1749, 1308, 1812,  991, 1999, 1118, 1937, 1561,
+  1624, 1245, 1875, 1498, 1687, 1435, 1750, 1055, 2000, 1182, 1938, 1372,
+  1813, 1309, 1876, 1119, 1625, 2001, 1562, 1688, 1499, 1751, 1246, 1939,
+  1436, 1814, 1373, 1877, 1183, 2002, 1310, 1940, 1626, 1689, 1563, 1752,
+  1500, 1815, 1247, 2003, 1437, 1878, 1374, 1941, 1690, 1627, 1753, 1564,
+  1816, 1311, 2004, 1501, 1879, 1438, 1942, 1375, 2005, 1691, 1754, 1628,
+  1817, 1565, 1880, 1502, 1943, 1439, 2006, 1755, 1692, 1818, 1629, 1881,
+  1566, 1944, 1503, 2007, 1756, 1819, 1693, 1882, 1630, 1945, 1567, 2008,
+  1820, 1757, 1883, 1694, 1946, 1631, 2009, 1821, 1884, 1758, 1947, 1695,
+  2010, 1885, 1822, 1948, 1759, 2011, 1886, 1949, 1823, 2012, 1950, 1887,
+  2013, 1951, 2014, 2015,   32, 2048, 2080,   33, 2049, 2081,   96, 2112,
+  2144,   97, 2113, 2145,   34, 2050, 2082,  160, 2176, 2208,   98, 2114,
+  2146,  161, 2177, 2209,  162, 2178, 2210,   35, 2051, 2083,  224, 2240,
+  2272,   99, 2115, 2147,  225, 2241, 2273,  163, 2179, 2211,  226, 2242,
+  2274,   36, 2052, 2084,  288, 2304, 2336,  100, 2116, 2148,  289, 2305,
+  2337,  227, 2243, 2275,  164, 2180, 2212,  290, 2306, 2338,   37, 2053,
+  2085,  228, 2244, 2276,  291, 2307, 2339,  352, 2368, 2400,  101, 2117,
+  2149,  353, 2369, 2401,  165, 2181, 2213,  354, 2370, 2402,  292, 2308,
+  2340,  229, 2245, 2277,  355, 2371, 2403,   38, 2054, 2086,  416, 2432,
+  2464,  102, 2118, 2150,  417, 2433, 2465,  166, 2182, 2214,  418, 2434,
+  2466,  293, 2309, 2341,  356, 2372, 2404,  230, 2246, 2278,  419, 2435,
+  2467,   39, 2055, 2087,  480, 2496, 2528,  103, 2119, 2151,  357, 2373,
+  2405,  481, 2497, 2529,  294, 2310, 2342,  420, 2436, 2468,  167, 2183,
+  2215,  482, 2498, 2530,  231, 2247, 2279,  483, 2499, 2531,  358, 2374,
+  2406,  421, 2437, 2469,   40, 2056, 2088,  544, 2560, 2592,  104, 2120,
+  2152,  295, 2311, 2343,  484, 2500, 2532,  545, 2561, 2593,  168, 2184,
+  2216,  546, 2562, 2594,  422, 2438, 2470,  232, 2248, 2280,  547, 2563,
+  2595,  359, 2375, 2407,  485, 2501, 2533,  296, 2312, 2344,  548, 2564,
+  2596,   41, 2057, 2089,  608, 2624, 2656,  105, 2121, 2153,  609, 2625,
+  2657,  169, 2185, 2217,  423, 2439, 2471,  486, 2502, 2534,  610, 2626,
+  2658,  360, 2376, 2408,  549, 2565, 2597,  233, 2249, 2281,  611, 2627,
+  2659,  297, 2313, 2345,  612, 2628, 2660,  487, 2503, 2535,   42, 2058,
+  2090,  424, 2440, 2472,  550, 2566, 2598,  672, 2688, 2720,  106, 2122,
+  2154,  673, 2689, 2721,  170, 2186, 2218,  674, 2690, 2722,  361, 2377,
+  2409,  613, 2629, 2661,  234, 2250, 2282,  675, 2691, 2723,  488, 2504,
+  2536,  551, 2567, 2599,  298, 2314, 2346,  676, 2692, 2724,  425, 2441,
+  2473,  614, 2630, 2662,   43, 2059, 2091,  736, 2752, 2784,  107, 2123,
+  2155,  737, 2753, 2785,  171, 2187, 2219,  362, 2378, 2410,  677, 2693,
+  2725,  738, 2754, 2786,  552, 2568, 2600,  235, 2251, 2283,  489, 2505,
+  2537,  615, 2631, 2663,  739, 2755, 2787,  426, 2442, 2474,  678, 2694,
+  2726,  299, 2315, 2347,  740, 2756, 2788,   44, 2060, 2092,  800, 2816,
+  2848,  108, 2124, 2156,  553, 2569, 2601,  616, 2632, 2664,  801, 2817,
+  2849,  363, 2379, 2411,  741, 2757, 2789,  172, 2188, 2220,  802, 2818,
+  2850,  490, 2506, 2538,  679, 2695, 2727,  236, 2252, 2284,  803, 2819,
+  2851,  427, 2443, 2475,  742, 2758, 2790,  300, 2316, 2348,  804, 2820,
+  2852,  617, 2633, 2665,  554, 2570, 2602,  680, 2696, 2728,   45, 2061,
+  2093,  364, 2380, 2412,  805, 2821, 2853,  864, 2880, 2912,  109, 2125,
+  2157,  491, 2507, 2539,  743, 2759, 2791,  865, 2881, 2913,  173, 2189,
+  2221,  866, 2882, 2914,  237, 2253, 2285,  867, 2883, 2915,  428, 2444,
+  2476,  806, 2822, 2854,  618, 2634, 2666,  681, 2697, 2729,  301, 2317,
+  2349,  555, 2571, 2603,  744, 2760, 2792,  868, 2884, 2916,  492, 2508,
+  2540,  807, 2823, 2855,  365, 2381, 2413,  869, 2885, 2917,   46, 2062,
+  2094,  928, 2944, 2976,  110, 2126, 2158,  929, 2945, 2977,  174, 2190,
+  2222,  682, 2698, 2730,  930, 2946, 2978,  619, 2635, 2667,  745, 2761,
+  2793,  238, 2254, 2286,  429, 2445, 2477,  870, 2886, 2918,  931, 2947,
+  2979,  556, 2572, 2604,  808, 2824, 2856,  302, 2318, 2350,  932, 2948,
+  2980,  493, 2509, 2541,  871, 2887, 2919,  366, 2382, 2414,  683, 2699,
+  2731,  746, 2762, 2794,  933, 2949, 2981,   47, 2063, 2095,  620, 2636,
+  2668,  809, 2825, 2857,  992, 3008, 3040,  111, 2127, 2159,  993, 3009,
+  3041,  175, 2191, 2223,  994, 3010, 3042,  430, 2446, 2478,  934, 2950,
+  2982,  557, 2573, 2605,  872, 2888, 2920,  239, 2255, 2287,  995, 3011,
+  3043,  303, 2319, 2351,  996, 3012, 3044,  747, 2763, 2795,  684, 2700,
+  2732,  810, 2826, 2858,  494, 2510, 2542,  935, 2951, 2983,  367, 2383,
+  2415,  621, 2637, 2669,  873, 2889, 2921,  997, 3013, 3045,   48, 2064,
+  2096, 1056, 3072, 3104,  112, 2128, 2160, 1057, 3073, 3105,  176, 2192,
+  2224,  558, 2574, 2606,  936, 2952, 2984, 1058, 3074, 3106,  431, 2447,
+  2479,  998, 3014, 3046,  240, 2256, 2288,  748, 2764, 2796,  811, 2827,
+  2859, 1059, 3075, 3107,  685, 2701, 2733,  874, 2890, 2922,  304, 2320,
+  2352, 1060, 3076, 3108,  495, 2511, 2543,  999, 3015, 3047,  622, 2638,
+  2670,  937, 2953, 2985,  368, 2384, 2416, 1061, 3077, 3109,  812, 2828,
+  2860,   49, 2065, 2097,  559, 2575, 2607, 1000, 3016, 3048, 1120, 3136,
+  3168,  113, 2129, 2161,  749, 2765, 2797,  875, 2891, 2923, 1121, 3137,
+  3169,  432, 2448, 2480, 1062, 3078, 3110,  177, 2193, 2225, 1122, 3138,
+  3170,  686, 2702, 2734,  938, 2954, 2986,  241, 2257, 2289, 1123, 3139,
+  3171,  305, 2321, 2353,  496, 2512, 2544, 1063, 3079, 3111, 1124, 3140,
+  3172,  623, 2639, 2671, 1001, 3017, 3049,  813, 2829, 2861,  876, 2892,
+  2924,  369, 2385, 2417, 1125, 3141, 3173,  750, 2766, 2798,  939, 2955,
+  2987,  560, 2576, 2608, 1064, 3080, 3112,   50, 2066, 2098, 1184, 3200,
+  3232,  114, 2130, 2162,  433, 2449, 2481,  687, 2703, 2735, 1002, 3018,
+  3050, 1126, 3142, 3174, 1185, 3201, 3233,  178, 2194, 2226, 1186, 3202,
+  3234,  242, 2258, 2290, 1187, 3203, 3235,  624, 2640, 2672, 1065, 3081,
+  3113,  497, 2513, 2545,  877, 2893, 2925, 1127, 3143, 3175,  306, 2322,
+  2354,  814, 2830, 2862,  940, 2956, 2988, 1188, 3204, 3236,  751, 2767,
+  2799, 1003, 3019, 3051,  370, 2386, 2418, 1189, 3205, 3237,  561, 2577,
+  2609, 1128, 3144, 3176,  688, 2704, 2736, 1066, 3082, 3114,  434, 2450,
+  2482, 1190, 3206, 3238,   51, 2067, 2099, 1248, 3264, 3296,  115, 2131,
+  2163, 1249, 3265, 3297,  179, 2195, 2227,  878, 2894, 2926,  941, 2957,
+  2989, 1250, 3266, 3298,  815, 2831, 2863, 1004, 3020, 3052,  243, 2259,
+  2291,  625, 2641, 2673, 1129, 3145, 3177, 1251, 3267, 3299,  498, 2514,
+  2546, 1191, 3207, 3239,  307, 2323, 2355,  752, 2768, 2800, 1067, 3083,
+  3115, 1252, 3268, 3300,  371, 2387, 2419, 1253, 3269, 3301,  562, 2578,
+  2610, 1192, 3208, 3240,  689, 2705, 2737, 1130, 3146, 3178,  942, 2958,
+  2990,  879, 2895, 2927, 1005, 3021, 3053,  435, 2451, 2483, 1254, 3270,
+  3302,   52, 2068, 2100,  816, 2832, 2864, 1068, 3084, 3116, 1312, 3328,
+  3360,  116, 2132, 2164, 1313, 3329, 3361,  180, 2196, 2228, 1314, 3330,
+  3362,  626, 2642, 2674, 1193, 3209, 3241,  244, 2260, 2292, 1315, 3331,
+  3363,  499, 2515, 2547,  753, 2769, 2801, 1131, 3147, 3179, 1255, 3271,
+  3303,  308, 2324, 2356, 1316, 3332, 3364,  943, 2959, 2991, 1006, 3022,
+  3054,  690, 2706, 2738, 1194, 3210, 3242,  372, 2388, 2420,  563, 2579,
+  2611,  880, 2896, 2928, 1069, 3085, 3117, 1256, 3272, 3304, 1317, 3333,
+  3365,  817, 2833, 2865, 1132, 3148, 3180,  436, 2452, 2484, 1318, 3334,
+  3366,   53, 2069, 2101, 1376, 3392, 3424,  117, 2133, 2165,  627, 2643,
+  2675, 1257, 3273, 3305, 1377, 3393, 3425,  181, 2197, 2229,  754, 2770,
+  2802, 1195, 3211, 3243, 1378, 3394, 3426,  500, 2516, 2548, 1319, 3335,
+  3367,  245, 2261, 2293, 1007, 3023, 3055, 1379, 3395, 3427,  944, 2960,
+  2992, 1070, 3086, 3118,  309, 2325, 2357, 1380, 3396, 3428,  881, 2897,
+  2929, 1133, 3149, 3181,  691, 2707, 2739, 1258, 3274, 3306,  564, 2580,
+  2612, 1320, 3336, 3368,  373, 2389, 2421, 1381, 3397, 3429,  818, 2834,
+  2866, 1196, 3212, 3244,  437, 2453, 2485, 1382, 3398, 3430,  628, 2644,
+  2676, 1008, 3024, 3056, 1071, 3087, 3119, 1321, 3337, 3369,  755, 2771,
+  2803, 1259, 3275, 3307,   54, 2070, 2102, 1440, 3456, 3488,  118, 2134,
+  2166,  945, 2961, 2993, 1134, 3150, 3182, 1441, 3457, 3489,  182, 2198,
+  2230, 1442, 3458, 3490,  501, 2517, 2549, 1383, 3399, 3431,  246, 2262,
+  2294,  882, 2898, 2930, 1197, 3213, 3245, 1443, 3459, 3491,  310, 2326,
+  2358,  692, 2708, 2740, 1322, 3338, 3370, 1444, 3460, 3492,  565, 2581,
+  2613,  819, 2835, 2867, 1260, 3276, 3308, 1384, 3400, 3432,  374, 2390,
+  2422, 1445, 3461, 3493, 1072, 3088, 3120, 1009, 3025, 3057, 1135, 3151,
+  3183,  438, 2454, 2486,  946, 2962, 2994, 1198, 3214, 3246, 1446, 3462,
+  3494,  756, 2772, 2804, 1323, 3339, 3371,  629, 2645, 2677, 1385, 3401,
+  3433,   55, 2071, 2103, 1504, 3520, 3552,  119, 2135, 2167,  883, 2899,
+  2931, 1261, 3277, 3309, 1505, 3521, 3553,  183, 2199, 2231,  502, 2518,
+  2550, 1447, 3463, 3495, 1506, 3522, 3554,  247, 2263, 2295, 1507, 3523,
+  3555,  693, 2709, 2741, 1386, 3402, 3434,  820, 2836, 2868, 1324, 3340,
+  3372,  311, 2327, 2359, 1073, 3089, 3121, 1136, 3152, 3184, 1508, 3524,
+  3556,  566, 2582, 2614, 1448, 3464, 3496, 1010, 3026, 3058, 1199, 3215,
+  3247,  375, 2391, 2423, 1509, 3525, 3557,  947, 2963, 2995, 1262, 3278,
+  3310,  757, 2773, 2805, 1387, 3403, 3435,  439, 2455, 2487,  630, 2646,
+  2678, 1449, 3465, 3497, 1510, 3526, 3558,  884, 2900, 2932, 1325, 3341,
+  3373,   56, 2072, 2104, 1568, 3584, 3616,  120, 2136, 2168, 1569, 3585,
+  3617,  503, 2519, 2551, 1137, 3153, 3185, 1511, 3527, 3559,  184, 2200,
+  2232, 1074, 3090, 3122, 1200, 3216, 3248, 1570, 3586, 3618,  694, 2710,
+  2742, 1450, 3466, 3498,  248, 2264, 2296,  821, 2837, 2869, 1388, 3404,
+  3436, 1571, 3587, 3619, 1011, 3027, 3059, 1263, 3279, 3311,  312, 2328,
+  2360, 1572, 3588, 3620,  567, 2583, 2615, 1512, 3528, 3560,  948, 2964,
+  2996, 1326, 3342, 3374,  376, 2392, 2424, 1573, 3589, 3621,  758, 2774,
+  2806, 1451, 3467, 3499,  631, 2647, 2679,  885, 2901, 2933, 1389, 3405,
+  3437, 1513, 3529, 3561,  440, 2456, 2488, 1574, 3590, 3622, 1138, 3154,
+  3186, 1201, 3217, 3249, 1075, 3091, 3123, 1264, 3280, 3312,   57, 2073,
+  2105,  504, 2520, 2552, 1012, 3028, 3060, 1327, 3343, 3375, 1575, 3591,
+  3623, 1632, 3648, 3680,  121, 2137, 2169, 1633, 3649, 3681,  822, 2838,
+  2870, 1452, 3468, 3500,  185, 2201, 2233,  695, 2711, 2743, 1514, 3530,
+  3562, 1634, 3650, 3682,  249, 2265, 2297, 1635, 3651, 3683,  949, 2965,
+  2997, 1390, 3406, 3438,  568, 2584, 2616, 1576, 3592, 3624,  313, 2329,
+  2361, 1636, 3652, 3684, 1202, 3218, 3250,  377, 2393, 2425,  759, 2775,
+  2807, 1139, 3155, 3187, 1265, 3281, 3313, 1515, 3531, 3563, 1637, 3653,
+  3685,  886, 2902, 2934, 1453, 3469, 3501, 1076, 3092, 3124, 1328, 3344,
+  3376,  632, 2648, 2680, 1577, 3593, 3625,  441, 2457, 2489, 1638, 3654,
+  3686, 1013, 3029, 3061, 1391, 3407, 3439,  823, 2839, 2871, 1516, 3532,
+  3564,  505, 2521, 2553, 1639, 3655, 3687,   58, 2074, 2106,  696, 2712,
+  2744, 1578, 3594, 3626, 1696, 3712, 3744,  122, 2138, 2170, 1697, 3713,
+  3745,  186, 2202, 2234,  950, 2966, 2998, 1454, 3470, 3502, 1698, 3714,
+  3746,  250, 2266, 2298, 1203, 3219, 3251, 1266, 3282, 3314, 1699, 3715,
+  3747,  569, 2585, 2617, 1140, 3156, 3188, 1329, 3345, 3377, 1640, 3656,
+  3688,  314, 2330, 2362, 1700, 3716, 3748,  760, 2776, 2808, 1077, 3093,
+  3125, 1392, 3408, 3440, 1579, 3595, 3627,  887, 2903, 2935, 1517, 3533,
+  3565,  378, 2394, 2426, 1701, 3717, 3749,  633, 2649, 2681, 1641, 3657,
+  3689, 1014, 3030, 3062, 1455, 3471, 3503,  442, 2458, 2490, 1702, 3718,
+  3750,  824, 2840, 2872, 1580, 3596, 3628, 1267, 3283, 3315, 1204, 3220,
+  3252, 1330, 3346, 3378,  506, 2522, 2554,  697, 2713, 2745,  951, 2967,
+  2999, 1518, 3534, 3566, 1642, 3658, 3690, 1703, 3719, 3751,   59, 2075,
+  2107, 1760, 3776, 3808,  123, 2139, 2171, 1141, 3157, 3189, 1393, 3409,
+  3441, 1761, 3777, 3809,  187, 2203, 2235, 1762, 3778, 3810,  251, 2267,
+  2299, 1763, 3779, 3811,  570, 2586, 2618, 1078, 3094, 3126, 1456, 3472,
+  3504, 1704, 3720, 3752,  315, 2331, 2363,  888, 2904, 2936, 1581, 3597,
+  3629, 1764, 3780, 3812,  761, 2777, 2809, 1643, 3659, 3691,  379, 2395,
+  2427, 1015, 3031, 3063, 1519, 3535, 3567, 1765, 3781, 3813,  634, 2650,
+  2682, 1705, 3721, 3753, 1268, 3284, 3316, 1331, 3347, 3379,  443, 2459,
+  2491, 1205, 3221, 3253, 1394, 3410, 3442, 1766, 3782, 3814,  825, 2841,
+  2873, 1644, 3660, 3692,  952, 2968, 3000, 1582, 3598, 3630, 1142, 3158,
+  3190, 1457, 3473, 3505,  698, 2714, 2746, 1706, 3722, 3754,  507, 2523,
+  2555, 1767, 3783, 3815,   60, 2076, 2108, 1824, 3840, 3872,  124, 2140,
+  2172, 1079, 3095, 3127, 1520, 3536, 3568, 1825, 3841, 3873,  188, 2204,
+  2236, 1826, 3842, 3874,  252, 2268, 2300,  571, 2587, 2619, 1768, 3784,
+  3816, 1827, 3843, 3875,  889, 2905, 2937, 1645, 3661, 3693,  762, 2778,
+  2810, 1707, 3723, 3755,  316, 2332, 2364, 1332, 3348, 3380, 1828, 3844,
+  3876, 1016, 3032, 3064, 1583, 3599, 3631, 1269, 3285, 3317, 1395, 3411,
+  3443, 1206, 3222, 3254, 1458, 3474, 3506,  380, 2396, 2428, 1829, 3845,
+  3877,  635, 2651, 2683, 1769, 3785, 3817, 1143, 3159, 3191, 1521, 3537,
+  3569,  444, 2460, 2492,  826, 2842, 2874, 1708, 3724, 3756, 1830, 3846,
+  3878,  953, 2969, 3001, 1646, 3662, 3694,  699, 2715, 2747, 1770, 3786,
+  3818, 1080, 3096, 3128, 1584, 3600, 3632,  508, 2524, 2556, 1831, 3847,
+  3879,   61, 2077, 2109, 1333, 3349, 3381, 1396, 3412, 3444, 1888, 3904,
+  3936,  125, 2141, 2173, 1889, 3905, 3937,  189, 2205, 2237,  890, 2906,
+  2938, 1270, 3286, 3318, 1459, 3475, 3507, 1709, 3725, 3757, 1890, 3906,
+  3938,  572, 2588, 2620, 1832, 3848, 3880,  253, 2269, 2301,  763, 2779,
+  2811, 1017, 3033, 3065, 1647, 3663, 3695, 1771, 3787, 3819, 1891, 3907,
+  3939, 1207, 3223, 3255, 1522, 3538, 3570,  317, 2333, 2365, 1892, 3908,
+  3940,  636, 2652, 2684, 1144, 3160, 3192, 1585, 3601, 3633, 1833, 3849,
+  3881,  381, 2397, 2429, 1893, 3909, 3941,  954, 2970, 3002, 1710, 3726,
+  3758,  827, 2843, 2875, 1772, 3788, 3820,  445, 2461, 2493, 1894, 3910,
+  3942, 1081, 3097, 3129, 1648, 3664, 3696, 1397, 3413, 3445,  700, 2716,
+  2748, 1334, 3350, 3382, 1460, 3476, 3508, 1834, 3850, 3882,  509, 2525,
+  2557, 1271, 3287, 3319, 1523, 3539, 3571, 1895, 3911, 3943,  891, 2907,
+  2939, 1773, 3789, 3821,   62, 2078, 2110, 1208, 3224, 3256, 1586, 3602,
+  3634, 1952, 3968, 4000,  126, 2142, 2174, 1018, 3034, 3066, 1711, 3727,
+  3759, 1953, 3969, 4001,  190, 2206, 2238, 1954, 3970, 4002,  573, 2589,
+  2621,  764, 2780, 2812, 1835, 3851, 3883, 1896, 3912, 3944,  254, 2270,
+  2302, 1955, 3971, 4003, 1145, 3161, 3193, 1649, 3665, 3697,  318, 2334,
+  2366, 1956, 3972, 4004,  637, 2653, 2685, 1897, 3913, 3945,  382, 2398,
+  2430,  955, 2971, 3003, 1398, 3414, 3446, 1461, 3477, 3509, 1774, 3790,
+  3822, 1957, 3973, 4005,  828, 2844, 2876, 1836, 3852, 3884, 1335, 3351,
+  3383, 1524, 3540, 3572, 1082, 3098, 3130, 1712, 3728, 3760,  446, 2462,
+  2494, 1958, 3974, 4006, 1272, 3288, 3320, 1587, 3603, 3635,  701, 2717,
+  2749, 1898, 3914, 3946,  510, 2526, 2558, 1209, 3225, 3257, 1650, 3666,
+  3698, 1959, 3975, 4007,  892, 2908, 2940, 1837, 3853, 3885, 1019, 3035,
+  3067, 1775, 3791, 3823,   63, 2079, 2111, 2016, 4032, 4064,  127, 2143,
+  2175,  765, 2781, 2813, 1899, 3915, 3947, 2017, 4033, 4065,  574, 2590,
+  2622, 1960, 3976, 4008,  191, 2207, 2239, 1146, 3162, 3194, 1713, 3729,
+  3761, 2018, 4034, 4066, 1462, 3478, 3510,  255, 2271, 2303, 1399, 3415,
+  3447, 1525, 3541, 3573, 2019, 4035, 4067, 1336, 3352, 3384, 1588, 3604,
+  3636,  319, 2335, 2367, 2020, 4036, 4068,  956, 2972, 3004, 1838, 3854,
+  3886,  638, 2654, 2686, 1961, 3977, 4009,  829, 2845, 2877, 1083, 3099,
+  3131, 1776, 3792, 3824, 1900, 3916, 3948,  383, 2399, 2431, 1273, 3289,
+  3321, 1651, 3667, 3699, 2021, 4037, 4069,  447, 2463, 2495, 2022, 4038,
+  4070,  702, 2718, 2750, 1210, 3226, 3258, 1714, 3730, 3762, 1962, 3978,
+  4010, 1020, 3036, 3068, 1839, 3855, 3887,  511, 2527, 2559,  893, 2909,
+  2941, 1901, 3917, 3949, 2023, 4039, 4071, 1463, 3479, 3511, 1526, 3542,
+  3574, 1400, 3416, 3448, 1589, 3605, 3637, 1147, 3163, 3195, 1777, 3793,
+  3825,  766, 2782, 2814, 1963, 3979, 4011,  575, 2591, 2623, 1337, 3353,
+  3385, 1652, 3668, 3700, 2024, 4040, 4072,  957, 2973, 3005, 1274, 3290,
+  3322, 1715, 3731, 3763, 1902, 3918, 3950, 1084, 3100, 3132, 1840, 3856,
+  3888,  639, 2655, 2687, 2025, 4041, 4073,  830, 2846, 2878, 1964, 3980,
+  4012, 1211, 3227, 3259, 1778, 3794, 3826, 1527, 3543, 3575, 1464, 3480,
+  3512, 1590, 3606, 3638,  703, 2719, 2751, 2026, 4042, 4074, 1021, 3037,
+  3069, 1401, 3417, 3449, 1653, 3669, 3701, 1903, 3919, 3951,  894, 2910,
+  2942, 1965, 3981, 4013, 1148, 3164, 3196, 1841, 3857, 3889, 1338, 3354,
+  3386, 1716, 3732, 3764,  767, 2783, 2815, 2027, 4043, 4075, 1275, 3291,
+  3323, 1779, 3795, 3827,  958, 2974, 3006, 1966, 3982, 4014, 1085, 3101,
+  3133, 1904, 3920, 3952,  831, 2847, 2879, 1528, 3544, 3576, 1591, 3607,
+  3639, 2028, 4044, 4076, 1212, 3228, 3260, 1842, 3858, 3890, 1465, 3481,
+  3513, 1654, 3670, 3702, 1402, 3418, 3450, 1717, 3733, 3765, 1022, 3038,
+  3070, 1967, 3983, 4015, 1339, 3355, 3387, 1780, 3796, 3828,  895, 2911,
+  2943, 1149, 3165, 3197, 1905, 3921, 3953, 2029, 4045, 4077, 1276, 3292,
+  3324, 1843, 3859, 3891, 1592, 3608, 3640, 1529, 3545, 3577, 1655, 3671,
+  3703, 1086, 3102, 3134, 1968, 3984, 4016,  959, 2975, 3007, 2030, 4046,
+  4078, 1466, 3482, 3514, 1718, 3734, 3766, 1213, 3229, 3261, 1906, 3922,
+  3954, 1403, 3419, 3451, 1781, 3797, 3829, 1340, 3356, 3388, 1844, 3860,
+  3892, 1023, 3039, 3071, 2031, 4047, 4079, 1150, 3166, 3198, 1969, 3985,
+  4017, 1593, 3609, 3641, 1656, 3672, 3704, 1277, 3293, 3325, 1907, 3923,
+  3955, 1530, 3546, 3578, 1719, 3735, 3767, 1467, 3483, 3515, 1782, 3798,
+  3830, 1087, 3103, 3135, 2032, 4048, 4080, 1214, 3230, 3262, 1970, 3986,
+  4018, 1404, 3420, 3452, 1845, 3861, 3893, 1341, 3357, 3389, 1908, 3924,
+  3956, 1151, 3167, 3199, 1657, 3673, 3705, 2033, 4049, 4081, 1594, 3610,
+  3642, 1720, 3736, 3768, 1531, 3547, 3579, 1783, 3799, 3831, 1278, 3294,
+  3326, 1971, 3987, 4019, 1468, 3484, 3516, 1846, 3862, 3894, 1405, 3421,
+  3453, 1909, 3925, 3957, 1215, 3231, 3263, 2034, 4050, 4082, 1342, 3358,
+  3390, 1972, 3988, 4020, 1658, 3674, 3706, 1721, 3737, 3769, 1595, 3611,
+  3643, 1784, 3800, 3832, 1532, 3548, 3580, 1847, 3863, 3895, 1279, 3295,
+  3327, 2035, 4051, 4083, 1469, 3485, 3517, 1910, 3926, 3958, 1406, 3422,
+  3454, 1973, 3989, 4021, 1722, 3738, 3770, 1659, 3675, 3707, 1785, 3801,
+  3833, 1596, 3612, 3644, 1848, 3864, 3896, 1343, 3359, 3391, 2036, 4052,
+  4084, 1533, 3549, 3581, 1911, 3927, 3959, 1470, 3486, 3518, 1974, 3990,
+  4022, 1407, 3423, 3455, 2037, 4053, 4085, 1723, 3739, 3771, 1786, 3802,
+  3834, 1660, 3676, 3708, 1849, 3865, 3897, 1597, 3613, 3645, 1912, 3928,
+  3960, 1534, 3550, 3582, 1975, 3991, 4023, 1471, 3487, 3519, 2038, 4054,
+  4086, 1787, 3803, 3835, 1724, 3740, 3772, 1850, 3866, 3898, 1661, 3677,
+  3709, 1913, 3929, 3961, 1598, 3614, 3646, 1976, 3992, 4024, 1535, 3551,
+  3583, 2039, 4055, 4087, 1788, 3804, 3836, 1851, 3867, 3899, 1725, 3741,
+  3773, 1914, 3930, 3962, 1662, 3678, 3710, 1977, 3993, 4025, 1599, 3615,
+  3647, 2040, 4056, 4088, 1852, 3868, 3900, 1789, 3805, 3837, 1915, 3931,
+  3963, 1726, 3742, 3774, 1978, 3994, 4026, 1663, 3679, 3711, 2041, 4057,
+  4089, 1853, 3869, 3901, 1916, 3932, 3964, 1790, 3806, 3838, 1979, 3995,
+  4027, 1727, 3743, 3775, 2042, 4058, 4090, 1917, 3933, 3965, 1854, 3870,
+  3902, 1980, 3996, 4028, 1791, 3807, 3839, 2043, 4059, 4091, 1918, 3934,
+  3966, 1981, 3997, 4029, 1855, 3871, 3903, 2044, 4060, 4092, 1982, 3998,
+  4030, 1919, 3935, 3967, 2045, 4061, 4093, 1983, 3999, 4031, 2046, 4062,
+  4094, 2047, 4063, 4095,
+};
+#endif  // CONFIG_WAVELETS
+#endif  // CONFIG_TX64X64
 
 // Neighborhood 5-tuples for various scans and blocksizes,
 // in {top, left, topleft, topright, bottomleft} order
@@ -1049,6 +1529,183 @@ DECLARE_ALIGNED(16, static const int16_t,
   895, 926, 989, 1020, 958, 989, 927, 958, 990, 1021, 959, 990, 991, 1022, 0, 0,
 };
 
+#if CONFIG_WAVELETS
+DECLARE_ALIGNED(16, static const int16_t,
+                dwtdct_scan_32x32_neighbors[1025 * MAX_NEIGHBORS]) = {
+  0,  0,  0,  0,  0,  0,  1, 32,  1,  1, 32, 32,
+  2, 33, 33, 64, 34, 65,  2,  2, 64, 64,  3, 34,
+  65, 96, 35, 66, 66, 97,  3,  3, 96, 96,  4, 35,
+  97, 128,  67,  98,  36,  67,  98, 129,   4,   4,  68,  99,
+  99, 130, 128, 128,   5,  36, 129, 160,  37,  68, 130, 161,
+  100, 131,  69, 100, 131, 162,   5,   5, 160, 160,   6,  37,
+  161, 192,  38,  69, 162, 193, 101, 132, 132, 163,  70, 101,
+  163, 194,   6,   6, 192, 192,   7,  38, 133, 164, 193, 224,
+  102, 133, 164, 195,  39,  70, 194, 225,  71, 102, 195, 226,
+  134, 165, 165, 196,   7,   7, 224, 224,   8,  39, 103, 134,
+  196, 227, 225, 256,  40,  71, 226, 257, 166, 197,  72, 103,
+  227, 258, 135, 166, 197, 228, 104, 135, 228, 259,   8,   8,
+  256, 256,   9,  40, 257, 288,  41,  72, 167, 198, 198, 229,
+  258, 289, 136, 167, 229, 260,  73, 104, 259, 290, 105, 136,
+  260, 291, 199, 230,   9,   9, 168, 199, 230, 261, 288, 288,
+  10,  41, 289, 320,  42,  73, 290, 321, 137, 168, 261, 292,
+  74, 105, 291, 322, 200, 231, 231, 262, 106, 137, 292, 323,
+  169, 200, 262, 293,  10,  10, 320, 320,  11,  42, 321, 352,
+  43,  74, 138, 169, 293, 324, 322, 353, 232, 263,  75, 106,
+  201, 232, 263, 294, 323, 354, 170, 201, 294, 325, 107, 138,
+  324, 355,  11,  11, 352, 352,  12,  43, 233, 264, 264, 295,
+  353, 384, 139, 170, 325, 356,  44,  75, 354, 385, 202, 233,
+  295, 326,  76, 107, 355, 386, 171, 202, 326, 357, 108, 139,
+  356, 387, 265, 296, 234, 265, 296, 327,  12,  12, 140, 171,
+  357, 388, 384, 384,  13,  44, 203, 234, 327, 358, 385, 416,
+  45,  76, 386, 417,  77, 108, 387, 418, 172, 203, 358, 389,
+  266, 297, 297, 328, 109, 140, 235, 266, 328, 359, 388, 419,
+  204, 235, 359, 390, 141, 172, 389, 420,  13,  13, 416, 416,
+  14,  45, 417, 448,  46,  77, 298, 329, 418, 449, 267, 298,
+  329, 360,  78, 109, 173, 204, 390, 421, 419, 450, 236, 267,
+  360, 391, 110, 141, 420, 451, 205, 236, 391, 422, 142, 173,
+  299, 330, 330, 361, 421, 452,  14,  14, 268, 299, 361, 392,
+  448, 448,  15,  46, 449, 480,  47,  78, 450, 481, 174, 205,
+  422, 453, 237, 268, 392, 423,  79, 110, 451, 482, 111, 142,
+  452, 483, 331, 362, 300, 331, 362, 393, 206, 237, 423, 454,
+  143, 174, 269, 300, 393, 424, 453, 484, 238, 269, 424, 455,
+  175, 206, 454, 485, 332, 363, 363, 394, 301, 332, 394, 425,
+  207, 238, 455, 486, 270, 301, 425, 456, 364, 395, 239, 270,
+  456, 487, 333, 364, 395, 426, 302, 333, 426, 457, 271, 302,
+  457, 488, 365, 396, 396, 427, 334, 365, 427, 458, 303, 334,
+  458, 489, 397, 428, 366, 397, 428, 459, 335, 366, 459, 490,
+  398, 429, 429, 460, 367, 398, 460, 491, 430, 461, 399, 430,
+  461, 492, 431, 462, 462, 493, 463, 494,   0,   0,   0,   0,
+  0,   0,  16,  16, 512, 512, 528, 528,  16,  16, 512, 512,
+  528, 528,  17,  48, 513, 544, 529, 560,  17,  17, 513, 513,
+  529, 529,  48,  48, 544, 544, 560, 560,  18,  49, 514, 545,
+  530, 561,  49,  80, 545, 576, 561, 592,  50,  81, 546, 577,
+  562, 593,  18,  18, 514, 514, 530, 530,  80,  80, 576, 576,
+  592, 592,  19,  50, 515, 546, 531, 562,  81, 112, 577, 608,
+  593, 624,  51,  82, 547, 578, 563, 594,  82, 113, 578, 609,
+  594, 625,  19,  19, 515, 515, 531, 531, 112, 112, 608, 608,
+  624, 624,  20,  51, 516, 547, 532, 563, 113, 144, 609, 640,
+  625, 656,  83, 114, 579, 610, 595, 626,  52,  83, 548, 579,
+  564, 595, 114, 145, 610, 641, 626, 657,  20,  20, 516, 516,
+  532, 532,  84, 115, 580, 611, 596, 627, 115, 146, 611, 642,
+  627, 658, 144, 144, 640, 640, 656, 656,  21,  52, 517, 548,
+  533, 564, 145, 176, 641, 672, 657, 688,  53,  84, 549, 580,
+  565, 596, 146, 177, 642, 673, 658, 689, 116, 147, 612, 643,
+  628, 659,  85, 116, 581, 612, 597, 628, 147, 178, 643, 674,
+  659, 690,  21,  21, 517, 517, 533, 533, 176, 176, 672, 672,
+  688, 688,  22,  53, 518, 549, 534, 565, 177, 208, 673, 704,
+  689, 720,  54,  85, 550, 581, 566, 597, 178, 209, 674, 705,
+  690, 721, 117, 148, 613, 644, 629, 660, 148, 179, 644, 675,
+  660, 691,  86, 117, 582, 613, 598, 629, 179, 210, 675, 706,
+  691, 722,  22,  22, 518, 518, 534, 534, 208, 208, 704, 704,
+  720, 720,  23,  54, 519, 550, 535, 566, 149, 180, 645, 676,
+  661, 692, 209, 240, 705, 736, 721, 752, 118, 149, 614, 645,
+  630, 661, 180, 211, 676, 707, 692, 723,  55,  86, 551, 582,
+  567, 598, 210, 241, 706, 737, 722, 753,  87, 118, 583, 614,
+  599, 630, 211, 242, 707, 738, 723, 754, 150, 181, 646, 677,
+  662, 693, 181, 212, 677, 708, 693, 724,  23,  23, 519, 519,
+  535, 535, 240, 240, 736, 736, 752, 752,  24,  55, 520, 551,
+  536, 567, 119, 150, 615, 646, 631, 662, 212, 243, 708, 739,
+  724, 755, 241, 272, 737, 768, 753, 784,  56,  87, 552, 583,
+  568, 599, 242, 273, 738, 769, 754, 785, 182, 213, 678, 709,
+  694, 725,  88, 119, 584, 615, 600, 631, 243, 274, 739, 770,
+  755, 786, 151, 182, 647, 678, 663, 694, 213, 244, 709, 740,
+  725, 756, 120, 151, 616, 647, 632, 663, 244, 275, 740, 771,
+  756, 787,  24,  24, 520, 520, 536, 536, 272, 272, 768, 768,
+  784, 784,  25,  56, 521, 552, 537, 568, 273, 304, 769, 800,
+  785, 816,  57,  88, 553, 584, 569, 600, 183, 214, 679, 710,
+  695, 726, 214, 245, 710, 741, 726, 757, 274, 305, 770, 801,
+  786, 817, 152, 183, 648, 679, 664, 695, 245, 276, 741, 772,
+  757, 788,  89, 120, 585, 616, 601, 632, 275, 306, 771, 802,
+  787, 818, 121, 152, 617, 648, 633, 664, 276, 307, 772, 803,
+  788, 819, 215, 246, 711, 742, 727, 758,  25,  25, 521, 521,
+  537, 537, 184, 215, 680, 711, 696, 727, 246, 277, 742, 773,
+  758, 789, 304, 304, 800, 800, 816, 816,  26,  57, 522, 553,
+  538, 569, 305, 336, 801, 832, 817, 848,  58,  89, 554, 585,
+  570, 601, 306, 337, 802, 833, 818, 849, 153, 184, 649, 680,
+  665, 696, 277, 308, 773, 804, 789, 820,  90, 121, 586, 617,
+  602, 633, 307, 338, 803, 834, 819, 850, 216, 247, 712, 743,
+  728, 759, 247, 278, 743, 774, 759, 790, 122, 153, 618, 649,
+  634, 665, 308, 339, 804, 835, 820, 851, 185, 216, 681, 712,
+  697, 728, 278, 309, 774, 805, 790, 821,  26,  26, 522, 522,
+  538, 538, 336, 336, 832, 832, 848, 848,  27,  58, 523, 554,
+  539, 570, 337, 368, 833, 864, 849, 880,  59,  90, 555, 586,
+  571, 602, 154, 185, 650, 681, 666, 697, 309, 340, 805, 836,
+  821, 852, 338, 369, 834, 865, 850, 881, 248, 279, 744, 775,
+  760, 791,  91, 122, 587, 618, 603, 634, 217, 248, 713, 744,
+  729, 760, 279, 310, 775, 806, 791, 822, 339, 370, 835, 866,
+  851, 882, 186, 217, 682, 713, 698, 729, 310, 341, 806, 837,
+  822, 853, 123, 154, 619, 650, 635, 666, 340, 371, 836, 867,
+  852, 883,  27,  27, 523, 523, 539, 539, 368, 368, 864, 864,
+  880, 880,  28,  59, 524, 555, 540, 571, 249, 280, 745, 776,
+  761, 792, 280, 311, 776, 807, 792, 823, 369, 400, 865, 896,
+  881, 912, 155, 186, 651, 682, 667, 698, 341, 372, 837, 868,
+  853, 884,  60,  91, 556, 587, 572, 603, 370, 401, 866, 897,
+  882, 913, 218, 249, 714, 745, 730, 761, 311, 342, 807, 838,
+  823, 854,  92, 123, 588, 619, 604, 635, 371, 402, 867, 898,
+  883, 914, 187, 218, 683, 714, 699, 730, 342, 373, 838, 869,
+  854, 885, 124, 155, 620, 651, 636, 667, 372, 403, 868, 899,
+  884, 915, 281, 312, 777, 808, 793, 824, 250, 281, 746, 777,
+  762, 793, 312, 343, 808, 839, 824, 855,  28,  28, 524, 524,
+  540, 540, 156, 187, 652, 683, 668, 699, 373, 404, 869, 900,
+  885, 916, 400, 400, 896, 896, 912, 912,  29,  60, 525, 556,
+  541, 572, 219, 250, 715, 746, 731, 762, 343, 374, 839, 870,
+  855, 886, 401, 432, 897, 928, 913, 944,  61,  92, 557, 588,
+  573, 604, 402, 433, 898, 929, 914, 945,  93, 124, 589, 620,
+  605, 636, 403, 434, 899, 930, 915, 946, 188, 219, 684, 715,
+  700, 731, 374, 405, 870, 901, 886, 917, 282, 313, 778, 809,
+  794, 825, 313, 344, 809, 840, 825, 856, 125, 156, 621, 652,
+  637, 668, 251, 282, 747, 778, 763, 794, 344, 375, 840, 871,
+  856, 887, 404, 435, 900, 931, 916, 947, 220, 251, 716, 747,
+  732, 763, 375, 406, 871, 902, 887, 918, 157, 188, 653, 684,
+  669, 700, 405, 436, 901, 932, 917, 948,  29,  29, 525, 525,
+  541, 541, 432, 432, 928, 928, 944, 944,  30,  61, 526, 557,
+  542, 573, 433, 464, 929, 960, 945, 976,  62,  93, 558, 589,
+  574, 605, 314, 345, 810, 841, 826, 857, 434, 465, 930, 961,
+  946, 977, 283, 314, 779, 810, 795, 826, 345, 376, 841, 872,
+  857, 888,  94, 125, 590, 621, 606, 637, 189, 220, 685, 716,
+  701, 732, 406, 437, 902, 933, 918, 949, 435, 466, 931, 962,
+  947, 978, 252, 283, 748, 779, 764, 795, 376, 407, 872, 903,
+  888, 919, 126, 157, 622, 653, 638, 669, 436, 467, 932, 963,
+  948, 979, 221, 252, 717, 748, 733, 764, 407, 438, 903, 934,
+  919, 950, 158, 189, 654, 685, 670, 701, 315, 346, 811, 842,
+  827, 858, 346, 377, 842, 873, 858, 889, 437, 468, 933, 964,
+  949, 980,  30,  30, 526, 526, 542, 542, 284, 315, 780, 811,
+  796, 827, 377, 408, 873, 904, 889, 920, 464, 464, 960, 960,
+  976, 976,  31,  62, 527, 558, 543, 574, 465, 496, 961, 992,
+  977, 1008,   63,   94,  559,  590,  575,  606,  466,  497,  962,  993,
+  978, 1009,  190,  221,  686,  717,  702,  733,  438,  469,  934,  965,
+  950, 981, 253, 284, 749, 780, 765, 796, 408, 439, 904, 935,
+  920, 951,  95, 126, 591, 622, 607, 638, 467, 498, 963, 994,
+  979, 1010,  127,  158,  623,  654,  639,  670,  468,  499,  964,  995,
+  980, 1011,  347,  378,  843,  874,  859,  890,  316,  347,  812,  843,
+  828, 859, 378, 409, 874, 905, 890, 921, 222, 253, 718, 749,
+  734, 765, 439, 470, 935, 966, 951, 982, 159, 190, 655, 686,
+  671, 702, 285, 316, 781, 812, 797, 828, 409, 440, 905, 936,
+  921,  952,  469,  500,  965,  996,  981, 1012,  254,  285,  750,  781,
+  766, 797, 440, 471, 936, 967, 952, 983, 191, 222, 687, 718,
+  703,  734,  470,  501,  966,  997,  982, 1013,  348,  379,  844,  875,
+  860, 891, 379, 410, 875, 906, 891, 922, 317, 348, 813, 844,
+  829, 860, 410, 441, 906, 937, 922, 953, 223, 254, 719, 750,
+  735,  766,  471,  502,  967,  998,  983, 1014,  286,  317,  782,  813,
+  798, 829, 441, 472, 937, 968, 953, 984, 380, 411, 876, 907,
+  892, 923, 255, 286, 751, 782, 767, 798, 472, 503, 968, 999,
+  984, 1015,  349,  380,  845,  876,  861,  892,  411,  442,  907,  938,
+  923, 954, 318, 349, 814, 845, 830, 861, 442, 473, 938, 969,
+  954,  985,  287,  318,  783,  814,  799,  830,  473,  504,  969, 1000,
+  985, 1016,  381,  412,  877,  908,  893,  924,  412,  443,  908,  939,
+  924, 955, 350, 381, 846, 877, 862, 893, 443, 474, 939, 970,
+  955,  986,  319,  350,  815,  846,  831,  862,  474,  505,  970, 1001,
+  986, 1017,  413,  444,  909,  940,  925,  956,  382,  413,  878,  909,
+  894, 925, 444, 475, 940, 971, 956, 987, 351, 382, 847, 878,
+  863,  894,  475,  506,  971, 1002,  987, 1018,  414,  445,  910,  941,
+  926, 957, 445, 476, 941, 972, 957, 988, 383, 414, 879, 910,
+  895,  926,  476,  507,  972, 1003,  988, 1019,  446,  477,  942,  973,
+  958,  989,  415,  446,  911,  942,  927,  958,  477,  508,  973, 1004,
+  989, 1020,  447,  478,  943,  974,  959,  990,  478,  509,  974, 1005,
+  990, 1021,  479,  510,  975, 1006,  991, 1022, 0, 0
+};
+#endif  // CONFIG_WAVELETS
+
 #if CONFIG_TX64X64
 DECLARE_ALIGNED(16, static const int16_t,
                 default_scan_64x64_neighbors[4097 * MAX_NEIGHBORS]) = {
@@ -2077,6 +2734,695 @@ DECLARE_ALIGNED(16, static const int16_t,
   3839, 3902, 4028, 4091, 3966, 4029, 3903, 3966,
   4029, 4092, 3967, 4030, 4030, 4093, 4031, 4094, 0, 0,
 };
+
+#if CONFIG_WAVELETS
+DECLARE_ALIGNED(16, static const int16_t,
+                dwtdct_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,  67, 130, 130, 193,   3,   3, 192, 192,   4,  67,
+  193, 256, 131, 194,  68, 131, 194, 257,   4,   4, 132, 195,
+  195, 258, 256, 256,   5,  68, 257, 320,  69, 132, 258, 321,
+  196, 259, 133, 196, 259, 322,   5,   5, 320, 320,   6,  69,
+  321, 384,  70, 133, 322, 385, 197, 260, 260, 323, 134, 197,
+  323, 386,   6,   6, 384, 384,   7,  70, 261, 324, 385, 448,
+  198, 261, 324, 387,  71, 134, 386, 449, 135, 198, 387, 450,
+  262, 325, 325, 388,   7,   7, 448, 448,   8,  71, 199, 262,
+  388, 451, 449, 512,  72, 135, 450, 513, 326, 389, 136, 199,
+  451, 514, 263, 326, 389, 452, 200, 263, 452, 515,   8,   8,
+  512, 512,   9,  72, 513, 576,  73, 136, 327, 390, 390, 453,
+  514, 577, 264, 327, 453, 516, 137, 200, 515, 578, 201, 264,
+  516, 579, 391, 454,   9,   9, 328, 391, 454, 517, 576, 576,
+  10,  73, 577, 640,  74, 137, 578, 641, 265, 328, 517, 580,
+  138, 201, 579, 642, 392, 455, 455, 518, 202, 265, 580, 643,
+  329, 392, 518, 581,  10,  10, 640, 640,  11,  74, 641, 704,
+  75, 138, 266, 329, 581, 644, 642, 705, 456, 519, 139, 202,
+  393, 456, 519, 582, 643, 706, 330, 393, 582, 645, 203, 266,
+  644, 707,  11,  11, 704, 704,  12,  75, 457, 520, 520, 583,
+  705, 768, 267, 330, 645, 708,  76, 139, 706, 769, 394, 457,
+  583, 646, 140, 203, 707, 770, 331, 394, 646, 709, 204, 267,
+  708, 771, 521, 584, 458, 521, 584, 647,  12,  12, 268, 331,
+  709, 772, 768, 768,  13,  76, 395, 458, 647, 710, 769, 832,
+  77, 140, 770, 833, 141, 204, 771, 834, 332, 395, 710, 773,
+  522, 585, 585, 648, 205, 268, 459, 522, 648, 711, 772, 835,
+  396, 459, 711, 774, 269, 332, 773, 836,  13,  13, 832, 832,
+  14,  77, 833, 896,  78, 141, 586, 649, 834, 897, 523, 586,
+  649, 712, 142, 205, 333, 396, 774, 837, 835, 898, 460, 523,
+  712, 775, 206, 269, 836, 899, 397, 460, 775, 838, 270, 333,
+  587, 650, 650, 713, 837, 900,  14,  14, 524, 587, 713, 776,
+  896, 896,  15,  78, 897, 960,  79, 142, 898, 961, 334, 397,
+  838, 901, 461, 524, 776, 839, 143, 206, 899, 962, 207, 270,
+  900, 963, 651, 714, 588, 651, 714, 777, 398, 461, 839, 902,
+  271, 334, 525, 588, 777, 840, 901, 964,  15,  15, 960, 960,
+  16,   79,  961, 1024,   80,  143,  462,  525,  840,  903,  962, 1025,
+  335,  398,  902,  965,  144,  207,  652,  715,  715,  778,  963, 1026,
+  589,  652,  778,  841,  208,  271,  964, 1027,  399,  462,  903,  966,
+  526,  589,  841,  904,  272,  335,  965, 1028,  716,  779,   16,   16,
+  463,  526,  904,  967, 1024, 1024,   17,   80,  653,  716,  779,  842,
+  1025, 1088,  336,  399,  966, 1029,   81,  144, 1026, 1089,  590,  653,
+  842,  905,  145,  208, 1027, 1090,  209,  272,  400,  463,  967, 1030,
+  1028, 1091,  527,  590,  905,  968,  717,  780,  780,  843,  273,  336,
+  1029, 1092,  654,  717,  843,  906,  464,  527,  968, 1031,   17,   17,
+  1088, 1088,   18,   81,  337,  400,  591,  654,  906,  969, 1030, 1093,
+  1089, 1152,   82,  145, 1090, 1153,  146,  209, 1091, 1154,  528,  591,
+  969, 1032,  401,  464,  781,  844, 1031, 1094,  210,  273,  718,  781,
+  844,  907, 1092, 1155,  655,  718,  907,  970,  274,  337, 1093, 1156,
+  465,  528, 1032, 1095,  592,  655,  970, 1033,  338,  401, 1094, 1157,
+  18,   18, 1152, 1152,   19,   82, 1153, 1216,   83,  146,  782,  845,
+  845,  908, 1154, 1217,  719,  782,  908,  971,  147,  210,  529,  592,
+  1033, 1096, 1155, 1218,  402,  465, 1095, 1158,  211,  274,  656,  719,
+  971, 1034, 1156, 1219,  275,  338, 1157, 1220,  466,  529, 1096, 1159,
+  593,  656, 1034, 1097,  846,  909,  783,  846,  909,  972,  339,  402,
+  1158, 1221,   19,   19,  720,  783,  972, 1035, 1216, 1216,   20,   83,
+  1217, 1280,   84,  147, 1218, 1281,  530,  593, 1097, 1160,  148,  211,
+  1219, 1282,  403,  466,  657,  720, 1035, 1098, 1159, 1222,  212,  275,
+  1220, 1283,  847,  910,  910,  973,  594,  657, 1098, 1161,  276,  339,
+  467,  530,  784,  847,  973, 1036, 1160, 1223, 1221, 1284,  721,  784,
+  1036, 1099,  340,  403, 1222, 1285,   20,   20, 1280, 1280,   21,   84,
+  531,  594, 1161, 1224, 1281, 1344,   85,  148,  658,  721, 1099, 1162,
+  1282, 1345,  404,  467, 1223, 1286,  149,  212,  911,  974, 1283, 1346,
+  848,  911,  974, 1037,  213,  276, 1284, 1347,  785,  848, 1037, 1100,
+  595,  658, 1162, 1225,  468,  531, 1224, 1287,  277,  340, 1285, 1348,
+  722,  785, 1100, 1163,  341,  404, 1286, 1349,  532,  595,  912,  975,
+  975, 1038, 1225, 1288,  659,  722, 1163, 1226,   21,   21, 1344, 1344,
+  22,   85,  849,  912, 1038, 1101, 1345, 1408,   86,  149, 1346, 1409,
+  405,  468, 1287, 1350,  150,  213,  786,  849, 1101, 1164, 1347, 1410,
+  214,  277,  596,  659, 1226, 1289, 1348, 1411,  469,  532,  723,  786,
+  1164, 1227, 1288, 1351,  278,  341, 1349, 1412,  976, 1039,  913,  976,
+  1039, 1102,  342,  405,  850,  913, 1102, 1165, 1350, 1413,  660,  723,
+  1227, 1290,  533,  596, 1289, 1352,   22,   22, 1408, 1408,   23,   86,
+  787,  850, 1165, 1228, 1409, 1472,   87,  150,  406,  469, 1351, 1414,
+  1410, 1473,  151,  214, 1411, 1474,  597,  660, 1290, 1353,  724,  787,
+  1228, 1291,  215,  278,  977, 1040, 1040, 1103, 1412, 1475,  470,  533,
+  1352, 1415,  914,  977, 1103, 1166,  279,  342, 1413, 1476,  851,  914,
+  1166, 1229,  661,  724, 1291, 1354,  343,  406,  534,  597, 1353, 1416,
+  1414, 1477,  788,  851, 1229, 1292,   23,   23, 1472, 1472,   24,   87,
+  1473, 1536,  407,  470, 1041, 1104, 1415, 1478,   88,  151,  978, 1041,
+  1104, 1167, 1474, 1537,  598,  661, 1354, 1417,  152,  215,  725,  788,
+  1292, 1355, 1475, 1538,  915,  978, 1167, 1230,  216,  279, 1476, 1539,
+  471,  534, 1416, 1479,  852,  915, 1230, 1293,  280,  343, 1477, 1540,
+  662,  725, 1355, 1418,  535,  598,  789,  852, 1293, 1356, 1417, 1480,
+  344,  407, 1478, 1541, 1042, 1105, 1105, 1168,  979, 1042, 1168, 1231,
+  24,   24,  408,  471,  916,  979, 1231, 1294, 1479, 1542, 1536, 1536,
+  25,   88, 1537, 1600,  726,  789, 1356, 1419,   89,  152,  599,  662,
+  1418, 1481, 1538, 1601,  153,  216, 1539, 1602,  853,  916, 1294, 1357,
+  472,  535, 1480, 1543,  217,  280, 1540, 1603, 1106, 1169,  281,  344,
+  663,  726, 1043, 1106, 1169, 1232, 1419, 1482, 1541, 1604,  790,  853,
+  1357, 1420,  980, 1043, 1232, 1295,  536,  599, 1481, 1544,  345,  408,
+  1542, 1605,  917,  980, 1295, 1358,  727,  790, 1420, 1483,  409,  472,
+  1543, 1606,   25,   25,  600,  663, 1482, 1545, 1600, 1600,   26,   89,
+  1601, 1664,   90,  153,  854,  917, 1358, 1421, 1602, 1665,  154,  217,
+  1107, 1170, 1170, 1233, 1603, 1666,  473,  536, 1044, 1107, 1233, 1296,
+  1544, 1607,  218,  281, 1604, 1667,  664,  727,  981, 1044, 1296, 1359,
+  1483, 1546,  791,  854, 1421, 1484,  282,  345, 1605, 1668,  537,  600,
+  1545, 1608,  918,  981, 1359, 1422,  346,  409, 1606, 1669,  728,  791,
+  1484, 1547, 1171, 1234, 1108, 1171, 1234, 1297,  410,  473,  601,  664,
+  855,  918, 1422, 1485, 1546, 1609, 1607, 1670,   26,   26, 1664, 1664,
+  27,   90, 1045, 1108, 1297, 1360, 1665, 1728,   91,  154, 1666, 1729,
+  155,  218, 1667, 1730,  474,  537,  982, 1045, 1360, 1423, 1608, 1671,
+  219,  282,  792,  855, 1485, 1548, 1668, 1731,  665,  728, 1547, 1610,
+  283,  346,  919,  982, 1423, 1486, 1669, 1732,  538,  601, 1609, 1672,
+  1172, 1235, 1235, 1298,  347,  410, 1109, 1172, 1298, 1361, 1670, 1733,
+  729,  792, 1548, 1611,  856,  919, 1486, 1549, 1046, 1109, 1361, 1424,
+  602,  665, 1610, 1673,  411,  474, 1671, 1734,   27,   27, 1728, 1728,
+  28,   91,  983, 1046, 1424, 1487, 1729, 1792,   92,  155, 1730, 1793,
+  156,  219,  475,  538, 1672, 1735, 1731, 1794,  793,  856, 1549, 1612,
+  666,  729, 1611, 1674,  220,  283, 1236, 1299, 1732, 1795,  920,  983,
+  1487, 1550, 1173, 1236, 1299, 1362, 1110, 1173, 1362, 1425,  284,  347,
+  1733, 1796,  539,  602, 1673, 1736, 1047, 1110, 1425, 1488,  348,  411,
+  730,  793, 1612, 1675, 1734, 1797,  857,  920, 1550, 1613,  603,  666,
+  1674, 1737,  984, 1047, 1488, 1551,  412,  475, 1735, 1798,   28,   28,
+  1237, 1300, 1300, 1363, 1792, 1792,   29,   92, 1793, 1856,   93,  156,
+  794,  857, 1174, 1237, 1363, 1426, 1613, 1676, 1794, 1857,  476,  539,
+  1736, 1799,  157,  220,  667,  730,  921,  984, 1551, 1614, 1675, 1738,
+  1795, 1858, 1111, 1174, 1426, 1489,  221,  284, 1796, 1859,  540,  603,
+  1048, 1111, 1489, 1552, 1737, 1800,  285,  348, 1797, 1860,  858,  921,
+  1614, 1677,  731,  794, 1676, 1739,  349,  412, 1798, 1861,  985, 1048,
+  1552, 1615, 1301, 1364,  604,  667, 1238, 1301, 1364, 1427, 1738, 1801,
+  413,  476, 1175, 1238, 1427, 1490, 1799, 1862,  795,  858, 1677, 1740,
+  29,   29, 1112, 1175, 1490, 1553, 1856, 1856,   30,   93,  922,  985,
+  1615, 1678, 1857, 1920,   94,  157, 1858, 1921,  477,  540,  668,  731,
+  1739, 1802, 1800, 1863,  158,  221, 1859, 1922, 1049, 1112, 1553, 1616,
+  222,  285, 1860, 1923,  541,  604, 1801, 1864,  286,  349,  859,  922,
+  1302, 1365, 1365, 1428, 1678, 1741, 1861, 1924,  732,  795, 1740, 1803,
+  1239, 1302, 1428, 1491,  986, 1049, 1616, 1679,  350,  413, 1862, 1925,
+  1176, 1239, 1491, 1554,  605,  668, 1802, 1865,  414,  477, 1113, 1176,
+  1554, 1617, 1863, 1926,  796,  859, 1741, 1804,  923,  986, 1679, 1742,
+  30,   30, 1920, 1920,   31,   94,  669,  732, 1803, 1866, 1921, 1984,
+  478,  541, 1864, 1927,   95,  158, 1050, 1113, 1617, 1680, 1922, 1985,
+  1366, 1429,  159,  222, 1303, 1366, 1429, 1492, 1923, 1986, 1240, 1303,
+  1492, 1555,  223,  286, 1924, 1987,  860,  923, 1742, 1805,  542,  605,
+  1865, 1928,  733,  796,  987, 1050, 1680, 1743, 1804, 1867,  287,  350,
+  1177, 1240, 1555, 1618, 1925, 1988,  351,  414, 1926, 1989,  606,  669,
+  1114, 1177, 1618, 1681, 1866, 1929,  924,  987, 1743, 1806,  415,  478,
+  797,  860, 1805, 1868, 1927, 1990, 1367, 1430, 1430, 1493, 1304, 1367,
+  1493, 1556, 1051, 1114, 1681, 1744,  670,  733, 1867, 1930,  479,  542,
+  1241, 1304, 1556, 1619, 1928, 1991,  861,  924, 1178, 1241, 1619, 1682,
+  1806, 1869,  988, 1051, 1744, 1807,  543,  606, 1929, 1992,  734,  797,
+  1868, 1931, 1115, 1178, 1682, 1745, 1431, 1494, 1368, 1431, 1494, 1557,
+  607,  670, 1930, 1993,  925,  988, 1305, 1368, 1557, 1620, 1807, 1870,
+  798,  861, 1869, 1932, 1052, 1115, 1745, 1808, 1242, 1305, 1620, 1683,
+  671,  734, 1931, 1994, 1179, 1242, 1683, 1746,  862,  925, 1870, 1933,
+  989, 1052, 1808, 1871,  735,  798, 1432, 1495, 1495, 1558, 1932, 1995,
+  1116, 1179, 1746, 1809, 1369, 1432, 1558, 1621, 1306, 1369, 1621, 1684,
+  926,  989, 1871, 1934, 1243, 1306, 1684, 1747,  799,  862, 1053, 1116,
+  1809, 1872, 1933, 1996, 1180, 1243, 1747, 1810, 1496, 1559, 1433, 1496,
+  1559, 1622,  990, 1053, 1872, 1935,  863,  926, 1934, 1997, 1370, 1433,
+  1622, 1685, 1117, 1180, 1810, 1873, 1307, 1370, 1685, 1748, 1244, 1307,
+  1748, 1811,  927,  990, 1935, 1998, 1054, 1117, 1873, 1936, 1497, 1560,
+  1560, 1623, 1181, 1244, 1811, 1874, 1434, 1497, 1623, 1686, 1371, 1434,
+  1686, 1749,  991, 1054, 1936, 1999, 1118, 1181, 1874, 1937, 1308, 1371,
+  1749, 1812, 1245, 1308, 1812, 1875, 1055, 1118, 1561, 1624, 1937, 2000,
+  1498, 1561, 1624, 1687, 1435, 1498, 1687, 1750, 1182, 1245, 1875, 1938,
+  1372, 1435, 1750, 1813, 1309, 1372, 1813, 1876, 1119, 1182, 1938, 2001,
+  1246, 1309, 1876, 1939, 1562, 1625, 1625, 1688, 1499, 1562, 1688, 1751,
+  1436, 1499, 1751, 1814, 1183, 1246, 1939, 2002, 1373, 1436, 1814, 1877,
+  1310, 1373, 1877, 1940, 1626, 1689, 1563, 1626, 1689, 1752, 1500, 1563,
+  1752, 1815, 1247, 1310, 1940, 2003, 1437, 1500, 1815, 1878, 1374, 1437,
+  1878, 1941, 1311, 1374, 1941, 2004, 1627, 1690, 1690, 1753, 1564, 1627,
+  1753, 1816, 1501, 1564, 1816, 1879, 1438, 1501, 1879, 1942, 1375, 1438,
+  1942, 2005, 1691, 1754, 1628, 1691, 1754, 1817, 1565, 1628, 1817, 1880,
+  1502, 1565, 1880, 1943, 1439, 1502, 1943, 2006, 1692, 1755, 1755, 1818,
+  1629, 1692, 1818, 1881, 1566, 1629, 1881, 1944, 1503, 1566, 1944, 2007,
+  1756, 1819, 1693, 1756, 1819, 1882, 1630, 1693, 1882, 1945, 1567, 1630,
+  1945, 2008, 1757, 1820, 1820, 1883, 1694, 1757, 1883, 1946, 1631, 1694,
+  1946, 2009, 1821, 1884, 1758, 1821, 1884, 1947, 1695, 1758, 1947, 2010,
+  1822, 1885, 1885, 1948, 1759, 1822, 1948, 2011, 1886, 1949, 1823, 1886,
+  1949, 2012, 1887, 1950, 1950, 2013, 1951, 2014,    0,    0,    0,    0,
+  0,    0,   32,   32, 2048, 2048, 2080, 2080,   32,   32, 2048, 2048,
+  2080, 2080,   33,   96, 2049, 2112, 2081, 2144,   33,   33, 2049, 2049,
+  2081, 2081,   96,   96, 2112, 2112, 2144, 2144,   34,   97, 2050, 2113,
+  2082, 2145,   97,  160, 2113, 2176, 2145, 2208,   98,  161, 2114, 2177,
+  2146, 2209,   34,   34, 2050, 2050, 2082, 2082,  160,  160, 2176, 2176,
+  2208, 2208,   35,   98, 2051, 2114, 2083, 2146,  161,  224, 2177, 2240,
+  2209, 2272,   99,  162, 2115, 2178, 2147, 2210,  162,  225, 2178, 2241,
+  2210, 2273,   35,   35, 2051, 2051, 2083, 2083,  224,  224, 2240, 2240,
+  2272, 2272,   36,   99, 2052, 2115, 2084, 2147,  225,  288, 2241, 2304,
+  2273, 2336,  163,  226, 2179, 2242, 2211, 2274,  100,  163, 2116, 2179,
+  2148, 2211,  226,  289, 2242, 2305, 2274, 2337,   36,   36, 2052, 2052,
+  2084, 2084,  164,  227, 2180, 2243, 2212, 2275,  227,  290, 2243, 2306,
+  2275, 2338,  288,  288, 2304, 2304, 2336, 2336,   37,  100, 2053, 2116,
+  2085, 2148,  289,  352, 2305, 2368, 2337, 2400,  101,  164, 2117, 2180,
+  2149, 2212,  290,  353, 2306, 2369, 2338, 2401,  228,  291, 2244, 2307,
+  2276, 2339,  165,  228, 2181, 2244, 2213, 2276,  291,  354, 2307, 2370,
+  2339, 2402,   37,   37, 2053, 2053, 2085, 2085,  352,  352, 2368, 2368,
+  2400, 2400,   38,  101, 2054, 2117, 2086, 2149,  353,  416, 2369, 2432,
+  2401, 2464,  102,  165, 2118, 2181, 2150, 2213,  354,  417, 2370, 2433,
+  2402, 2465,  229,  292, 2245, 2308, 2277, 2340,  292,  355, 2308, 2371,
+  2340, 2403,  166,  229, 2182, 2245, 2214, 2277,  355,  418, 2371, 2434,
+  2403, 2466,   38,   38, 2054, 2054, 2086, 2086,  416,  416, 2432, 2432,
+  2464, 2464,   39,  102, 2055, 2118, 2087, 2150,  293,  356, 2309, 2372,
+  2341, 2404,  417,  480, 2433, 2496, 2465, 2528,  230,  293, 2246, 2309,
+  2278, 2341,  356,  419, 2372, 2435, 2404, 2467,  103,  166, 2119, 2182,
+  2151, 2214,  418,  481, 2434, 2497, 2466, 2529,  167,  230, 2183, 2246,
+  2215, 2278,  419,  482, 2435, 2498, 2467, 2530,  294,  357, 2310, 2373,
+  2342, 2405,  357,  420, 2373, 2436, 2405, 2468,   39,   39, 2055, 2055,
+  2087, 2087,  480,  480, 2496, 2496, 2528, 2528,   40,  103, 2056, 2119,
+  2088, 2151,  231,  294, 2247, 2310, 2279, 2342,  420,  483, 2436, 2499,
+  2468, 2531,  481,  544, 2497, 2560, 2529, 2592,  104,  167, 2120, 2183,
+  2152, 2215,  482,  545, 2498, 2561, 2530, 2593,  358,  421, 2374, 2437,
+  2406, 2469,  168,  231, 2184, 2247, 2216, 2279,  483,  546, 2499, 2562,
+  2531, 2594,  295,  358, 2311, 2374, 2343, 2406,  421,  484, 2437, 2500,
+  2469, 2532,  232,  295, 2248, 2311, 2280, 2343,  484,  547, 2500, 2563,
+  2532, 2595,   40,   40, 2056, 2056, 2088, 2088,  544,  544, 2560, 2560,
+  2592, 2592,   41,  104, 2057, 2120, 2089, 2152,  545,  608, 2561, 2624,
+  2593, 2656,  105,  168, 2121, 2184, 2153, 2216,  359,  422, 2375, 2438,
+  2407, 2470,  422,  485, 2438, 2501, 2470, 2533,  546,  609, 2562, 2625,
+  2594, 2657,  296,  359, 2312, 2375, 2344, 2407,  485,  548, 2501, 2564,
+  2533, 2596,  169,  232, 2185, 2248, 2217, 2280,  547,  610, 2563, 2626,
+  2595, 2658,  233,  296, 2249, 2312, 2281, 2344,  548,  611, 2564, 2627,
+  2596, 2659,  423,  486, 2439, 2502, 2471, 2534,   41,   41, 2057, 2057,
+  2089, 2089,  360,  423, 2376, 2439, 2408, 2471,  486,  549, 2502, 2565,
+  2534, 2597,  608,  608, 2624, 2624, 2656, 2656,   42,  105, 2058, 2121,
+  2090, 2153,  609,  672, 2625, 2688, 2657, 2720,  106,  169, 2122, 2185,
+  2154, 2217,  610,  673, 2626, 2689, 2658, 2721,  297,  360, 2313, 2376,
+  2345, 2408,  549,  612, 2565, 2628, 2597, 2660,  170,  233, 2186, 2249,
+  2218, 2281,  611,  674, 2627, 2690, 2659, 2722,  424,  487, 2440, 2503,
+  2472, 2535,  487,  550, 2503, 2566, 2535, 2598,  234,  297, 2250, 2313,
+  2282, 2345,  612,  675, 2628, 2691, 2660, 2723,  361,  424, 2377, 2440,
+  2409, 2472,  550,  613, 2566, 2629, 2598, 2661,   42,   42, 2058, 2058,
+  2090, 2090,  672,  672, 2688, 2688, 2720, 2720,   43,  106, 2059, 2122,
+  2091, 2154,  673,  736, 2689, 2752, 2721, 2784,  107,  170, 2123, 2186,
+  2155, 2218,  298,  361, 2314, 2377, 2346, 2409,  613,  676, 2629, 2692,
+  2661, 2724,  674,  737, 2690, 2753, 2722, 2785,  488,  551, 2504, 2567,
+  2536, 2599,  171,  234, 2187, 2250, 2219, 2282,  425,  488, 2441, 2504,
+  2473, 2536,  551,  614, 2567, 2630, 2599, 2662,  675,  738, 2691, 2754,
+  2723, 2786,  362,  425, 2378, 2441, 2410, 2473,  614,  677, 2630, 2693,
+  2662, 2725,  235,  298, 2251, 2314, 2283, 2346,  676,  739, 2692, 2755,
+  2724, 2787,   43,   43, 2059, 2059, 2091, 2091,  736,  736, 2752, 2752,
+  2784, 2784,   44,  107, 2060, 2123, 2092, 2155,  489,  552, 2505, 2568,
+  2537, 2600,  552,  615, 2568, 2631, 2600, 2663,  737,  800, 2753, 2816,
+  2785, 2848,  299,  362, 2315, 2378, 2347, 2410,  677,  740, 2693, 2756,
+  2725, 2788,  108,  171, 2124, 2187, 2156, 2219,  738,  801, 2754, 2817,
+  2786, 2849,  426,  489, 2442, 2505, 2474, 2537,  615,  678, 2631, 2694,
+  2663, 2726,  172,  235, 2188, 2251, 2220, 2283,  739,  802, 2755, 2818,
+  2787, 2850,  363,  426, 2379, 2442, 2411, 2474,  678,  741, 2694, 2757,
+  2726, 2789,  236,  299, 2252, 2315, 2284, 2347,  740,  803, 2756, 2819,
+  2788, 2851,  553,  616, 2569, 2632, 2601, 2664,  490,  553, 2506, 2569,
+  2538, 2601,  616,  679, 2632, 2695, 2664, 2727,   44,   44, 2060, 2060,
+  2092, 2092,  300,  363, 2316, 2379, 2348, 2411,  741,  804, 2757, 2820,
+  2789, 2852,  800,  800, 2816, 2816, 2848, 2848,   45,  108, 2061, 2124,
+  2093, 2156,  427,  490, 2443, 2506, 2475, 2538,  679,  742, 2695, 2758,
+  2727, 2790,  801,  864, 2817, 2880, 2849, 2912,  109,  172, 2125, 2188,
+  2157, 2220,  802,  865, 2818, 2881, 2850, 2913,  173,  236, 2189, 2252,
+  2221, 2284,  803,  866, 2819, 2882, 2851, 2914,  364,  427, 2380, 2443,
+  2412, 2475,  742,  805, 2758, 2821, 2790, 2853,  554,  617, 2570, 2633,
+  2602, 2665,  617,  680, 2633, 2696, 2665, 2728,  237,  300, 2253, 2316,
+  2285, 2348,  491,  554, 2507, 2570, 2539, 2602,  680,  743, 2696, 2759,
+  2728, 2791,  804,  867, 2820, 2883, 2852, 2915,  428,  491, 2444, 2507,
+  2476, 2539,  743,  806, 2759, 2822, 2791, 2854,  301,  364, 2317, 2380,
+  2349, 2412,  805,  868, 2821, 2884, 2853, 2916,   45,   45, 2061, 2061,
+  2093, 2093,  864,  864, 2880, 2880, 2912, 2912,   46,  109, 2062, 2125,
+  2094, 2157,  865,  928, 2881, 2944, 2913, 2976,  110,  173, 2126, 2189,
+  2158, 2221,  618,  681, 2634, 2697, 2666, 2729,  866,  929, 2882, 2945,
+  2914, 2977,  555,  618, 2571, 2634, 2603, 2666,  681,  744, 2697, 2760,
+  2729, 2792,  174,  237, 2190, 2253, 2222, 2285,  365,  428, 2381, 2444,
+  2413, 2476,  806,  869, 2822, 2885, 2854, 2917,  867,  930, 2883, 2946,
+  2915, 2978,  492,  555, 2508, 2571, 2540, 2603,  744,  807, 2760, 2823,
+  2792, 2855,  238,  301, 2254, 2317, 2286, 2349,  868,  931, 2884, 2947,
+  2916, 2979,  429,  492, 2445, 2508, 2477, 2540,  807,  870, 2823, 2886,
+  2855, 2918,  302,  365, 2318, 2381, 2350, 2413,  619,  682, 2635, 2698,
+  2667, 2730,  682,  745, 2698, 2761, 2730, 2793,  869,  932, 2885, 2948,
+  2917, 2980,   46,   46, 2062, 2062, 2094, 2094,  556,  619, 2572, 2635,
+  2604, 2667,  745,  808, 2761, 2824, 2793, 2856,  928,  928, 2944, 2944,
+  2976, 2976,   47,  110, 2063, 2126, 2095, 2158,  929,  992, 2945, 3008,
+  2977, 3040,  111,  174, 2127, 2190, 2159, 2222,  930,  993, 2946, 3009,
+  2978, 3041,  366,  429, 2382, 2445, 2414, 2477,  870,  933, 2886, 2949,
+  2918, 2981,  493,  556, 2509, 2572, 2541, 2604,  808,  871, 2824, 2887,
+  2856, 2919,  175,  238, 2191, 2254, 2223, 2286,  931,  994, 2947, 3010,
+  2979, 3042,  239,  302, 2255, 2318, 2287, 2350,  932,  995, 2948, 3011,
+  2980, 3043,  683,  746, 2699, 2762, 2731, 2794,  620,  683, 2636, 2699,
+  2668, 2731,  746,  809, 2762, 2825, 2794, 2857,  430,  493, 2446, 2509,
+  2478, 2541,  871,  934, 2887, 2950, 2919, 2982,  303,  366, 2319, 2382,
+  2351, 2414,  557,  620, 2573, 2636, 2605, 2668,  809,  872, 2825, 2888,
+  2857, 2920,  933,  996, 2949, 3012, 2981, 3044,   47,   47, 2063, 2063,
+  2095, 2095,  992,  992, 3008, 3008, 3040, 3040,   48,  111, 2064, 2127,
+  2096, 2159,  993, 1056, 3009, 3072, 3041, 3104,  112,  175, 2128, 2191,
+  2160, 2223,  494,  557, 2510, 2573, 2542, 2605,  872,  935, 2888, 2951,
+  2920, 2983,  994, 1057, 3010, 3073, 3042, 3105,  367,  430, 2383, 2446,
+  2415, 2478,  934,  997, 2950, 3013, 2982, 3045,  176,  239, 2192, 2255,
+  2224, 2287,  684,  747, 2700, 2763, 2732, 2795,  747,  810, 2763, 2826,
+  2795, 2858,  995, 1058, 3011, 3074, 3043, 3106,  621,  684, 2637, 2700,
+  2669, 2732,  810,  873, 2826, 2889, 2858, 2921,  240,  303, 2256, 2319,
+  2288, 2351,  996, 1059, 3012, 3075, 3044, 3107,  431,  494, 2447, 2510,
+  2479, 2542,  935,  998, 2951, 3014, 2983, 3046,  558,  621, 2574, 2637,
+  2606, 2669,  873,  936, 2889, 2952, 2921, 2984,  304,  367, 2320, 2383,
+  2352, 2415,  997, 1060, 3013, 3076, 3045, 3108,  748,  811, 2764, 2827,
+  2796, 2859,   48,   48, 2064, 2064, 2096, 2096,  495,  558, 2511, 2574,
+  2543, 2606,  936,  999, 2952, 3015, 2984, 3047, 1056, 1056, 3072, 3072,
+  3104, 3104,   49,  112, 2065, 2128, 2097, 2160,  685,  748, 2701, 2764,
+  2733, 2796,  811,  874, 2827, 2890, 2859, 2922, 1057, 1120, 3073, 3136,
+  3105, 3168,  368,  431, 2384, 2447, 2416, 2479,  998, 1061, 3014, 3077,
+  3046, 3109,  113,  176, 2129, 2192, 2161, 2224, 1058, 1121, 3074, 3137,
+  3106, 3169,  622,  685, 2638, 2701, 2670, 2733,  874,  937, 2890, 2953,
+  2922, 2985,  177,  240, 2193, 2256, 2225, 2288, 1059, 1122, 3075, 3138,
+  3107, 3170,  241,  304, 2257, 2320, 2289, 2352,  432,  495, 2448, 2511,
+  2480, 2543,  999, 1062, 3015, 3078, 3047, 3110, 1060, 1123, 3076, 3139,
+  3108, 3171,  559,  622, 2575, 2638, 2607, 2670,  937, 1000, 2953, 3016,
+  2985, 3048,  749,  812, 2765, 2828, 2797, 2860,  812,  875, 2828, 2891,
+  2860, 2923,  305,  368, 2321, 2384, 2353, 2416, 1061, 1124, 3077, 3140,
+  3109, 3172,  686,  749, 2702, 2765, 2734, 2797,  875,  938, 2891, 2954,
+  2923, 2986,  496,  559, 2512, 2575, 2544, 2607, 1000, 1063, 3016, 3079,
+  3048, 3111,   49,   49, 2065, 2065, 2097, 2097, 1120, 1120, 3136, 3136,
+  3168, 3168,   50,  113, 2066, 2129, 2098, 2161,  369,  432, 2385, 2448,
+  2417, 2480,  623,  686, 2639, 2702, 2671, 2734,  938, 1001, 2954, 3017,
+  2986, 3049, 1062, 1125, 3078, 3141, 3110, 3173, 1121, 1184, 3137, 3200,
+  3169, 3232,  114,  177, 2130, 2193, 2162, 2225, 1122, 1185, 3138, 3201,
+  3170, 3233,  178,  241, 2194, 2257, 2226, 2289, 1123, 1186, 3139, 3202,
+  3171, 3234,  560,  623, 2576, 2639, 2608, 2671, 1001, 1064, 3017, 3080,
+  3049, 3112,  433,  496, 2449, 2512, 2481, 2544,  813,  876, 2829, 2892,
+  2861, 2924, 1063, 1126, 3079, 3142, 3111, 3174,  242,  305, 2258, 2321,
+  2290, 2353,  750,  813, 2766, 2829, 2798, 2861,  876,  939, 2892, 2955,
+  2924, 2987, 1124, 1187, 3140, 3203, 3172, 3235,  687,  750, 2703, 2766,
+  2735, 2798,  939, 1002, 2955, 3018, 2987, 3050,  306,  369, 2322, 2385,
+  2354, 2417, 1125, 1188, 3141, 3204, 3173, 3236,  497,  560, 2513, 2576,
+  2545, 2608, 1064, 1127, 3080, 3143, 3112, 3175,  624,  687, 2640, 2703,
+  2672, 2735, 1002, 1065, 3018, 3081, 3050, 3113,  370,  433, 2386, 2449,
+  2418, 2481, 1126, 1189, 3142, 3205, 3174, 3237,   50,   50, 2066, 2066,
+  2098, 2098, 1184, 1184, 3200, 3200, 3232, 3232,   51,  114, 2067, 2130,
+  2099, 2162, 1185, 1248, 3201, 3264, 3233, 3296,  115,  178, 2131, 2194,
+  2163, 2226,  814,  877, 2830, 2893, 2862, 2925,  877,  940, 2893, 2956,
+  2925, 2988, 1186, 1249, 3202, 3265, 3234, 3297,  751,  814, 2767, 2830,
+  2799, 2862,  940, 1003, 2956, 3019, 2988, 3051,  179,  242, 2195, 2258,
+  2227, 2290,  561,  624, 2577, 2640, 2609, 2672, 1065, 1128, 3081, 3144,
+  3113, 3176, 1187, 1250, 3203, 3266, 3235, 3298,  434,  497, 2450, 2513,
+  2482, 2545, 1127, 1190, 3143, 3206, 3175, 3238,  243,  306, 2259, 2322,
+  2291, 2354,  688,  751, 2704, 2767, 2736, 2799, 1003, 1066, 3019, 3082,
+  3051, 3114, 1188, 1251, 3204, 3267, 3236, 3299,  307,  370, 2323, 2386,
+  2355, 2418, 1189, 1252, 3205, 3268, 3237, 3300,  498,  561, 2514, 2577,
+  2546, 2609, 1128, 1191, 3144, 3207, 3176, 3239,  625,  688, 2641, 2704,
+  2673, 2736, 1066, 1129, 3082, 3145, 3114, 3177,  878,  941, 2894, 2957,
+  2926, 2989,  815,  878, 2831, 2894, 2863, 2926,  941, 1004, 2957, 3020,
+  2989, 3052,  371,  434, 2387, 2450, 2419, 2482, 1190, 1253, 3206, 3269,
+  3238, 3301,   51,   51, 2067, 2067, 2099, 2099,  752,  815, 2768, 2831,
+  2800, 2863, 1004, 1067, 3020, 3083, 3052, 3115, 1248, 1248, 3264, 3264,
+  3296, 3296,   52,  115, 2068, 2131, 2100, 2163, 1249, 1312, 3265, 3328,
+  3297, 3360,  116,  179, 2132, 2195, 2164, 2227, 1250, 1313, 3266, 3329,
+  3298, 3361,  562,  625, 2578, 2641, 2610, 2673, 1129, 1192, 3145, 3208,
+  3177, 3240,  180,  243, 2196, 2259, 2228, 2291, 1251, 1314, 3267, 3330,
+  3299, 3362,  435,  498, 2451, 2514, 2483, 2546,  689,  752, 2705, 2768,
+  2737, 2800, 1067, 1130, 3083, 3146, 3115, 3178, 1191, 1254, 3207, 3270,
+  3239, 3302,  244,  307, 2260, 2323, 2292, 2355, 1252, 1315, 3268, 3331,
+  3300, 3363,  879,  942, 2895, 2958, 2927, 2990,  942, 1005, 2958, 3021,
+  2990, 3053,  626,  689, 2642, 2705, 2674, 2737, 1130, 1193, 3146, 3209,
+  3178, 3241,  308,  371, 2324, 2387, 2356, 2419,  499,  562, 2515, 2578,
+  2547, 2610,  816,  879, 2832, 2895, 2864, 2927, 1005, 1068, 3021, 3084,
+  3053, 3116, 1192, 1255, 3208, 3271, 3240, 3303, 1253, 1316, 3269, 3332,
+  3301, 3364,  753,  816, 2769, 2832, 2801, 2864, 1068, 1131, 3084, 3147,
+  3116, 3179,  372,  435, 2388, 2451, 2420, 2483, 1254, 1317, 3270, 3333,
+  3302, 3365,   52,   52, 2068, 2068, 2100, 2100, 1312, 1312, 3328, 3328,
+  3360, 3360,   53,  116, 2069, 2132, 2101, 2164,  563,  626, 2579, 2642,
+  2611, 2674, 1193, 1256, 3209, 3272, 3241, 3304, 1313, 1376, 3329, 3392,
+  3361, 3424,  117,  180, 2133, 2196, 2165, 2228,  690,  753, 2706, 2769,
+  2738, 2801, 1131, 1194, 3147, 3210, 3179, 3242, 1314, 1377, 3330, 3393,
+  3362, 3425,  436,  499, 2452, 2515, 2484, 2547, 1255, 1318, 3271, 3334,
+  3303, 3366,  181,  244, 2197, 2260, 2229, 2292,  943, 1006, 2959, 3022,
+  2991, 3054, 1315, 1378, 3331, 3394, 3363, 3426,  880,  943, 2896, 2959,
+  2928, 2991, 1006, 1069, 3022, 3085, 3054, 3117,  245,  308, 2261, 2324,
+  2293, 2356, 1316, 1379, 3332, 3395, 3364, 3427,  817,  880, 2833, 2896,
+  2865, 2928, 1069, 1132, 3085, 3148, 3117, 3180,  627,  690, 2643, 2706,
+  2675, 2738, 1194, 1257, 3210, 3273, 3242, 3305,  500,  563, 2516, 2579,
+  2548, 2611, 1256, 1319, 3272, 3335, 3304, 3367,  309,  372, 2325, 2388,
+  2357, 2420, 1317, 1380, 3333, 3396, 3365, 3428,  754,  817, 2770, 2833,
+  2802, 2865, 1132, 1195, 3148, 3211, 3180, 3243,  373,  436, 2389, 2452,
+  2421, 2484, 1318, 1381, 3334, 3397, 3366, 3429,  564,  627, 2580, 2643,
+  2612, 2675,  944, 1007, 2960, 3023, 2992, 3055, 1007, 1070, 3023, 3086,
+  3055, 3118, 1257, 1320, 3273, 3336, 3305, 3368,  691,  754, 2707, 2770,
+  2739, 2802, 1195, 1258, 3211, 3274, 3243, 3306,   53,   53, 2069, 2069,
+  2101, 2101, 1376, 1376, 3392, 3392, 3424, 3424,   54,  117, 2070, 2133,
+  2102, 2165,  881,  944, 2897, 2960, 2929, 2992, 1070, 1133, 3086, 3149,
+  3118, 3181, 1377, 1440, 3393, 3456, 3425, 3488,  118,  181, 2134, 2197,
+  2166, 2229, 1378, 1441, 3394, 3457, 3426, 3489,  437,  500, 2453, 2516,
+  2485, 2548, 1319, 1382, 3335, 3398, 3367, 3430,  182,  245, 2198, 2261,
+  2230, 2293,  818,  881, 2834, 2897, 2866, 2929, 1133, 1196, 3149, 3212,
+  3181, 3244, 1379, 1442, 3395, 3458, 3427, 3490,  246,  309, 2262, 2325,
+  2294, 2357,  628,  691, 2644, 2707, 2676, 2739, 1258, 1321, 3274, 3337,
+  3306, 3369, 1380, 1443, 3396, 3459, 3428, 3491,  501,  564, 2517, 2580,
+  2549, 2612,  755,  818, 2771, 2834, 2803, 2866, 1196, 1259, 3212, 3275,
+  3244, 3307, 1320, 1383, 3336, 3399, 3368, 3431,  310,  373, 2326, 2389,
+  2358, 2421, 1381, 1444, 3397, 3460, 3429, 3492, 1008, 1071, 3024, 3087,
+  3056, 3119,  945, 1008, 2961, 3024, 2993, 3056, 1071, 1134, 3087, 3150,
+  3119, 3182,  374,  437, 2390, 2453, 2422, 2485,  882,  945, 2898, 2961,
+  2930, 2993, 1134, 1197, 3150, 3213, 3182, 3245, 1382, 1445, 3398, 3461,
+  3430, 3493,  692,  755, 2708, 2771, 2740, 2803, 1259, 1322, 3275, 3338,
+  3307, 3370,  565,  628, 2581, 2644, 2613, 2676, 1321, 1384, 3337, 3400,
+  3369, 3432,   54,   54, 2070, 2070, 2102, 2102, 1440, 1440, 3456, 3456,
+  3488, 3488,   55,  118, 2071, 2134, 2103, 2166,  819,  882, 2835, 2898,
+  2867, 2930, 1197, 1260, 3213, 3276, 3245, 3308, 1441, 1504, 3457, 3520,
+  3489, 3552,  119,  182, 2135, 2198, 2167, 2230,  438,  501, 2454, 2517,
+  2486, 2549, 1383, 1446, 3399, 3462, 3431, 3494, 1442, 1505, 3458, 3521,
+  3490, 3553,  183,  246, 2199, 2262, 2231, 2294, 1443, 1506, 3459, 3522,
+  3491, 3554,  629,  692, 2645, 2708, 2677, 2740, 1322, 1385, 3338, 3401,
+  3370, 3433,  756,  819, 2772, 2835, 2804, 2867, 1260, 1323, 3276, 3339,
+  3308, 3371,  247,  310, 2263, 2326, 2295, 2358, 1009, 1072, 3025, 3088,
+  3057, 3120, 1072, 1135, 3088, 3151, 3120, 3183, 1444, 1507, 3460, 3523,
+  3492, 3555,  502,  565, 2518, 2581, 2550, 2613, 1384, 1447, 3400, 3463,
+  3432, 3495,  946, 1009, 2962, 3025, 2994, 3057, 1135, 1198, 3151, 3214,
+  3183, 3246,  311,  374, 2327, 2390, 2359, 2422, 1445, 1508, 3461, 3524,
+  3493, 3556,  883,  946, 2899, 2962, 2931, 2994, 1198, 1261, 3214, 3277,
+  3246, 3309,  693,  756, 2709, 2772, 2741, 2804, 1323, 1386, 3339, 3402,
+  3371, 3434,  375,  438, 2391, 2454, 2423, 2486,  566,  629, 2582, 2645,
+  2614, 2677, 1385, 1448, 3401, 3464, 3433, 3496, 1446, 1509, 3462, 3525,
+  3494, 3557,  820,  883, 2836, 2899, 2868, 2931, 1261, 1324, 3277, 3340,
+  3309, 3372,   55,   55, 2071, 2071, 2103, 2103, 1504, 1504, 3520, 3520,
+  3552, 3552,   56,  119, 2072, 2135, 2104, 2167, 1505, 1568, 3521, 3584,
+  3553, 3616,  439,  502, 2455, 2518, 2487, 2550, 1073, 1136, 3089, 3152,
+  3121, 3184, 1447, 1510, 3463, 3526, 3495, 3558,  120,  183, 2136, 2199,
+  2168, 2231, 1010, 1073, 3026, 3089, 3058, 3121, 1136, 1199, 3152, 3215,
+  3184, 3247, 1506, 1569, 3522, 3585, 3554, 3617,  630,  693, 2646, 2709,
+  2678, 2741, 1386, 1449, 3402, 3465, 3434, 3497,  184,  247, 2200, 2263,
+  2232, 2295,  757,  820, 2773, 2836, 2805, 2868, 1324, 1387, 3340, 3403,
+  3372, 3435, 1507, 1570, 3523, 3586, 3555, 3618,  947, 1010, 2963, 3026,
+  2995, 3058, 1199, 1262, 3215, 3278, 3247, 3310,  248,  311, 2264, 2327,
+  2296, 2359, 1508, 1571, 3524, 3587, 3556, 3619,  503,  566, 2519, 2582,
+  2551, 2614, 1448, 1511, 3464, 3527, 3496, 3559,  884,  947, 2900, 2963,
+  2932, 2995, 1262, 1325, 3278, 3341, 3310, 3373,  312,  375, 2328, 2391,
+  2360, 2423, 1509, 1572, 3525, 3588, 3557, 3620,  694,  757, 2710, 2773,
+  2742, 2805, 1387, 1450, 3403, 3466, 3435, 3498,  567,  630, 2583, 2646,
+  2615, 2678,  821,  884, 2837, 2900, 2869, 2932, 1325, 1388, 3341, 3404,
+  3373, 3436, 1449, 1512, 3465, 3528, 3497, 3560,  376,  439, 2392, 2455,
+  2424, 2487, 1510, 1573, 3526, 3589, 3558, 3621, 1074, 1137, 3090, 3153,
+  3122, 3185, 1137, 1200, 3153, 3216, 3185, 3248, 1011, 1074, 3027, 3090,
+  3059, 3122, 1200, 1263, 3216, 3279, 3248, 3311,   56,   56, 2072, 2072,
+  2104, 2104,  440,  503, 2456, 2519, 2488, 2551,  948, 1011, 2964, 3027,
+  2996, 3059, 1263, 1326, 3279, 3342, 3311, 3374, 1511, 1574, 3527, 3590,
+  3559, 3622, 1568, 1568, 3584, 3584, 3616, 3616,   57,  120, 2073, 2136,
+  2105, 2168, 1569, 1632, 3585, 3648, 3617, 3680,  758,  821, 2774, 2837,
+  2806, 2869, 1388, 1451, 3404, 3467, 3436, 3499,  121,  184, 2137, 2200,
+  2169, 2232,  631,  694, 2647, 2710, 2679, 2742, 1450, 1513, 3466, 3529,
+  3498, 3561, 1570, 1633, 3586, 3649, 3618, 3681,  185,  248, 2201, 2264,
+  2233, 2296, 1571, 1634, 3587, 3650, 3619, 3682,  885,  948, 2901, 2964,
+  2933, 2996, 1326, 1389, 3342, 3405, 3374, 3437,  504,  567, 2520, 2583,
+  2552, 2615, 1512, 1575, 3528, 3591, 3560, 3623,  249,  312, 2265, 2328,
+  2297, 2360, 1572, 1635, 3588, 3651, 3620, 3683, 1138, 1201, 3154, 3217,
+  3186, 3249,  313,  376, 2329, 2392, 2361, 2424,  695,  758, 2711, 2774,
+  2743, 2806, 1075, 1138, 3091, 3154, 3123, 3186, 1201, 1264, 3217, 3280,
+  3249, 3312, 1451, 1514, 3467, 3530, 3499, 3562, 1573, 1636, 3589, 3652,
+  3621, 3684,  822,  885, 2838, 2901, 2870, 2933, 1389, 1452, 3405, 3468,
+  3437, 3500, 1012, 1075, 3028, 3091, 3060, 3123, 1264, 1327, 3280, 3343,
+  3312, 3375,  568,  631, 2584, 2647, 2616, 2679, 1513, 1576, 3529, 3592,
+  3561, 3624,  377,  440, 2393, 2456, 2425, 2488, 1574, 1637, 3590, 3653,
+  3622, 3685,  949, 1012, 2965, 3028, 2997, 3060, 1327, 1390, 3343, 3406,
+  3375, 3438,  759,  822, 2775, 2838, 2807, 2870, 1452, 1515, 3468, 3531,
+  3500, 3563,  441,  504, 2457, 2520, 2489, 2552, 1575, 1638, 3591, 3654,
+  3623, 3686,   57,   57, 2073, 2073, 2105, 2105,  632,  695, 2648, 2711,
+  2680, 2743, 1514, 1577, 3530, 3593, 3562, 3625, 1632, 1632, 3648, 3648,
+  3680, 3680,   58,  121, 2074, 2137, 2106, 2169, 1633, 1696, 3649, 3712,
+  3681, 3744,  122,  185, 2138, 2201, 2170, 2233,  886,  949, 2902, 2965,
+  2934, 2997, 1390, 1453, 3406, 3469, 3438, 3501, 1634, 1697, 3650, 3713,
+  3682, 3745,  186,  249, 2202, 2265, 2234, 2297, 1139, 1202, 3155, 3218,
+  3187, 3250, 1202, 1265, 3218, 3281, 3250, 3313, 1635, 1698, 3651, 3714,
+  3683, 3746,  505,  568, 2521, 2584, 2553, 2616, 1076, 1139, 3092, 3155,
+  3124, 3187, 1265, 1328, 3281, 3344, 3313, 3376, 1576, 1639, 3592, 3655,
+  3624, 3687,  250,  313, 2266, 2329, 2298, 2361, 1636, 1699, 3652, 3715,
+  3684, 3747,  696,  759, 2712, 2775, 2744, 2807, 1013, 1076, 3029, 3092,
+  3061, 3124, 1328, 1391, 3344, 3407, 3376, 3439, 1515, 1578, 3531, 3594,
+  3563, 3626,  823,  886, 2839, 2902, 2871, 2934, 1453, 1516, 3469, 3532,
+  3501, 3564,  314,  377, 2330, 2393, 2362, 2425, 1637, 1700, 3653, 3716,
+  3685, 3748,  569,  632, 2585, 2648, 2617, 2680, 1577, 1640, 3593, 3656,
+  3625, 3688,  950, 1013, 2966, 3029, 2998, 3061, 1391, 1454, 3407, 3470,
+  3439, 3502,  378,  441, 2394, 2457, 2426, 2489, 1638, 1701, 3654, 3717,
+  3686, 3749,  760,  823, 2776, 2839, 2808, 2871, 1516, 1579, 3532, 3595,
+  3564, 3627, 1203, 1266, 3219, 3282, 3251, 3314, 1140, 1203, 3156, 3219,
+  3188, 3251, 1266, 1329, 3282, 3345, 3314, 3377,  442,  505, 2458, 2521,
+  2490, 2553,  633,  696, 2649, 2712, 2681, 2744,  887,  950, 2903, 2966,
+  2935, 2998, 1454, 1517, 3470, 3533, 3502, 3565, 1578, 1641, 3594, 3657,
+  3626, 3689, 1639, 1702, 3655, 3718, 3687, 3750,   58,   58, 2074, 2074,
+  2106, 2106, 1696, 1696, 3712, 3712, 3744, 3744,   59,  122, 2075, 2138,
+  2107, 2170, 1077, 1140, 3093, 3156, 3125, 3188, 1329, 1392, 3345, 3408,
+  3377, 3440, 1697, 1760, 3713, 3776, 3745, 3808,  123,  186, 2139, 2202,
+  2171, 2234, 1698, 1761, 3714, 3777, 3746, 3809,  187,  250, 2203, 2266,
+  2235, 2298, 1699, 1762, 3715, 3778, 3747, 3810,  506,  569, 2522, 2585,
+  2554, 2617, 1014, 1077, 3030, 3093, 3062, 3125, 1392, 1455, 3408, 3471,
+  3440, 3503, 1640, 1703, 3656, 3719, 3688, 3751,  251,  314, 2267, 2330,
+  2299, 2362,  824,  887, 2840, 2903, 2872, 2935, 1517, 1580, 3533, 3596,
+  3565, 3628, 1700, 1763, 3716, 3779, 3748, 3811,  697,  760, 2713, 2776,
+  2745, 2808, 1579, 1642, 3595, 3658, 3627, 3690,  315,  378, 2331, 2394,
+  2363, 2426,  951, 1014, 2967, 3030, 2999, 3062, 1455, 1518, 3471, 3534,
+  3503, 3566, 1701, 1764, 3717, 3780, 3749, 3812,  570,  633, 2586, 2649,
+  2618, 2681, 1641, 1704, 3657, 3720, 3689, 3752, 1204, 1267, 3220, 3283,
+  3252, 3315, 1267, 1330, 3283, 3346, 3315, 3378,  379,  442, 2395, 2458,
+  2427, 2490, 1141, 1204, 3157, 3220, 3189, 3252, 1330, 1393, 3346, 3409,
+  3378, 3441, 1702, 1765, 3718, 3781, 3750, 3813,  761,  824, 2777, 2840,
+  2809, 2872, 1580, 1643, 3596, 3659, 3628, 3691,  888,  951, 2904, 2967,
+  2936, 2999, 1518, 1581, 3534, 3597, 3566, 3629, 1078, 1141, 3094, 3157,
+  3126, 3189, 1393, 1456, 3409, 3472, 3441, 3504,  634,  697, 2650, 2713,
+  2682, 2745, 1642, 1705, 3658, 3721, 3690, 3753,  443,  506, 2459, 2522,
+  2491, 2554, 1703, 1766, 3719, 3782, 3751, 3814,   59,   59, 2075, 2075,
+  2107, 2107, 1760, 1760, 3776, 3776, 3808, 3808,   60,  123, 2076, 2139,
+  2108, 2171, 1015, 1078, 3031, 3094, 3063, 3126, 1456, 1519, 3472, 3535,
+  3504, 3567, 1761, 1824, 3777, 3840, 3809, 3872,  124,  187, 2140, 2203,
+  2172, 2235, 1762, 1825, 3778, 3841, 3810, 3873,  188,  251, 2204, 2267,
+  2236, 2299,  507,  570, 2523, 2586, 2555, 2618, 1704, 1767, 3720, 3783,
+  3752, 3815, 1763, 1826, 3779, 3842, 3811, 3874,  825,  888, 2841, 2904,
+  2873, 2936, 1581, 1644, 3597, 3660, 3629, 3692,  698,  761, 2714, 2777,
+  2746, 2809, 1643, 1706, 3659, 3722, 3691, 3754,  252,  315, 2268, 2331,
+  2300, 2363, 1268, 1331, 3284, 3347, 3316, 3379, 1764, 1827, 3780, 3843,
+  3812, 3875,  952, 1015, 2968, 3031, 3000, 3063, 1519, 1582, 3535, 3598,
+  3567, 3630, 1205, 1268, 3221, 3284, 3253, 3316, 1331, 1394, 3347, 3410,
+  3379, 3442, 1142, 1205, 3158, 3221, 3190, 3253, 1394, 1457, 3410, 3473,
+  3442, 3505,  316,  379, 2332, 2395, 2364, 2427, 1765, 1828, 3781, 3844,
+  3813, 3876,  571,  634, 2587, 2650, 2619, 2682, 1705, 1768, 3721, 3784,
+  3753, 3816, 1079, 1142, 3095, 3158, 3127, 3190, 1457, 1520, 3473, 3536,
+  3505, 3568,  380,  443, 2396, 2459, 2428, 2491,  762,  825, 2778, 2841,
+  2810, 2873, 1644, 1707, 3660, 3723, 3692, 3755, 1766, 1829, 3782, 3845,
+  3814, 3877,  889,  952, 2905, 2968, 2937, 3000, 1582, 1645, 3598, 3661,
+  3630, 3693,  635,  698, 2651, 2714, 2683, 2746, 1706, 1769, 3722, 3785,
+  3754, 3817, 1016, 1079, 3032, 3095, 3064, 3127, 1520, 1583, 3536, 3599,
+  3568, 3631,  444,  507, 2460, 2523, 2492, 2555, 1767, 1830, 3783, 3846,
+  3815, 3878,   60,   60, 2076, 2076, 2108, 2108, 1269, 1332, 3285, 3348,
+  3317, 3380, 1332, 1395, 3348, 3411, 3380, 3443, 1824, 1824, 3840, 3840,
+  3872, 3872,   61,  124, 2077, 2140, 2109, 2172, 1825, 1888, 3841, 3904,
+  3873, 3936,  125,  188, 2141, 2204, 2173, 2236,  826,  889, 2842, 2905,
+  2874, 2937, 1206, 1269, 3222, 3285, 3254, 3317, 1395, 1458, 3411, 3474,
+  3443, 3506, 1645, 1708, 3661, 3724, 3693, 3756, 1826, 1889, 3842, 3905,
+  3874, 3937,  508,  571, 2524, 2587, 2556, 2619, 1768, 1831, 3784, 3847,
+  3816, 3879,  189,  252, 2205, 2268, 2237, 2300,  699,  762, 2715, 2778,
+  2747, 2810,  953, 1016, 2969, 3032, 3001, 3064, 1583, 1646, 3599, 3662,
+  3631, 3694, 1707, 1770, 3723, 3786, 3755, 3818, 1827, 1890, 3843, 3906,
+  3875, 3938, 1143, 1206, 3159, 3222, 3191, 3254, 1458, 1521, 3474, 3537,
+  3506, 3569,  253,  316, 2269, 2332, 2301, 2364, 1828, 1891, 3844, 3907,
+  3876, 3939,  572,  635, 2588, 2651, 2620, 2683, 1080, 1143, 3096, 3159,
+  3128, 3191, 1521, 1584, 3537, 3600, 3569, 3632, 1769, 1832, 3785, 3848,
+  3817, 3880,  317,  380, 2333, 2396, 2365, 2428, 1829, 1892, 3845, 3908,
+  3877, 3940,  890,  953, 2906, 2969, 2938, 3001, 1646, 1709, 3662, 3725,
+  3694, 3757,  763,  826, 2779, 2842, 2811, 2874, 1708, 1771, 3724, 3787,
+  3756, 3819,  381,  444, 2397, 2460, 2429, 2492, 1830, 1893, 3846, 3909,
+  3878, 3941, 1017, 1080, 3033, 3096, 3065, 3128, 1584, 1647, 3600, 3663,
+  3632, 3695, 1333, 1396, 3349, 3412, 3381, 3444,  636,  699, 2652, 2715,
+  2684, 2747, 1270, 1333, 3286, 3349, 3318, 3381, 1396, 1459, 3412, 3475,
+  3444, 3507, 1770, 1833, 3786, 3849, 3818, 3881,  445,  508, 2461, 2524,
+  2493, 2556, 1207, 1270, 3223, 3286, 3255, 3318, 1459, 1522, 3475, 3538,
+  3507, 3570, 1831, 1894, 3847, 3910, 3879, 3942,  827,  890, 2843, 2906,
+  2875, 2938, 1709, 1772, 3725, 3788, 3757, 3820,   61,   61, 2077, 2077,
+  2109, 2109, 1144, 1207, 3160, 3223, 3192, 3255, 1522, 1585, 3538, 3601,
+  3570, 3633, 1888, 1888, 3904, 3904, 3936, 3936,   62,  125, 2078, 2141,
+  2110, 2173,  954, 1017, 2970, 3033, 3002, 3065, 1647, 1710, 3663, 3726,
+  3695, 3758, 1889, 1952, 3905, 3968, 3937, 4000,  126,  189, 2142, 2205,
+  2174, 2237, 1890, 1953, 3906, 3969, 3938, 4001,  509,  572, 2525, 2588,
+  2557, 2620,  700,  763, 2716, 2779, 2748, 2811, 1771, 1834, 3787, 3850,
+  3819, 3882, 1832, 1895, 3848, 3911, 3880, 3943,  190,  253, 2206, 2269,
+  2238, 2301, 1891, 1954, 3907, 3970, 3939, 4002, 1081, 1144, 3097, 3160,
+  3129, 3192, 1585, 1648, 3601, 3664, 3633, 3696,  254,  317, 2270, 2333,
+  2302, 2365, 1892, 1955, 3908, 3971, 3940, 4003,  573,  636, 2589, 2652,
+  2621, 2684, 1833, 1896, 3849, 3912, 3881, 3944,  318,  381, 2334, 2397,
+  2366, 2429,  891,  954, 2907, 2970, 2939, 3002, 1334, 1397, 3350, 3413,
+  3382, 3445, 1397, 1460, 3413, 3476, 3445, 3508, 1710, 1773, 3726, 3789,
+  3758, 3821, 1893, 1956, 3909, 3972, 3941, 4004,  764,  827, 2780, 2843,
+  2812, 2875, 1772, 1835, 3788, 3851, 3820, 3883, 1271, 1334, 3287, 3350,
+  3319, 3382, 1460, 1523, 3476, 3539, 3508, 3571, 1018, 1081, 3034, 3097,
+  3066, 3129, 1648, 1711, 3664, 3727, 3696, 3759,  382,  445, 2398, 2461,
+  2430, 2493, 1894, 1957, 3910, 3973, 3942, 4005, 1208, 1271, 3224, 3287,
+  3256, 3319, 1523, 1586, 3539, 3602, 3571, 3634,  637,  700, 2653, 2716,
+  2685, 2748, 1834, 1897, 3850, 3913, 3882, 3945,  446,  509, 2462, 2525,
+  2494, 2557, 1145, 1208, 3161, 3224, 3193, 3256, 1586, 1649, 3602, 3665,
+  3634, 3697, 1895, 1958, 3911, 3974, 3943, 4006,  828,  891, 2844, 2907,
+  2876, 2939, 1773, 1836, 3789, 3852, 3821, 3884,  955, 1018, 2971, 3034,
+  3003, 3066, 1711, 1774, 3727, 3790, 3759, 3822,   62,   62, 2078, 2078,
+  2110, 2110, 1952, 1952, 3968, 3968, 4000, 4000,   63,  126, 2079, 2142,
+  2111, 2174,  701,  764, 2717, 2780, 2749, 2812, 1835, 1898, 3851, 3914,
+  3883, 3946, 1953, 2016, 3969, 4032, 4001, 4064,  510,  573, 2526, 2589,
+  2558, 2621, 1896, 1959, 3912, 3975, 3944, 4007,  127,  190, 2143, 2206,
+  2175, 2238, 1082, 1145, 3098, 3161, 3130, 3193, 1649, 1712, 3665, 3728,
+  3697, 3760, 1954, 2017, 3970, 4033, 4002, 4065, 1398, 1461, 3414, 3477,
+  3446, 3509,  191,  254, 2207, 2270, 2239, 2302, 1335, 1398, 3351, 3414,
+  3383, 3446, 1461, 1524, 3477, 3540, 3509, 3572, 1955, 2018, 3971, 4034,
+  4003, 4066, 1272, 1335, 3288, 3351, 3320, 3383, 1524, 1587, 3540, 3603,
+  3572, 3635,  255,  318, 2271, 2334, 2303, 2366, 1956, 2019, 3972, 4035,
+  4004, 4067,  892,  955, 2908, 2971, 2940, 3003, 1774, 1837, 3790, 3853,
+  3822, 3885,  574,  637, 2590, 2653, 2622, 2685, 1897, 1960, 3913, 3976,
+  3945, 4008,  765,  828, 2781, 2844, 2813, 2876, 1019, 1082, 3035, 3098,
+  3067, 3130, 1712, 1775, 3728, 3791, 3760, 3823, 1836, 1899, 3852, 3915,
+  3884, 3947,  319,  382, 2335, 2398, 2367, 2430, 1209, 1272, 3225, 3288,
+  3257, 3320, 1587, 1650, 3603, 3666, 3635, 3698, 1957, 2020, 3973, 4036,
+  4005, 4068,  383,  446, 2399, 2462, 2431, 2494, 1958, 2021, 3974, 4037,
+  4006, 4069,  638,  701, 2654, 2717, 2686, 2749, 1146, 1209, 3162, 3225,
+  3194, 3257, 1650, 1713, 3666, 3729, 3698, 3761, 1898, 1961, 3914, 3977,
+  3946, 4009,  956, 1019, 2972, 3035, 3004, 3067, 1775, 1838, 3791, 3854,
+  3823, 3886,  447,  510, 2463, 2526, 2495, 2558,  829,  892, 2845, 2908,
+  2877, 2940, 1837, 1900, 3853, 3916, 3885, 3948, 1959, 2022, 3975, 4038,
+  4007, 4070, 1399, 1462, 3415, 3478, 3447, 3510, 1462, 1525, 3478, 3541,
+  3510, 3573, 1336, 1399, 3352, 3415, 3384, 3447, 1525, 1588, 3541, 3604,
+  3573, 3636, 1083, 1146, 3099, 3162, 3131, 3194, 1713, 1776, 3729, 3792,
+  3761, 3824,  702,  765, 2718, 2781, 2750, 2813, 1899, 1962, 3915, 3978,
+  3947, 4010,  511,  574, 2527, 2590, 2559, 2622, 1273, 1336, 3289, 3352,
+  3321, 3384, 1588, 1651, 3604, 3667, 3636, 3699, 1960, 2023, 3976, 4039,
+  4008, 4071,  893,  956, 2909, 2972, 2941, 3004, 1210, 1273, 3226, 3289,
+  3258, 3321, 1651, 1714, 3667, 3730, 3699, 3762, 1838, 1901, 3854, 3917,
+  3886, 3949, 1020, 1083, 3036, 3099, 3068, 3131, 1776, 1839, 3792, 3855,
+  3824, 3887,  575,  638, 2591, 2654, 2623, 2686, 1961, 2024, 3977, 4040,
+  4009, 4072,  766,  829, 2782, 2845, 2814, 2877, 1900, 1963, 3916, 3979,
+  3948, 4011, 1147, 1210, 3163, 3226, 3195, 3258, 1714, 1777, 3730, 3793,
+  3762, 3825, 1463, 1526, 3479, 3542, 3511, 3574, 1400, 1463, 3416, 3479,
+  3448, 3511, 1526, 1589, 3542, 3605, 3574, 3637,  639,  702, 2655, 2718,
+  2687, 2750, 1962, 2025, 3978, 4041, 4010, 4073,  957, 1020, 2973, 3036,
+  3005, 3068, 1337, 1400, 3353, 3416, 3385, 3448, 1589, 1652, 3605, 3668,
+  3637, 3700, 1839, 1902, 3855, 3918, 3887, 3950,  830,  893, 2846, 2909,
+  2878, 2941, 1901, 1964, 3917, 3980, 3949, 4012, 1084, 1147, 3100, 3163,
+  3132, 3195, 1777, 1840, 3793, 3856, 3825, 3888, 1274, 1337, 3290, 3353,
+  3322, 3385, 1652, 1715, 3668, 3731, 3700, 3763,  703,  766, 2719, 2782,
+  2751, 2814, 1963, 2026, 3979, 4042, 4011, 4074, 1211, 1274, 3227, 3290,
+  3259, 3322, 1715, 1778, 3731, 3794, 3763, 3826,  894,  957, 2910, 2973,
+  2942, 3005, 1902, 1965, 3918, 3981, 3950, 4013, 1021, 1084, 3037, 3100,
+  3069, 3132, 1840, 1903, 3856, 3919, 3888, 3951,  767,  830, 2783, 2846,
+  2815, 2878, 1464, 1527, 3480, 3543, 3512, 3575, 1527, 1590, 3543, 3606,
+  3575, 3638, 1964, 2027, 3980, 4043, 4012, 4075, 1148, 1211, 3164, 3227,
+  3196, 3259, 1778, 1841, 3794, 3857, 3826, 3889, 1401, 1464, 3417, 3480,
+  3449, 3512, 1590, 1653, 3606, 3669, 3638, 3701, 1338, 1401, 3354, 3417,
+  3386, 3449, 1653, 1716, 3669, 3732, 3701, 3764,  958, 1021, 2974, 3037,
+  3006, 3069, 1903, 1966, 3919, 3982, 3951, 4014, 1275, 1338, 3291, 3354,
+  3323, 3386, 1716, 1779, 3732, 3795, 3764, 3827,  831,  894, 2847, 2910,
+  2879, 2942, 1085, 1148, 3101, 3164, 3133, 3196, 1841, 1904, 3857, 3920,
+  3889, 3952, 1965, 2028, 3981, 4044, 4013, 4076, 1212, 1275, 3228, 3291,
+  3260, 3323, 1779, 1842, 3795, 3858, 3827, 3890, 1528, 1591, 3544, 3607,
+  3576, 3639, 1465, 1528, 3481, 3544, 3513, 3576, 1591, 1654, 3607, 3670,
+  3639, 3702, 1022, 1085, 3038, 3101, 3070, 3133, 1904, 1967, 3920, 3983,
+  3952, 4015,  895,  958, 2911, 2974, 2943, 3006, 1966, 2029, 3982, 4045,
+  4014, 4077, 1402, 1465, 3418, 3481, 3450, 3513, 1654, 1717, 3670, 3733,
+  3702, 3765, 1149, 1212, 3165, 3228, 3197, 3260, 1842, 1905, 3858, 3921,
+  3890, 3953, 1339, 1402, 3355, 3418, 3387, 3450, 1717, 1780, 3733, 3796,
+  3765, 3828, 1276, 1339, 3292, 3355, 3324, 3387, 1780, 1843, 3796, 3859,
+  3828, 3891,  959, 1022, 2975, 3038, 3007, 3070, 1967, 2030, 3983, 4046,
+  4015, 4078, 1086, 1149, 3102, 3165, 3134, 3197, 1905, 1968, 3921, 3984,
+  3953, 4016, 1529, 1592, 3545, 3608, 3577, 3640, 1592, 1655, 3608, 3671,
+  3640, 3703, 1213, 1276, 3229, 3292, 3261, 3324, 1843, 1906, 3859, 3922,
+  3891, 3954, 1466, 1529, 3482, 3545, 3514, 3577, 1655, 1718, 3671, 3734,
+  3703, 3766, 1403, 1466, 3419, 3482, 3451, 3514, 1718, 1781, 3734, 3797,
+  3766, 3829, 1023, 1086, 3039, 3102, 3071, 3134, 1968, 2031, 3984, 4047,
+  4016, 4079, 1150, 1213, 3166, 3229, 3198, 3261, 1906, 1969, 3922, 3985,
+  3954, 4017, 1340, 1403, 3356, 3419, 3388, 3451, 1781, 1844, 3797, 3860,
+  3829, 3892, 1277, 1340, 3293, 3356, 3325, 3388, 1844, 1907, 3860, 3923,
+  3892, 3955, 1087, 1150, 3103, 3166, 3135, 3198, 1593, 1656, 3609, 3672,
+  3641, 3704, 1969, 2032, 3985, 4048, 4017, 4080, 1530, 1593, 3546, 3609,
+  3578, 3641, 1656, 1719, 3672, 3735, 3704, 3767, 1467, 1530, 3483, 3546,
+  3515, 3578, 1719, 1782, 3735, 3798, 3767, 3830, 1214, 1277, 3230, 3293,
+  3262, 3325, 1907, 1970, 3923, 3986, 3955, 4018, 1404, 1467, 3420, 3483,
+  3452, 3515, 1782, 1845, 3798, 3861, 3830, 3893, 1341, 1404, 3357, 3420,
+  3389, 3452, 1845, 1908, 3861, 3924, 3893, 3956, 1151, 1214, 3167, 3230,
+  3199, 3262, 1970, 2033, 3986, 4049, 4018, 4081, 1278, 1341, 3294, 3357,
+  3326, 3389, 1908, 1971, 3924, 3987, 3956, 4019, 1594, 1657, 3610, 3673,
+  3642, 3705, 1657, 1720, 3673, 3736, 3705, 3768, 1531, 1594, 3547, 3610,
+  3579, 3642, 1720, 1783, 3736, 3799, 3768, 3831, 1468, 1531, 3484, 3547,
+  3516, 3579, 1783, 1846, 3799, 3862, 3831, 3894, 1215, 1278, 3231, 3294,
+  3263, 3326, 1971, 2034, 3987, 4050, 4019, 4082, 1405, 1468, 3421, 3484,
+  3453, 3516, 1846, 1909, 3862, 3925, 3894, 3957, 1342, 1405, 3358, 3421,
+  3390, 3453, 1909, 1972, 3925, 3988, 3957, 4020, 1658, 1721, 3674, 3737,
+  3706, 3769, 1595, 1658, 3611, 3674, 3643, 3706, 1721, 1784, 3737, 3800,
+  3769, 3832, 1532, 1595, 3548, 3611, 3580, 3643, 1784, 1847, 3800, 3863,
+  3832, 3895, 1279, 1342, 3295, 3358, 3327, 3390, 1972, 2035, 3988, 4051,
+  4020, 4083, 1469, 1532, 3485, 3548, 3517, 3580, 1847, 1910, 3863, 3926,
+  3895, 3958, 1406, 1469, 3422, 3485, 3454, 3517, 1910, 1973, 3926, 3989,
+  3958, 4021, 1343, 1406, 3359, 3422, 3391, 3454, 1973, 2036, 3989, 4052,
+  4021, 4084, 1659, 1722, 3675, 3738, 3707, 3770, 1722, 1785, 3738, 3801,
+  3770, 3833, 1596, 1659, 3612, 3675, 3644, 3707, 1785, 1848, 3801, 3864,
+  3833, 3896, 1533, 1596, 3549, 3612, 3581, 3644, 1848, 1911, 3864, 3927,
+  3896, 3959, 1470, 1533, 3486, 3549, 3518, 3581, 1911, 1974, 3927, 3990,
+  3959, 4022, 1407, 1470, 3423, 3486, 3455, 3518, 1974, 2037, 3990, 4053,
+  4022, 4085, 1723, 1786, 3739, 3802, 3771, 3834, 1660, 1723, 3676, 3739,
+  3708, 3771, 1786, 1849, 3802, 3865, 3834, 3897, 1597, 1660, 3613, 3676,
+  3645, 3708, 1849, 1912, 3865, 3928, 3897, 3960, 1534, 1597, 3550, 3613,
+  3582, 3645, 1912, 1975, 3928, 3991, 3960, 4023, 1471, 1534, 3487, 3550,
+  3519, 3582, 1975, 2038, 3991, 4054, 4023, 4086, 1724, 1787, 3740, 3803,
+  3772, 3835, 1787, 1850, 3803, 3866, 3835, 3898, 1661, 1724, 3677, 3740,
+  3709, 3772, 1850, 1913, 3866, 3929, 3898, 3961, 1598, 1661, 3614, 3677,
+  3646, 3709, 1913, 1976, 3929, 3992, 3961, 4024, 1535, 1598, 3551, 3614,
+  3583, 3646, 1976, 2039, 3992, 4055, 4024, 4087, 1788, 1851, 3804, 3867,
+  3836, 3899, 1725, 1788, 3741, 3804, 3773, 3836, 1851, 1914, 3867, 3930,
+  3899, 3962, 1662, 1725, 3678, 3741, 3710, 3773, 1914, 1977, 3930, 3993,
+  3962, 4025, 1599, 1662, 3615, 3678, 3647, 3710, 1977, 2040, 3993, 4056,
+  4025, 4088, 1789, 1852, 3805, 3868, 3837, 3900, 1852, 1915, 3868, 3931,
+  3900, 3963, 1726, 1789, 3742, 3805, 3774, 3837, 1915, 1978, 3931, 3994,
+  3963, 4026, 1663, 1726, 3679, 3742, 3711, 3774, 1978, 2041, 3994, 4057,
+  4026, 4089, 1853, 1916, 3869, 3932, 3901, 3964, 1790, 1853, 3806, 3869,
+  3838, 3901, 1916, 1979, 3932, 3995, 3964, 4027, 1727, 1790, 3743, 3806,
+  3775, 3838, 1979, 2042, 3995, 4058, 4027, 4090, 1854, 1917, 3870, 3933,
+  3902, 3965, 1917, 1980, 3933, 3996, 3965, 4028, 1791, 1854, 3807, 3870,
+  3839, 3902, 1980, 2043, 3996, 4059, 4028, 4091, 1918, 1981, 3934, 3997,
+  3966, 4029, 1855, 1918, 3871, 3934, 3903, 3966, 1981, 2044, 3997, 4060,
+  4029, 4092, 1919, 1982, 3935, 3998, 3967, 4030, 1982, 2045, 3998, 4061,
+  4030, 4093, 1983, 2046, 3999, 4062, 4031, 4094, 0, 0
+};
+#endif  // CONFIG_WAVELETS
 #endif  // CONFIG_TX64X64
 
 DECLARE_ALIGNED(16, static const int16_t, vp9_default_iscan_4x4[16]) = {
@@ -2242,6 +3588,139 @@ DECLARE_ALIGNED(16, static const int16_t, vp9_default_iscan_32x32[1024]) = {
   1023,
 };
 
+#if CONFIG_WAVELETS
+DECLARE_ALIGNED(16, static const int16_t, vp9_dwtdct_iscan_32x32[1024]) = {
+  0,  1,  4,  9, 15, 22, 33, 43,
+  56,  71,  86, 104, 121, 142, 166, 189,
+  256, 259, 268, 283, 301, 322, 355, 385,
+  424, 469, 514, 568, 619, 682, 754, 823,
+  2,  3,  6, 11, 17, 26, 35, 45,
+  58,  73,  90, 106, 123, 146, 168, 193,
+  262, 265, 274, 289, 307, 334, 361, 391,
+  430, 475, 526, 574, 625, 694, 760, 835,
+  5,  7,  8, 13, 20, 28, 37, 50,
+  62,  75,  92, 108, 129, 150, 170, 195,
+  271, 277, 280, 295, 316, 340, 367, 406,
+  442, 481, 532, 580, 643, 706, 766, 841,
+  10, 12, 14, 19, 23, 31, 41, 52,
+  65,  81,  96, 113, 133, 152, 175, 201,
+  286, 292, 298, 313, 325, 349, 379, 412,
+  451, 499, 544, 595, 655, 712, 781, 859,
+  16, 18, 21, 24, 30, 39, 48, 59,
+  69,  83, 100, 119, 137, 158, 181, 203,
+  304, 310, 319, 328, 346, 373, 400, 433,
+  463, 505, 556, 613, 667, 730, 799, 865,
+  25, 27, 29, 32, 40, 46, 54, 67,
+  79,  94, 109, 127, 143, 164, 185, 210,
+  331, 337, 343, 352, 376, 394, 418, 457,
+  493, 538, 583, 637, 685, 748, 811, 886,
+  34, 36, 38, 42, 49, 55, 64, 76,
+  87, 102, 117, 135, 154, 176, 197, 216,
+  358, 364, 370, 382, 403, 421, 448, 484,
+  517, 562, 607, 661, 718, 784, 847, 904,
+  44, 47, 51, 53, 60, 68, 77, 85,
+  98, 114, 131, 147, 162, 183, 208, 222,
+  388, 397, 409, 415, 436, 460, 487, 511,
+  550, 598, 649, 697, 742, 805, 880, 922,
+  57, 61, 63, 66, 70, 80, 88, 99,
+  112, 124, 140, 159, 179, 199, 214, 227,
+  427, 439, 445, 454, 466, 496, 520, 553,
+  592, 628, 676, 733, 793, 853, 898, 937,
+  72,  74,  78,  82,  84,  95, 103, 115,
+  125, 139, 156, 173, 190, 211, 224, 233,
+  472, 478, 490, 502, 508, 541, 565, 601,
+  631, 673, 724, 775, 826, 889, 928, 955,
+  89,  91,  93,  97, 101, 110, 118, 132,
+  141, 157, 171, 186, 206, 220, 231, 239,
+  523, 529, 535, 547, 559, 586, 610, 652,
+  679, 727, 769, 814, 874, 916, 949, 973,
+  105, 107, 111, 116, 120, 128, 136, 148,
+  160, 174, 187, 205, 218, 229, 237, 244,
+  571, 577, 589, 604, 616, 640, 664, 700,
+  736, 778, 817, 871, 910, 943, 967, 988,
+  122, 126, 130, 134, 138, 144, 155, 163,
+  180, 191, 207, 219, 226, 235, 242, 248,
+  622, 634, 646, 658, 670, 688, 721, 745,
+  796,  829,  877,  913,  934,  961,  982, 1000,
+  145, 149, 151, 153, 161, 165, 177, 184,
+  200, 212, 221, 230, 236, 241, 246, 251,
+  691, 703, 709, 715, 739, 751, 787, 808,
+  856,  892,  919,  946,  964,  979,  994, 1009,
+  167, 169, 172, 178, 182, 188, 198, 209,
+  215, 225, 232, 238, 243, 247, 250, 253,
+  757, 763, 772, 790, 802, 820, 850, 883,
+  901,  931,  952,  970,  985,  997, 1006, 1015,
+  192, 194, 196, 202, 204, 213, 217, 223,
+  228, 234, 240, 245, 249, 252, 254, 255,
+  832, 838, 844, 862, 868, 895, 907, 925,
+  940,  958,  976,  991, 1003, 1012, 1018, 1021,
+  257, 260, 269, 284, 302, 323, 356, 386,
+  425, 470, 515, 569, 620, 683, 755, 824,
+  258, 261, 270, 285, 303, 324, 357, 387,
+  426, 471, 516, 570, 621, 684, 756, 825,
+  263, 266, 275, 290, 308, 335, 362, 392,
+  431, 476, 527, 575, 626, 695, 761, 836,
+  264, 267, 276, 291, 309, 336, 363, 393,
+  432, 477, 528, 576, 627, 696, 762, 837,
+  272, 278, 281, 296, 317, 341, 368, 407,
+  443, 482, 533, 581, 644, 707, 767, 842,
+  273, 279, 282, 297, 318, 342, 369, 408,
+  444, 483, 534, 582, 645, 708, 768, 843,
+  287, 293, 299, 314, 326, 350, 380, 413,
+  452, 500, 545, 596, 656, 713, 782, 860,
+  288, 294, 300, 315, 327, 351, 381, 414,
+  453, 501, 546, 597, 657, 714, 783, 861,
+  305, 311, 320, 329, 347, 374, 401, 434,
+  464, 506, 557, 614, 668, 731, 800, 866,
+  306, 312, 321, 330, 348, 375, 402, 435,
+  465, 507, 558, 615, 669, 732, 801, 867,
+  332, 338, 344, 353, 377, 395, 419, 458,
+  494, 539, 584, 638, 686, 749, 812, 887,
+  333, 339, 345, 354, 378, 396, 420, 459,
+  495, 540, 585, 639, 687, 750, 813, 888,
+  359, 365, 371, 383, 404, 422, 449, 485,
+  518, 563, 608, 662, 719, 785, 848, 905,
+  360, 366, 372, 384, 405, 423, 450, 486,
+  519, 564, 609, 663, 720, 786, 849, 906,
+  389, 398, 410, 416, 437, 461, 488, 512,
+  551, 599, 650, 698, 743, 806, 881, 923,
+  390, 399, 411, 417, 438, 462, 489, 513,
+  552, 600, 651, 699, 744, 807, 882, 924,
+  428, 440, 446, 455, 467, 497, 521, 554,
+  593, 629, 677, 734, 794, 854, 899, 938,
+  429, 441, 447, 456, 468, 498, 522, 555,
+  594, 630, 678, 735, 795, 855, 900, 939,
+  473, 479, 491, 503, 509, 542, 566, 602,
+  632, 674, 725, 776, 827, 890, 929, 956,
+  474, 480, 492, 504, 510, 543, 567, 603,
+  633, 675, 726, 777, 828, 891, 930, 957,
+  524, 530, 536, 548, 560, 587, 611, 653,
+  680, 728, 770, 815, 875, 917, 950, 974,
+  525, 531, 537, 549, 561, 588, 612, 654,
+  681, 729, 771, 816, 876, 918, 951, 975,
+  572, 578, 590, 605, 617, 641, 665, 701,
+  737, 779, 818, 872, 911, 944, 968, 989,
+  573, 579, 591, 606, 618, 642, 666, 702,
+  738, 780, 819, 873, 912, 945, 969, 990,
+  623, 635, 647, 659, 671, 689, 722, 746,
+  797,  830,  878,  914,  935,  962,  983, 1001,
+  624, 636, 648, 660, 672, 690, 723, 747,
+  798,  831,  879,  915,  936,  963,  984, 1002,
+  692, 704, 710, 716, 740, 752, 788, 809,
+  857,  893,  920,  947,  965,  980,  995, 1010,
+  693, 705, 711, 717, 741, 753, 789, 810,
+  858,  894,  921,  948,  966,  981,  996, 1011,
+  758, 764, 773, 791, 803, 821, 851, 884,
+  902,  932,  953,  971,  986,  998, 1007, 1016,
+  759, 765, 774, 792, 804, 822, 852, 885,
+  903,  933,  954,  972,  987,  999, 1008, 1017,
+  833, 839, 845, 863, 869, 896, 908, 926,
+  941,  959,  977,  992, 1004, 1013, 1019, 1022,
+  834, 840, 846, 864, 870, 897, 909, 927,
+  942,  960,  978,  993, 1005, 1014, 1020, 1023,
+};
+#endif  // CONFIG_WAVELETS
+
 #if CONFIG_TX64X64
 DECLARE_ALIGNED(16, static const int16_t, vp9_default_iscan_64x64[4096]) = {
   0,  1,  4,  9, 15, 22, 33, 43,
@@ -2757,6 +4236,353 @@ DECLARE_ALIGNED(16, static const int16_t, vp9_default_iscan_64x64[4096]) = {
   3976, 3990, 4004, 4017, 4029, 4040, 4050, 4059,
   4067, 4074, 4080, 4085, 4089, 4092, 4094, 4095,
 };
+
+#if CONFIG_WAVELETS
+DECLARE_ALIGNED(16, static const int16_t, vp9_dwtdct_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,  553,  598,  640,  683,  732,  780, 1024, 1027, 1036, 1051,
+  1069, 1090, 1123, 1153, 1192, 1237, 1282, 1336, 1387, 1450, 1522, 1591,
+  1666, 1741, 1831, 1924, 2017, 2113, 2224, 2329, 2437, 2554, 2683, 2818,
+  2944, 3073, 3220, 3364,    2,    3,    6,   11,   17,   26,   35,   45,
+  58,  73,  90, 106, 123, 146, 168, 193, 216, 243, 271, 302,
+  335, 365, 402, 437, 473, 516, 557, 600, 642, 687, 736, 782,
+  1030, 1033, 1042, 1057, 1075, 1102, 1129, 1159, 1198, 1243, 1294, 1342,
+  1393, 1462, 1528, 1603, 1672, 1753, 1837, 1930, 2029, 2119, 2230, 2335,
+  2443, 2572, 2695, 2824, 2950, 3085, 3232, 3370,    5,    7,    8,   13,
+  20,  28,  37,  50,  62,  75,  92, 108, 129, 150, 170, 195,
+  218, 249, 277, 304, 337, 369, 406, 441, 478, 520, 559, 604,
+  646,  689,  740,  788, 1039, 1045, 1048, 1063, 1084, 1108, 1135, 1174,
+  1210, 1249, 1300, 1348, 1411, 1474, 1534, 1609, 1678, 1771, 1855, 1936,
+  2035, 2131, 2242, 2347, 2458, 2584, 2701, 2836, 2962, 3091, 3244, 3388,
+  10,  12,  14,  19,  23,  31,  41,  52,  65,  81,  96, 113,
+  133, 152, 175, 201, 224, 253, 279, 310, 341, 375, 410, 445,
+  484,  524,  563,  606,  648,  697,  746,  793, 1054, 1060, 1066, 1081,
+  1093, 1117, 1147, 1180, 1219, 1267, 1312, 1363, 1423, 1480, 1549, 1627,
+  1696, 1783, 1861, 1954, 2047, 2149, 2254, 2359, 2476, 2596, 2713, 2842,
+  2968, 3115, 3262, 3403,   16,   18,   21,   24,   30,   39,   48,   59,
+  69,  83, 100, 119, 137, 158, 181, 203, 230, 255, 286, 316,
+  347, 380, 414, 451, 490, 530, 571, 612, 656, 705, 750, 799,
+  1072, 1078, 1087, 1096, 1114, 1141, 1168, 1201, 1231, 1273, 1324, 1381,
+  1435, 1498, 1567, 1633, 1714, 1789, 1882, 1972, 2065, 2164, 2266, 2377,
+  2494, 2614, 2737, 2860, 2992, 3139, 3274, 3421,   25,   27,   29,   32,
+  40,  46,  54,  67,  79,  94, 109, 127, 143, 164, 185, 210,
+  236, 263, 292, 320, 353, 388, 422, 459, 496, 533, 579, 618,
+  665,  711,  754,  809, 1099, 1105, 1111, 1120, 1144, 1162, 1186, 1225,
+  1261, 1306, 1351, 1405, 1453, 1516, 1579, 1654, 1732, 1813, 1900, 1984,
+  2083, 2188, 2290, 2401, 2512, 2623, 2761, 2878, 3019, 3157, 3286, 3451,
+  34,  36,  38,  42,  49,  55,  64,  76,  87, 102, 117, 135,
+  154, 176, 197, 222, 247, 272, 298, 329, 361, 392, 427, 465,
+  504,  545,  585,  626,  671,  717,  766,  813, 1126, 1132, 1138, 1150,
+  1171, 1189, 1216, 1252, 1285, 1330, 1375, 1429, 1486, 1552, 1615, 1690,
+  1765, 1840, 1918, 2011, 2107, 2200, 2305, 2419, 2536, 2659, 2779, 2902,
+  3037, 3175, 3322, 3463,   44,   47,   51,   53,   60,   68,   77,   85,
+  98, 114, 131, 147, 162, 183, 208, 232, 256, 283, 314, 343,
+  373, 408, 442, 475, 511, 551, 592, 638, 681, 726, 772, 821,
+  1156, 1165, 1177, 1183, 1204, 1228, 1255, 1279, 1318, 1366, 1417, 1465,
+  1510, 1573, 1648, 1720, 1792, 1873, 1966, 2053, 2143, 2248, 2350, 2449,
+  2557, 2677, 2800, 2938, 3067, 3202, 3340, 3487,   57,   61,   63,   66,
+  70,  80,  88,  99, 112, 124, 140, 159, 179, 199, 219, 240,
+  267, 294, 322, 354, 386, 418, 455, 492, 528, 567, 608, 649,
+  695,  742,  786,  833, 1195, 1207, 1213, 1222, 1234, 1264, 1288, 1321,
+  1360, 1396, 1444, 1501, 1561, 1621, 1681, 1744, 1825, 1906, 1990, 2086,
+  2182, 2278, 2389, 2500, 2608, 2725, 2848, 2971, 3109, 3250, 3382, 3523,
+  72,  74,  78,  82,  84,  95, 103, 115, 125, 139, 156, 173,
+  190, 211, 234, 259, 281, 311, 339, 366, 394, 433, 466, 500,
+  543,  581,  622,  667,  707,  752,  803,  843, 1240, 1246, 1258, 1270,
+  1276, 1309, 1333, 1369, 1399, 1441, 1492, 1543, 1594, 1657, 1726, 1801,
+  1867, 1957, 2041, 2122, 2206, 2323, 2422, 2524, 2653, 2767, 2890, 3025,
+  3145, 3280, 3433, 3553,   89,   91,   93,   97,  101,  110,  118,  132,
+  141, 157, 171, 186, 206, 228, 251, 273, 296, 324, 351, 384,
+  415, 447, 482, 521, 554, 593, 636, 677, 722, 770, 815, 852,
+  1291, 1297, 1303, 1315, 1327, 1354, 1378, 1420, 1447, 1495, 1537, 1582,
+  1642, 1708, 1777, 1843, 1912, 1996, 2077, 2176, 2269, 2365, 2470, 2587,
+  2686, 2803, 2932, 3055, 3190, 3334, 3469, 3580,  105,  107,  111,  116,
+  120, 128, 136, 148, 160, 174, 187, 205, 225, 244, 265, 290,
+  317, 344, 370, 398, 431, 463, 498, 534, 573, 616, 654, 698,
+  743,  783,  831,  864, 1339, 1345, 1357, 1372, 1384, 1408, 1432, 1468,
+  1504, 1546, 1585, 1639, 1699, 1756, 1819, 1894, 1975, 2056, 2134, 2218,
+  2317, 2413, 2518, 2626, 2743, 2872, 2986, 3118, 3253, 3373, 3517, 3616,
+  122, 126, 130, 134, 138, 144, 155, 163, 180, 191, 207, 226,
+  238, 261, 287, 308, 332, 359, 390, 419, 449, 485, 518, 549,
+  587,  630,  672,  715,  760,  805,  845,  872, 1390, 1402, 1414, 1426,
+  1438, 1456, 1489, 1513, 1564, 1597, 1645, 1702, 1738, 1807, 1885, 1948,
+  2020, 2101, 2194, 2281, 2371, 2479, 2578, 2671, 2785, 2914, 3040, 3169,
+  3304, 3439, 3559, 3640,  145,  149,  151,  153,  161,  165,  177,  184,
+  200, 212, 229, 245, 262, 284, 305, 327, 355, 382, 411, 438,
+  469, 501, 539, 577, 613, 652, 690, 730, 776, 822, 858, 886,
+  1459, 1471, 1477, 1483, 1507, 1519, 1555, 1576, 1624, 1660, 1711, 1759,
+  1810, 1876, 1939, 2005, 2089, 2170, 2257, 2338, 2431, 2527, 2641, 2755,
+  2863, 2980, 3094, 3214, 3352, 3490, 3598, 3682,  167,  169,  172,  178,
+  182, 188, 198, 209, 220, 235, 252, 266, 288, 306, 326, 349,
+  378, 403, 428, 461, 494, 526, 560, 594, 632, 675, 713, 755,
+  801,  837,  868,  897, 1525, 1531, 1540, 1558, 1570, 1588, 1618, 1651,
+  1684, 1729, 1780, 1822, 1888, 1942, 2002, 2071, 2158, 2233, 2308, 2407,
+  2506, 2602, 2704, 2806, 2920, 3049, 3163, 3289, 3427, 3535, 3628, 3715,
+  192, 194, 196, 202, 204, 213, 223, 233, 241, 260, 274, 291,
+  309, 328, 350, 376, 395, 425, 457, 488, 512, 547, 583, 619,
+  659,  699,  737,  778,  819,  854,  882,  907, 1600, 1606, 1612, 1630,
+  1636, 1663, 1693, 1723, 1747, 1804, 1846, 1897, 1951, 2008, 2074, 2152,
+  2209, 2299, 2395, 2488, 2560, 2665, 2773, 2881, 3001, 3121, 3235, 3358,
+  3481, 3586, 3670, 3745,  215,  217,  221,  227,  231,  237,  248,  257,
+  268, 282, 297, 318, 333, 356, 379, 396, 424, 452, 479, 508,
+  541, 574, 609, 643, 679, 719, 764, 806, 841, 870, 895, 919,
+  1669, 1675, 1687, 1705, 1717, 1735, 1768, 1795, 1828, 1870, 1915, 1978,
+  2023, 2092, 2161, 2212, 2296, 2380, 2461, 2548, 2647, 2746, 2851, 2953,
+  3061, 3181, 3316, 3442, 3547, 3634, 3709, 3781,  242,  246,  250,  254,
+  258, 264, 275, 285, 295, 312, 325, 345, 360, 383, 404, 426,
+  453, 476, 506, 535, 568, 601, 634, 669, 708, 748, 789, 829,
+  860,  887,  909,  927, 1750, 1762, 1774, 1786, 1798, 1816, 1849, 1879,
+  1909, 1960, 1999, 2059, 2104, 2173, 2236, 2302, 2383, 2452, 2542, 2629,
+  2728, 2827, 2926, 3031, 3148, 3268, 3391, 3511, 3604, 3685, 3751, 3805,
+  270, 276, 278, 280, 289, 293, 299, 315, 323, 340, 352, 371,
+  391, 412, 429, 458, 480, 507, 532, 564, 590, 627, 663, 703,
+  733,  773,  816,  847,  876,  901,  921,  940, 1834, 1852, 1858, 1864,
+  1891, 1903, 1921, 1969, 1993, 2044, 2080, 2137, 2197, 2260, 2311, 2398,
+  2464, 2545, 2620, 2716, 2794, 2905, 3013, 3133, 3223, 3343, 3472, 3565,
+  3652, 3727, 3787, 3844,  301,  303,  307,  313,  319,  321,  330,  346,
+  357, 367, 385, 399, 420, 439, 462, 489, 509, 536, 565, 589,
+  624, 661, 691, 727, 768, 810, 838, 866, 890, 913, 934, 950,
+  1927, 1933, 1945, 1963, 1981, 1987, 2014, 2062, 2095, 2125, 2179, 2221,
+  2284, 2341, 2410, 2491, 2551, 2632, 2719, 2791, 2896, 3007, 3097, 3205,
+  3328, 3454, 3538, 3622, 3694, 3763, 3826, 3874,  334,  336,  338,  342,
+  348, 358, 362, 374, 387, 397, 416, 432, 450, 470, 495, 513,
+  542, 569, 591, 625, 657, 684, 723, 762, 797, 834, 862, 884,
+  905,  925,  942,  961, 2026, 2032, 2038, 2050, 2068, 2098, 2110, 2146,
+  2185, 2215, 2272, 2320, 2374, 2434, 2509, 2563, 2650, 2731, 2797, 2899,
+  2995, 3076, 3193, 3310, 3415, 3526, 3610, 3676, 3739, 3799, 3850, 3907,
+  364, 368, 372, 377, 381, 389, 393, 409, 421, 434, 448, 464,
+  486, 502, 527, 548, 575, 602, 628, 662, 685, 721, 756, 794,
+  827,  855,  880,  903,  923,  938,  954,  967, 2116, 2128, 2140, 2155,
+  2167, 2191, 2203, 2251, 2287, 2326, 2368, 2416, 2482, 2530, 2605, 2668,
+  2749, 2830, 2908, 3010, 3079, 3187, 3292, 3406, 3505, 3589, 3664, 3733,
+  3793, 3838, 3886, 3925,  401,  405,  407,  413,  417,  423,  430,  443,
+  456, 467, 483, 499, 519, 540, 561, 584, 610, 635, 664, 692,
+  724, 757, 792, 825, 850, 878, 899, 917, 936, 952, 965, 977,
+  2227, 2239, 2245, 2263, 2275, 2293, 2314, 2353, 2392, 2425, 2473, 2521,
+  2581, 2644, 2707, 2776, 2854, 2929, 3016, 3100, 3196, 3295, 3400, 3499,
+  3574, 3658, 3721, 3775, 3832, 3880, 3919, 3955,  436,  440,  444,  446,
+  454, 460, 468, 477, 493, 503, 522, 537, 550, 578, 595, 620,
+  644, 670, 704, 728, 763, 795, 826, 849, 873, 893, 915, 932,
+  948,  963,  975,  986, 2332, 2344, 2356, 2362, 2386, 2404, 2428, 2455,
+  2503, 2533, 2590, 2635, 2674, 2758, 2809, 2884, 2956, 3034, 3136, 3208,
+  3313, 3409, 3502, 3571, 3643, 3703, 3769, 3820, 3868, 3913, 3949, 3982,
+  472, 474, 481, 487, 491, 497, 505, 514, 529, 544, 555, 576,
+  588, 614, 633, 660, 680, 709, 734, 769, 798, 828, 851, 874,
+  892,  911,  930,  946,  959,  973,  984,  994, 2440, 2446, 2467, 2485,
+  2497, 2515, 2539, 2566, 2611, 2656, 2689, 2752, 2788, 2866, 2923, 3004,
+  3064, 3151, 3226, 3331, 3418, 3508, 3577, 3646, 3700, 3757, 3814, 3862,
+  3901, 3943, 3976, 4006,  515,  517,  523,  525,  531,  538,  546,  552,
+  570, 582, 596, 617, 631, 653, 676, 700, 720, 749, 774, 811,
+  835,  856,  879,  894,  912,  928,  944,  957,  971,  982,  992, 1001,
+  2569, 2575, 2593, 2599, 2617, 2638, 2662, 2680, 2734, 2770, 2812, 2875,
+  2917, 2983, 3052, 3124, 3184, 3271, 3346, 3457, 3529, 3592, 3661, 3706,
+  3760, 3808, 3856, 3895, 3937, 3970, 4000, 4027,  556,  558,  562,  566,
+  572, 580, 586, 597, 611, 623, 637, 655, 673, 693, 714, 738,
+  765, 790, 817, 839, 863, 881, 900, 916, 931, 945, 956, 969,
+  980,  990,  999, 1007, 2692, 2698, 2710, 2722, 2740, 2764, 2782, 2815,
+  2857, 2893, 2935, 2989, 3043, 3103, 3166, 3238, 3319, 3394, 3475, 3541,
+  3613, 3667, 3724, 3772, 3817, 3859, 3892, 3931, 3964, 3994, 4021, 4045,
+  599, 603, 605, 607, 615, 621, 629, 639, 650, 668, 678, 701,
+  716, 731, 758, 779, 807, 830, 848, 867, 885, 904, 918, 933,
+  947,  958,  970,  979,  988,  997, 1005, 1012, 2821, 2833, 2839, 2845,
+  2869, 2887, 2911, 2941, 2974, 3028, 3058, 3127, 3172, 3217, 3298, 3361,
+  3445, 3514, 3568, 3625, 3679, 3736, 3778, 3823, 3865, 3898, 3934, 3961,
+  3988, 4015, 4039, 4060,  641,  645,  647,  651,  658,  666,  674,  682,
+  696, 710, 725, 744, 761, 777, 802, 820, 842, 861, 877, 891,
+  906,  924,  937,  949,  960,  972,  981,  989,  996, 1003, 1010, 1016,
+  2947, 2959, 2965, 2977, 2998, 3022, 3046, 3070, 3112, 3154, 3199, 3256,
+  3307, 3355, 3430, 3484, 3550, 3607, 3655, 3697, 3742, 3796, 3835, 3871,
+  3904, 3940, 3967, 3991, 4012, 4033, 4054, 4072,  686,  688,  694,  702,
+  706, 712, 718, 729, 745, 753, 771, 784, 808, 823, 840, 857,
+  871, 888, 902, 914, 926, 939, 953, 964, 974, 983, 991, 998,
+  1004, 1009, 1014, 1019, 3082, 3088, 3106, 3130, 3142, 3160, 3178, 3211,
+  3259, 3283, 3337, 3376, 3448, 3493, 3544, 3595, 3637, 3688, 3730, 3766,
+  3802, 3841, 3883, 3916, 3946, 3973, 3997, 4018, 4036, 4051, 4066, 4081,
+  735, 739, 741, 747, 751, 759, 767, 775, 787, 804, 818, 832,
+  846, 859, 869, 883, 896, 910, 922, 935, 943, 955, 966, 976,
+  985,  993, 1000, 1006, 1011, 1015, 1018, 1021, 3229, 3241, 3247, 3265,
+  3277, 3301, 3325, 3349, 3385, 3436, 3478, 3520, 3562, 3601, 3631, 3673,
+  3712, 3754, 3790, 3829, 3853, 3889, 3922, 3952, 3979, 4003, 4024, 4042,
+  4057, 4069, 4078, 4087,  781,  785,  791,  796,  800,  812,  814,  824,
+  836, 844, 853, 865, 875, 889, 898, 908, 920, 929, 941, 951,
+  962,  968,  978,  987,  995, 1002, 1008, 1013, 1017, 1020, 1022, 1023,
+  3367, 3379, 3397, 3412, 3424, 3460, 3466, 3496, 3532, 3556, 3583, 3619,
+  3649, 3691, 3718, 3748, 3784, 3811, 3847, 3877, 3910, 3928, 3958, 3985,
+  4009, 4030, 4048, 4063, 4075, 4084, 4090, 4093, 1025, 1028, 1037, 1052,
+  1070, 1091, 1124, 1154, 1193, 1238, 1283, 1337, 1388, 1451, 1523, 1592,
+  1667, 1742, 1832, 1925, 2018, 2114, 2225, 2330, 2438, 2555, 2684, 2819,
+  2945, 3074, 3221, 3365, 1026, 1029, 1038, 1053, 1071, 1092, 1125, 1155,
+  1194, 1239, 1284, 1338, 1389, 1452, 1524, 1593, 1668, 1743, 1833, 1926,
+  2019, 2115, 2226, 2331, 2439, 2556, 2685, 2820, 2946, 3075, 3222, 3366,
+  1031, 1034, 1043, 1058, 1076, 1103, 1130, 1160, 1199, 1244, 1295, 1343,
+  1394, 1463, 1529, 1604, 1673, 1754, 1838, 1931, 2030, 2120, 2231, 2336,
+  2444, 2573, 2696, 2825, 2951, 3086, 3233, 3371, 1032, 1035, 1044, 1059,
+  1077, 1104, 1131, 1161, 1200, 1245, 1296, 1344, 1395, 1464, 1530, 1605,
+  1674, 1755, 1839, 1932, 2031, 2121, 2232, 2337, 2445, 2574, 2697, 2826,
+  2952, 3087, 3234, 3372, 1040, 1046, 1049, 1064, 1085, 1109, 1136, 1175,
+  1211, 1250, 1301, 1349, 1412, 1475, 1535, 1610, 1679, 1772, 1856, 1937,
+  2036, 2132, 2243, 2348, 2459, 2585, 2702, 2837, 2963, 3092, 3245, 3389,
+  1041, 1047, 1050, 1065, 1086, 1110, 1137, 1176, 1212, 1251, 1302, 1350,
+  1413, 1476, 1536, 1611, 1680, 1773, 1857, 1938, 2037, 2133, 2244, 2349,
+  2460, 2586, 2703, 2838, 2964, 3093, 3246, 3390, 1055, 1061, 1067, 1082,
+  1094, 1118, 1148, 1181, 1220, 1268, 1313, 1364, 1424, 1481, 1550, 1628,
+  1697, 1784, 1862, 1955, 2048, 2150, 2255, 2360, 2477, 2597, 2714, 2843,
+  2969, 3116, 3263, 3404, 1056, 1062, 1068, 1083, 1095, 1119, 1149, 1182,
+  1221, 1269, 1314, 1365, 1425, 1482, 1551, 1629, 1698, 1785, 1863, 1956,
+  2049, 2151, 2256, 2361, 2478, 2598, 2715, 2844, 2970, 3117, 3264, 3405,
+  1073, 1079, 1088, 1097, 1115, 1142, 1169, 1202, 1232, 1274, 1325, 1382,
+  1436, 1499, 1568, 1634, 1715, 1790, 1883, 1973, 2066, 2165, 2267, 2378,
+  2495, 2615, 2738, 2861, 2993, 3140, 3275, 3422, 1074, 1080, 1089, 1098,
+  1116, 1143, 1170, 1203, 1233, 1275, 1326, 1383, 1437, 1500, 1569, 1635,
+  1716, 1791, 1884, 1974, 2067, 2166, 2268, 2379, 2496, 2616, 2739, 2862,
+  2994, 3141, 3276, 3423, 1100, 1106, 1112, 1121, 1145, 1163, 1187, 1226,
+  1262, 1307, 1352, 1406, 1454, 1517, 1580, 1655, 1733, 1814, 1901, 1985,
+  2084, 2189, 2291, 2402, 2513, 2624, 2762, 2879, 3020, 3158, 3287, 3452,
+  1101, 1107, 1113, 1122, 1146, 1164, 1188, 1227, 1263, 1308, 1353, 1407,
+  1455, 1518, 1581, 1656, 1734, 1815, 1902, 1986, 2085, 2190, 2292, 2403,
+  2514, 2625, 2763, 2880, 3021, 3159, 3288, 3453, 1127, 1133, 1139, 1151,
+  1172, 1190, 1217, 1253, 1286, 1331, 1376, 1430, 1487, 1553, 1616, 1691,
+  1766, 1841, 1919, 2012, 2108, 2201, 2306, 2420, 2537, 2660, 2780, 2903,
+  3038, 3176, 3323, 3464, 1128, 1134, 1140, 1152, 1173, 1191, 1218, 1254,
+  1287, 1332, 1377, 1431, 1488, 1554, 1617, 1692, 1767, 1842, 1920, 2013,
+  2109, 2202, 2307, 2421, 2538, 2661, 2781, 2904, 3039, 3177, 3324, 3465,
+  1157, 1166, 1178, 1184, 1205, 1229, 1256, 1280, 1319, 1367, 1418, 1466,
+  1511, 1574, 1649, 1721, 1793, 1874, 1967, 2054, 2144, 2249, 2351, 2450,
+  2558, 2678, 2801, 2939, 3068, 3203, 3341, 3488, 1158, 1167, 1179, 1185,
+  1206, 1230, 1257, 1281, 1320, 1368, 1419, 1467, 1512, 1575, 1650, 1722,
+  1794, 1875, 1968, 2055, 2145, 2250, 2352, 2451, 2559, 2679, 2802, 2940,
+  3069, 3204, 3342, 3489, 1196, 1208, 1214, 1223, 1235, 1265, 1289, 1322,
+  1361, 1397, 1445, 1502, 1562, 1622, 1682, 1745, 1826, 1907, 1991, 2087,
+  2183, 2279, 2390, 2501, 2609, 2726, 2849, 2972, 3110, 3251, 3383, 3524,
+  1197, 1209, 1215, 1224, 1236, 1266, 1290, 1323, 1362, 1398, 1446, 1503,
+  1563, 1623, 1683, 1746, 1827, 1908, 1992, 2088, 2184, 2280, 2391, 2502,
+  2610, 2727, 2850, 2973, 3111, 3252, 3384, 3525, 1241, 1247, 1259, 1271,
+  1277, 1310, 1334, 1370, 1400, 1442, 1493, 1544, 1595, 1658, 1727, 1802,
+  1868, 1958, 2042, 2123, 2207, 2324, 2423, 2525, 2654, 2768, 2891, 3026,
+  3146, 3281, 3434, 3554, 1242, 1248, 1260, 1272, 1278, 1311, 1335, 1371,
+  1401, 1443, 1494, 1545, 1596, 1659, 1728, 1803, 1869, 1959, 2043, 2124,
+  2208, 2325, 2424, 2526, 2655, 2769, 2892, 3027, 3147, 3282, 3435, 3555,
+  1292, 1298, 1304, 1316, 1328, 1355, 1379, 1421, 1448, 1496, 1538, 1583,
+  1643, 1709, 1778, 1844, 1913, 1997, 2078, 2177, 2270, 2366, 2471, 2588,
+  2687, 2804, 2933, 3056, 3191, 3335, 3470, 3581, 1293, 1299, 1305, 1317,
+  1329, 1356, 1380, 1422, 1449, 1497, 1539, 1584, 1644, 1710, 1779, 1845,
+  1914, 1998, 2079, 2178, 2271, 2367, 2472, 2589, 2688, 2805, 2934, 3057,
+  3192, 3336, 3471, 3582, 1340, 1346, 1358, 1373, 1385, 1409, 1433, 1469,
+  1505, 1547, 1586, 1640, 1700, 1757, 1820, 1895, 1976, 2057, 2135, 2219,
+  2318, 2414, 2519, 2627, 2744, 2873, 2987, 3119, 3254, 3374, 3518, 3617,
+  1341, 1347, 1359, 1374, 1386, 1410, 1434, 1470, 1506, 1548, 1587, 1641,
+  1701, 1758, 1821, 1896, 1977, 2058, 2136, 2220, 2319, 2415, 2520, 2628,
+  2745, 2874, 2988, 3120, 3255, 3375, 3519, 3618, 1391, 1403, 1415, 1427,
+  1439, 1457, 1490, 1514, 1565, 1598, 1646, 1703, 1739, 1808, 1886, 1949,
+  2021, 2102, 2195, 2282, 2372, 2480, 2579, 2672, 2786, 2915, 3041, 3170,
+  3305, 3440, 3560, 3641, 1392, 1404, 1416, 1428, 1440, 1458, 1491, 1515,
+  1566, 1599, 1647, 1704, 1740, 1809, 1887, 1950, 2022, 2103, 2196, 2283,
+  2373, 2481, 2580, 2673, 2787, 2916, 3042, 3171, 3306, 3441, 3561, 3642,
+  1460, 1472, 1478, 1484, 1508, 1520, 1556, 1577, 1625, 1661, 1712, 1760,
+  1811, 1877, 1940, 2006, 2090, 2171, 2258, 2339, 2432, 2528, 2642, 2756,
+  2864, 2981, 3095, 3215, 3353, 3491, 3599, 3683, 1461, 1473, 1479, 1485,
+  1509, 1521, 1557, 1578, 1626, 1662, 1713, 1761, 1812, 1878, 1941, 2007,
+  2091, 2172, 2259, 2340, 2433, 2529, 2643, 2757, 2865, 2982, 3096, 3216,
+  3354, 3492, 3600, 3684, 1526, 1532, 1541, 1559, 1571, 1589, 1619, 1652,
+  1685, 1730, 1781, 1823, 1889, 1943, 2003, 2072, 2159, 2234, 2309, 2408,
+  2507, 2603, 2705, 2807, 2921, 3050, 3164, 3290, 3428, 3536, 3629, 3716,
+  1527, 1533, 1542, 1560, 1572, 1590, 1620, 1653, 1686, 1731, 1782, 1824,
+  1890, 1944, 2004, 2073, 2160, 2235, 2310, 2409, 2508, 2604, 2706, 2808,
+  2922, 3051, 3165, 3291, 3429, 3537, 3630, 3717, 1601, 1607, 1613, 1631,
+  1637, 1664, 1694, 1724, 1748, 1805, 1847, 1898, 1952, 2009, 2075, 2153,
+  2210, 2300, 2396, 2489, 2561, 2666, 2774, 2882, 3002, 3122, 3236, 3359,
+  3482, 3587, 3671, 3746, 1602, 1608, 1614, 1632, 1638, 1665, 1695, 1725,
+  1749, 1806, 1848, 1899, 1953, 2010, 2076, 2154, 2211, 2301, 2397, 2490,
+  2562, 2667, 2775, 2883, 3003, 3123, 3237, 3360, 3483, 3588, 3672, 3747,
+  1670, 1676, 1688, 1706, 1718, 1736, 1769, 1796, 1829, 1871, 1916, 1979,
+  2024, 2093, 2162, 2213, 2297, 2381, 2462, 2549, 2648, 2747, 2852, 2954,
+  3062, 3182, 3317, 3443, 3548, 3635, 3710, 3782, 1671, 1677, 1689, 1707,
+  1719, 1737, 1770, 1797, 1830, 1872, 1917, 1980, 2025, 2094, 2163, 2214,
+  2298, 2382, 2463, 2550, 2649, 2748, 2853, 2955, 3063, 3183, 3318, 3444,
+  3549, 3636, 3711, 3783, 1751, 1763, 1775, 1787, 1799, 1817, 1850, 1880,
+  1910, 1961, 2000, 2060, 2105, 2174, 2237, 2303, 2384, 2453, 2543, 2630,
+  2729, 2828, 2927, 3032, 3149, 3269, 3392, 3512, 3605, 3686, 3752, 3806,
+  1752, 1764, 1776, 1788, 1800, 1818, 1851, 1881, 1911, 1962, 2001, 2061,
+  2106, 2175, 2238, 2304, 2385, 2454, 2544, 2631, 2730, 2829, 2928, 3033,
+  3150, 3270, 3393, 3513, 3606, 3687, 3753, 3807, 1835, 1853, 1859, 1865,
+  1892, 1904, 1922, 1970, 1994, 2045, 2081, 2138, 2198, 2261, 2312, 2399,
+  2465, 2546, 2621, 2717, 2795, 2906, 3014, 3134, 3224, 3344, 3473, 3566,
+  3653, 3728, 3788, 3845, 1836, 1854, 1860, 1866, 1893, 1905, 1923, 1971,
+  1995, 2046, 2082, 2139, 2199, 2262, 2313, 2400, 2466, 2547, 2622, 2718,
+  2796, 2907, 3015, 3135, 3225, 3345, 3474, 3567, 3654, 3729, 3789, 3846,
+  1928, 1934, 1946, 1964, 1982, 1988, 2015, 2063, 2096, 2126, 2180, 2222,
+  2285, 2342, 2411, 2492, 2552, 2633, 2720, 2792, 2897, 3008, 3098, 3206,
+  3329, 3455, 3539, 3623, 3695, 3764, 3827, 3875, 1929, 1935, 1947, 1965,
+  1983, 1989, 2016, 2064, 2097, 2127, 2181, 2223, 2286, 2343, 2412, 2493,
+  2553, 2634, 2721, 2793, 2898, 3009, 3099, 3207, 3330, 3456, 3540, 3624,
+  3696, 3765, 3828, 3876, 2027, 2033, 2039, 2051, 2069, 2099, 2111, 2147,
+  2186, 2216, 2273, 2321, 2375, 2435, 2510, 2564, 2651, 2732, 2798, 2900,
+  2996, 3077, 3194, 3311, 3416, 3527, 3611, 3677, 3740, 3800, 3851, 3908,
+  2028, 2034, 2040, 2052, 2070, 2100, 2112, 2148, 2187, 2217, 2274, 2322,
+  2376, 2436, 2511, 2565, 2652, 2733, 2799, 2901, 2997, 3078, 3195, 3312,
+  3417, 3528, 3612, 3678, 3741, 3801, 3852, 3909, 2117, 2129, 2141, 2156,
+  2168, 2192, 2204, 2252, 2288, 2327, 2369, 2417, 2483, 2531, 2606, 2669,
+  2750, 2831, 2909, 3011, 3080, 3188, 3293, 3407, 3506, 3590, 3665, 3734,
+  3794, 3839, 3887, 3926, 2118, 2130, 2142, 2157, 2169, 2193, 2205, 2253,
+  2289, 2328, 2370, 2418, 2484, 2532, 2607, 2670, 2751, 2832, 2910, 3012,
+  3081, 3189, 3294, 3408, 3507, 3591, 3666, 3735, 3795, 3840, 3888, 3927,
+  2228, 2240, 2246, 2264, 2276, 2294, 2315, 2354, 2393, 2426, 2474, 2522,
+  2582, 2645, 2708, 2777, 2855, 2930, 3017, 3101, 3197, 3296, 3401, 3500,
+  3575, 3659, 3722, 3776, 3833, 3881, 3920, 3956, 2229, 2241, 2247, 2265,
+  2277, 2295, 2316, 2355, 2394, 2427, 2475, 2523, 2583, 2646, 2709, 2778,
+  2856, 2931, 3018, 3102, 3198, 3297, 3402, 3501, 3576, 3660, 3723, 3777,
+  3834, 3882, 3921, 3957, 2333, 2345, 2357, 2363, 2387, 2405, 2429, 2456,
+  2504, 2534, 2591, 2636, 2675, 2759, 2810, 2885, 2957, 3035, 3137, 3209,
+  3314, 3410, 3503, 3572, 3644, 3704, 3770, 3821, 3869, 3914, 3950, 3983,
+  2334, 2346, 2358, 2364, 2388, 2406, 2430, 2457, 2505, 2535, 2592, 2637,
+  2676, 2760, 2811, 2886, 2958, 3036, 3138, 3210, 3315, 3411, 3504, 3573,
+  3645, 3705, 3771, 3822, 3870, 3915, 3951, 3984, 2441, 2447, 2468, 2486,
+  2498, 2516, 2540, 2567, 2612, 2657, 2690, 2753, 2789, 2867, 2924, 3005,
+  3065, 3152, 3227, 3332, 3419, 3509, 3578, 3647, 3701, 3758, 3815, 3863,
+  3902, 3944, 3977, 4007, 2442, 2448, 2469, 2487, 2499, 2517, 2541, 2568,
+  2613, 2658, 2691, 2754, 2790, 2868, 2925, 3006, 3066, 3153, 3228, 3333,
+  3420, 3510, 3579, 3648, 3702, 3759, 3816, 3864, 3903, 3945, 3978, 4008,
+  2570, 2576, 2594, 2600, 2618, 2639, 2663, 2681, 2735, 2771, 2813, 2876,
+  2918, 2984, 3053, 3125, 3185, 3272, 3347, 3458, 3530, 3593, 3662, 3707,
+  3761, 3809, 3857, 3896, 3938, 3971, 4001, 4028, 2571, 2577, 2595, 2601,
+  2619, 2640, 2664, 2682, 2736, 2772, 2814, 2877, 2919, 2985, 3054, 3126,
+  3186, 3273, 3348, 3459, 3531, 3594, 3663, 3708, 3762, 3810, 3858, 3897,
+  3939, 3972, 4002, 4029, 2693, 2699, 2711, 2723, 2741, 2765, 2783, 2816,
+  2858, 2894, 2936, 2990, 3044, 3104, 3167, 3239, 3320, 3395, 3476, 3542,
+  3614, 3668, 3725, 3773, 3818, 3860, 3893, 3932, 3965, 3995, 4022, 4046,
+  2694, 2700, 2712, 2724, 2742, 2766, 2784, 2817, 2859, 2895, 2937, 2991,
+  3045, 3105, 3168, 3240, 3321, 3396, 3477, 3543, 3615, 3669, 3726, 3774,
+  3819, 3861, 3894, 3933, 3966, 3996, 4023, 4047, 2822, 2834, 2840, 2846,
+  2870, 2888, 2912, 2942, 2975, 3029, 3059, 3128, 3173, 3218, 3299, 3362,
+  3446, 3515, 3569, 3626, 3680, 3737, 3779, 3824, 3866, 3899, 3935, 3962,
+  3989, 4016, 4040, 4061, 2823, 2835, 2841, 2847, 2871, 2889, 2913, 2943,
+  2976, 3030, 3060, 3129, 3174, 3219, 3300, 3363, 3447, 3516, 3570, 3627,
+  3681, 3738, 3780, 3825, 3867, 3900, 3936, 3963, 3990, 4017, 4041, 4062,
+  2948, 2960, 2966, 2978, 2999, 3023, 3047, 3071, 3113, 3155, 3200, 3257,
+  3308, 3356, 3431, 3485, 3551, 3608, 3656, 3698, 3743, 3797, 3836, 3872,
+  3905, 3941, 3968, 3992, 4013, 4034, 4055, 4073, 2949, 2961, 2967, 2979,
+  3000, 3024, 3048, 3072, 3114, 3156, 3201, 3258, 3309, 3357, 3432, 3486,
+  3552, 3609, 3657, 3699, 3744, 3798, 3837, 3873, 3906, 3942, 3969, 3993,
+  4014, 4035, 4056, 4074, 3083, 3089, 3107, 3131, 3143, 3161, 3179, 3212,
+  3260, 3284, 3338, 3377, 3449, 3494, 3545, 3596, 3638, 3689, 3731, 3767,
+  3803, 3842, 3884, 3917, 3947, 3974, 3998, 4019, 4037, 4052, 4067, 4082,
+  3084, 3090, 3108, 3132, 3144, 3162, 3180, 3213, 3261, 3285, 3339, 3378,
+  3450, 3495, 3546, 3597, 3639, 3690, 3732, 3768, 3804, 3843, 3885, 3918,
+  3948, 3975, 3999, 4020, 4038, 4053, 4068, 4083, 3230, 3242, 3248, 3266,
+  3278, 3302, 3326, 3350, 3386, 3437, 3479, 3521, 3563, 3602, 3632, 3674,
+  3713, 3755, 3791, 3830, 3854, 3890, 3923, 3953, 3980, 4004, 4025, 4043,
+  4058, 4070, 4079, 4088, 3231, 3243, 3249, 3267, 3279, 3303, 3327, 3351,
+  3387, 3438, 3480, 3522, 3564, 3603, 3633, 3675, 3714, 3756, 3792, 3831,
+  3855, 3891, 3924, 3954, 3981, 4005, 4026, 4044, 4059, 4071, 4080, 4089,
+  3368, 3380, 3398, 3413, 3425, 3461, 3467, 3497, 3533, 3557, 3584, 3620,
+  3650, 3692, 3719, 3749, 3785, 3812, 3848, 3878, 3911, 3929, 3959, 3986,
+  4010, 4031, 4049, 4064, 4076, 4085, 4091, 4094, 3369, 3381, 3399, 3414,
+  3426, 3462, 3468, 3498, 3534, 3558, 3585, 3621, 3651, 3693, 3720, 3750,
+  3786, 3813, 3849, 3879, 3912, 3930, 3960, 3987, 4011, 4032, 4050, 4065,
+  4077, 4086, 4092, 4095,
+};
+#endif  // CONFIG_WAVELETS
 #endif  // CONFIG_TX64X64
 
 #if CONFIG_TX_SKIP
@@ -2807,22 +4633,22 @@ const scan_order vp9_default_scan_orders[TX_SIZES] = {
 #endif
 };
 
-const scan_order vp9_scan_orders[TX_SIZES][TX_TYPES] = {
+const scan_order vp9_intra_scan_orders[TX_SIZES][TX_TYPES] = {
   {  // TX_4X4
     {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
     {row_scan_4x4,     vp9_row_iscan_4x4,     row_scan_4x4_neighbors},
     {col_scan_4x4,     vp9_col_iscan_4x4,     col_scan_4x4_neighbors},
-    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors}
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
   }, {  // TX_8X8
     {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
     {row_scan_8x8,     vp9_row_iscan_8x8,     row_scan_8x8_neighbors},
     {col_scan_8x8,     vp9_col_iscan_8x8,     col_scan_8x8_neighbors},
-    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors}
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
   }, {  // TX_16X16
     {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
     {row_scan_16x16,     vp9_row_iscan_16x16,     row_scan_16x16_neighbors},
     {col_scan_16x16,     vp9_col_iscan_16x16,     col_scan_16x16_neighbors},
-    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors}
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
   }, {  // TX_32X32
     {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
     {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
@@ -2837,3 +4663,76 @@ const scan_order vp9_scan_orders[TX_SIZES][TX_TYPES] = {
 #endif
   }
 };
+
+#if CONFIG_EXT_TX
+const scan_order vp9_inter_scan_orders[TX_SIZES][TOTAL_TX_TYPES] = {
+  {  // TX_4X4
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+#if CONFIG_WAVELETS
+    {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+#endif  // CONFIG_WAVELETS
+  }, {  // TX_8X8
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+#if CONFIG_WAVELETS
+    {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors}
+#endif  // CONFIG_WAVELETS
+  }, {  // TX_16X16
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+#if CONFIG_WAVELETS
+    {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors}
+#endif  // CONFIG_WAVELETS
+  }, {  // TX_32X32
+    {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+    {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+    {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+    {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+    {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+    {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+    {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+    {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+    {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+#if CONFIG_WAVELETS
+    {dwtdct_scan_32x32, vp9_dwtdct_iscan_32x32, dwtdct_scan_32x32_neighbors},
+#endif  // CONFIG_WAVELETS
+#if CONFIG_TX64X64
+  }, {  // TX_64X64
+    {default_scan_64x64, vp9_default_iscan_64x64, default_scan_64x64_neighbors},
+    {default_scan_64x64, vp9_default_iscan_64x64, default_scan_64x64_neighbors},
+    {default_scan_64x64, vp9_default_iscan_64x64, default_scan_64x64_neighbors},
+    {default_scan_64x64, vp9_default_iscan_64x64, default_scan_64x64_neighbors},
+    {default_scan_64x64, vp9_default_iscan_64x64, default_scan_64x64_neighbors},
+    {default_scan_64x64, vp9_default_iscan_64x64, default_scan_64x64_neighbors},
+    {default_scan_64x64, vp9_default_iscan_64x64, default_scan_64x64_neighbors},
+    {default_scan_64x64, vp9_default_iscan_64x64, default_scan_64x64_neighbors},
+    {default_scan_64x64, vp9_default_iscan_64x64, default_scan_64x64_neighbors},
+#if CONFIG_WAVELETS
+    {dwtdct_scan_64x64, vp9_dwtdct_iscan_64x64, dwtdct_scan_64x64_neighbors},
+#endif  // CONFIG_WAVELETS
+#endif  // CONFIG_TX64X64
+  }
+};
+#endif  // CONFIG_EXT_TX
index 91c4d4e9319916c0ea1368836729f530f1aef075..8d420f3d5e6b3d5d3dacbe0de73eed28635fbaa3 100644 (file)
@@ -30,7 +30,10 @@ typedef struct {
 } scan_order;
 
 extern const scan_order vp9_default_scan_orders[TX_SIZES];
-extern const scan_order vp9_scan_orders[TX_SIZES][TX_TYPES];
+extern const scan_order vp9_intra_scan_orders[TX_SIZES][TX_TYPES];
+#if CONFIG_EXT_TX
+extern const scan_order vp9_inter_scan_orders[TX_SIZES][TOTAL_TX_TYPES];
+#endif  // CONFIG_EXT_TX
 
 #if CONFIG_TX_SKIP
 // pixel domain default scan orders
index 2abb85306f37c6bb052c104be9e82fe270915098..7f5befe58e3f480dc301aa13a32083051029040f 100644 (file)
@@ -495,12 +495,22 @@ static void inverse_transform_block(MACROBLOCKD* xd, int plane, int block,
                 vp9_iht16x16_add(tx_type, dqcoeff, dst, stride, eob);
                 break;
               case TX_32X32:
-                tx_type = DCT_DCT;
-                vp9_idct32x32_add(dqcoeff, dst, stride, eob);
+                tx_type = get_tx_type_large(plane_type, xd);
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+                if (tx_type == WAVELET1_DCT_DCT)
+                  vp9_idwtdct32x32_add(dqcoeff, dst, stride);
+                else
+#endif  // CONFIG_EXT_TX && CONFIG_WAVELETS
+                  vp9_idct32x32_add(dqcoeff, dst, stride, eob);
                 break;
 #if CONFIG_TX64X64
               case TX_64X64:
-                tx_type = DCT_DCT;
+                tx_type = get_tx_type_large(plane_type, xd);
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+                if (tx_type == WAVELET1_DCT_DCT)
+                  vp9_idwtdct64x64_add(dqcoeff, dst, stride);
+                else
+#endif  // CONFIG_EXT_TX && CONFIG_WAVELETS
                 vp9_idct64x64_add(dqcoeff, dst, stride, eob);
                 break;
 #endif  // CONFIG_TX64X64
@@ -525,7 +535,6 @@ static void inverse_transform_block(MACROBLOCKD* xd, int plane, int block,
       vp9_iwht4x4_add(dqcoeff, dst, stride, eob);
     } else {
       const PLANE_TYPE plane_type = pd->plane_type;
-
 #if CONFIG_TX_SKIP
       if (mbmi->tx_skip[plane != 0]) {
         int bs = 4 << tx_size;
@@ -555,12 +564,22 @@ static void inverse_transform_block(MACROBLOCKD* xd, int plane, int block,
           vp9_iht16x16_add(tx_type, dqcoeff, dst, stride, eob);
           break;
         case TX_32X32:
-          tx_type = DCT_DCT;
-          vp9_idct32x32_add(dqcoeff, dst, stride, eob);
+          tx_type = get_tx_type_large(plane_type, xd);
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+          if (tx_type == WAVELET1_DCT_DCT)
+            vp9_idwtdct32x32_add(dqcoeff, dst, stride);
+          else
+#endif  // CONFIG_EXT_TX && CONFIG_WAVELETS
+            vp9_idct32x32_add(dqcoeff, dst, stride, eob);
           break;
 #if CONFIG_TX64X64
         case TX_64X64:
-          tx_type = DCT_DCT;
+          tx_type = get_tx_type_large(plane_type, xd);
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+          if (tx_type == WAVELET1_DCT_DCT)
+            vp9_idwtdct64x64_add(dqcoeff, dst, stride);
+          else
+#endif  // CONFIG_EXT_TX && CONFIG_WAVELETS
           vp9_idct64x64_add(dqcoeff, dst, stride, eob);
           break;
 #endif  // CONFIG_TX64X64
@@ -1769,18 +1788,28 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
     if (skip)
       reset_skip_context(xd, bsize);
 #if CONFIG_EXT_TX
-    if (bsize <= BLOCK_16X16 && !skip) {
-      txfm = vp9_read_tree(r, vp9_ext_tx_tree,
-                           cm->fc.ext_tx_prob[supertx_size]);
-      if (!cm->frame_parallel_decoding_mode)
-        ++cm->counts.ext_tx[supertx_size][txfm];
+    if (!skip) {
+      if (supertx_size <= TX_16X16) {
+        txfm = vp9_read_tree(r, vp9_ext_tx_tree,
+                             cm->fc.ext_tx_prob[supertx_size]);
+        if (!cm->frame_parallel_decoding_mode)
+          ++cm->counts.ext_tx[supertx_size][txfm];
+#if CONFIG_WAVELETS
+      } else {
+        txfm = vp9_read_tree(r, vp9_ext_tx_large_tree,
+                             cm->fc.ext_tx_prob[supertx_size]);
+        if (!cm->frame_parallel_decoding_mode)
+          ++cm->counts.ext_tx[supertx_size][txfm];
+#endif  // CONFIG_WAVELETS
+      }
     }
-#endif
+#endif  // CONFIG_EXT_TX
   }
 #endif  // CONFIG_SUPERTX
   if (subsize < BLOCK_8X8) {
     decode_block(cm, xd, tile,
 #if CONFIG_SUPERTX
+
                  supertx_enabled,
 #endif
 #if CONFIG_COPY_MODE
@@ -3210,6 +3239,11 @@ static void read_ext_tx_probs(FRAME_CONTEXT *fc, vp9_reader *r) {
     for (j = TX_4X4; j <= TX_16X16; ++j)
       for (i = 0; i < EXT_TX_TYPES - 1; ++i)
         vp9_diff_update_prob(r, &fc->ext_tx_prob[j][i]);
+#if CONFIG_WAVELETS
+    for (; j < TX_SIZES; ++j)
+      for (i = 0; i < EXT_TX_TYPES_LARGE - 1; ++i)
+        vp9_diff_update_prob(r, &fc->ext_tx_prob[j][i]);
+#endif
   }
 }
 #endif  // CONFIG_EXT_TX
@@ -3494,7 +3528,7 @@ static void debug_check_frame_counts(const VP9_COMMON *const cm) {
 #if CONFIG_EXT_TX
   assert(!memcmp(cm->counts.ext_tx, zero_counts.ext_tx,
                  sizeof(cm->counts.ext_tx)));
-#endif
+#endif  // CONFIG_EXT_TX
 #if CONFIG_NEW_INTER
   assert(!memcmp(cm->counts.inter_compound_mode,
                  zero_counts.inter_compound_mode,
index e9b7104ff45ba06e5c66e928edd2bf923cab38af..90070340c1b30c92f8590e270ba69a6132a8c8b0 100644 (file)
@@ -1522,15 +1522,22 @@ static void read_inter_frame_mode_info(VP9_COMMON *const cm,
 
 #if CONFIG_EXT_TX
     if (inter_block &&
+#if !CONFIG_WAVELETS
         mbmi->tx_size <= TX_16X16 &&
+#endif
         cm->base_qindex > 0 &&
         mbmi->sb_type >= BLOCK_8X8 &&
 #if CONFIG_SUPERTX
-      !supertx_enabled &&
+        !supertx_enabled &&
+#endif
+        !vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP) &&
+        !mbmi->skip) {
+      mbmi->ext_txfrm = vp9_read_tree(r,
+#if CONFIG_WAVELETS
+                                      GET_EXT_TX_TREE(mbmi->tx_size),
+#else
+                                      vp9_ext_tx_tree,
 #endif
-      !vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP) &&
-      !mbmi->skip) {
-      mbmi->ext_txfrm = vp9_read_tree(r, vp9_ext_tx_tree,
                                       cm->fc.ext_tx_prob[mbmi->tx_size]);
       if (!cm->frame_parallel_decoding_mode)
         ++cm->counts.ext_tx[mbmi->tx_size][mbmi->ext_txfrm];
index e900e5998d2d1e8a12d03f1e50052c888d7aba9c..f7e8313eed5a052ae55ef6c64a09ac174baf55ae 100644 (file)
@@ -46,7 +46,10 @@ static struct vp9_token partition_encodings[PARTITION_TYPES];
 static struct vp9_token inter_mode_encodings[INTER_MODES];
 #if CONFIG_EXT_TX
 static struct vp9_token ext_tx_encodings[EXT_TX_TYPES];
-#endif
+#if CONFIG_WAVELETS
+static struct vp9_token ext_tx_large_encodings[EXT_TX_TYPES_LARGE];
+#endif  // CONFIG_WAVELETS
+#endif  // CONFIG_EXT_TX
 #if CONFIG_PALETTE
 static struct vp9_token palette_size_encodings[PALETTE_SIZES];
 static struct vp9_token palette_color_encodings[PALETTE_COLORS];
@@ -84,7 +87,10 @@ void vp9_entropy_mode_init() {
   vp9_tokens_from_tree(inter_mode_encodings, vp9_inter_mode_tree);
 #if CONFIG_EXT_TX
   vp9_tokens_from_tree(ext_tx_encodings, vp9_ext_tx_tree);
+#if CONFIG_WAVELETS
+  vp9_tokens_from_tree(ext_tx_large_encodings, vp9_ext_tx_large_tree);
 #endif
+#endif  // CONFIG_EXT_TX
 #if CONFIG_PALETTE
   vp9_tokens_from_tree(palette_size_encodings, vp9_palette_size_tree);
   vp9_tokens_from_tree(palette_color_encodings, vp9_palette_color_tree);
@@ -245,6 +251,13 @@ static void update_ext_tx_probs(VP9_COMMON *cm, vp9_writer *w) {
     savings += prob_diff_update_savings(vp9_ext_tx_tree, cm->fc.ext_tx_prob[i],
                                         cm->counts.ext_tx[i], EXT_TX_TYPES);
   }
+#if CONFIG_WAVELETS
+  for (; i < TX_SIZES; ++i) {
+    savings += prob_diff_update_savings(
+        vp9_ext_tx_large_tree, cm->fc.ext_tx_prob[i], cm->counts.ext_tx[i],
+        EXT_TX_TYPES_LARGE);
+  }
+#endif
   do_update = savings > savings_thresh;
   vp9_write(w, do_update, GROUP_DIFF_UPDATE_PROB);
   if (do_update) {
@@ -252,6 +265,12 @@ static void update_ext_tx_probs(VP9_COMMON *cm, vp9_writer *w) {
       prob_diff_update(vp9_ext_tx_tree, cm->fc.ext_tx_prob[i],
                        cm->counts.ext_tx[i], EXT_TX_TYPES, w);
     }
+#if CONFIG_WAVELETS
+    for (; i < TX_SIZES; ++i) {
+      prob_diff_update(vp9_ext_tx_large_tree, cm->fc.ext_tx_prob[i],
+                       cm->counts.ext_tx[i], EXT_TX_TYPES_LARGE, w);
+    }
+#endif  // CONFIG_WAVELETS
   }
 }
 #endif  // CONFIG_EXT_TX
@@ -607,7 +626,9 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
   }
 #if CONFIG_EXT_TX
   if (is_inter &&
-      mbmi->tx_size < TX_32X32 &&
+#if !CONFIG_WAVELETS
+      mbmi->tx_size <= TX_16X16 &&
+#endif
       cm->base_qindex > 0 &&
       bsize >= BLOCK_8X8 &&
 #if CONFIG_SUPERTX
@@ -615,8 +636,14 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
 #endif
       !mbmi->skip &&
       !vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
+#if CONFIG_WAVELETS
+    vp9_write_token(w, GET_EXT_TX_TREE(mbmi->tx_size),
+                    cm->fc.ext_tx_prob[mbmi->tx_size],
+                    &((GET_EXT_TX_ENCODINGS(mbmi->tx_size))[mbmi->ext_txfrm]));
+#else
     vp9_write_token(w, vp9_ext_tx_tree, cm->fc.ext_tx_prob[mbmi->tx_size],
                     &ext_tx_encodings[mbmi->ext_txfrm]);
+#endif  // CONFIG_WAVELETS
   }
 #endif  // CONFIG_EXT_TX
 
@@ -1211,10 +1238,18 @@ static void write_modes_sb(VP9_COMP *cpi,
     if (supertx_enabled) {
       vp9_write(w, xd->mi[0].mbmi.skip, vp9_get_skip_prob(cm, xd));
 #if CONFIG_EXT_TX
+#if CONFIG_WAVELETS
+      if (!xd->mi[0].mbmi.skip)
+        vp9_write_token(w, GET_EXT_TX_TREE(supertx_size),
+                        cm->fc.ext_tx_prob[supertx_size],
+                        &GET_EXT_TX_ENCODINGS(supertx_size)
+                            [xd->mi[0].mbmi.ext_txfrm]);
+#else
       if (supertx_size <= TX_16X16 && !xd->mi[0].mbmi.skip)
         vp9_write_token(w, vp9_ext_tx_tree, cm->fc.ext_tx_prob[supertx_size],
                         &ext_tx_encodings[xd->mi[0].mbmi.ext_txfrm]);
-#endif
+#endif  // CONFIG_WAVELETS
+#endif  // CONFIG_EXT_TX
     }
   }
 #endif  // CONFIG_SUPERTX
index 0565ce78ce3d9c9d5f8be141a21120e7e543021e..a095867fb64482ddd973db2a68b789b547359f7e 100644 (file)
@@ -71,7 +71,7 @@ static void analysis_53_col(int length, tran_low_t *x,
 }
 
 static void dyadic_analyze_53(int levels, int width, int height,
-                              int16_t *x, int pitch_x,
+                              const int16_t *x, int pitch_x,
                               tran_low_t *c, int pitch_c,
                               int dwt_scale_bits) {
   int lv, i, j, nh, nw, hh = height, hw = width;
@@ -152,7 +152,7 @@ static void analysis_26_col(int length, tran_low_t *x,
 }
 
 static void dyadic_analyze_26(int levels, int width, int height,
-                              int16_t *x, int pitch_x,
+                              const int16_t *x, int pitch_x,
                               tran_low_t *c, int pitch_c,
                               int dwt_scale_bits) {
   int lv, i, j, nh, nw, hh = height, hw = width;
@@ -221,7 +221,7 @@ static void analysis_97(int length, double *x,
 }
 
 static void dyadic_analyze_97(int levels, int width, int height,
-                              int16_t *x, int pitch_x,
+                              const int16_t *x, int pitch_x,
                               tran_low_t *c, int pitch_c,
                               int dwt_scale_bits) {
   int lv, i, j, nh, nw, hh = height, hw = width;
@@ -258,7 +258,7 @@ static void dyadic_analyze_97(int levels, int width, int height,
   }
 }
 
-void vp9_fdwt32x32_c(tran_low_t *input, tran_low_t *output, int stride) {
+void vp9_fdwt32x32_c(const int16_t *input, tran_low_t *output, int stride) {
 #if DWT_TYPE == 26
   dyadic_analyze_26(4, 32, 32, input, stride, output, 32, 2);
 #elif DWT_TYPE == 97
@@ -268,11 +268,11 @@ void vp9_fdwt32x32_c(tran_low_t *input, tran_low_t *output, int stride) {
 #endif
 }
 
-void vp9_fdwtdct32x32_c(tran_low_t *input, tran_low_t *output,
+void vp9_fdwtdct32x32_c(const int16_t *input, tran_low_t *output,
                         int stride) {
   const int dwt_levels = 1;
   tran_low_t buffer[16 * 16];
-  int i, j;
+  int i;
   // Scales up by 2-bit from unitary
 #if DWT_TYPE == 26
   dyadic_analyze_26(dwt_levels, 32, 32, input, stride, output, 32, 2);
@@ -290,7 +290,7 @@ void vp9_fdwtdct32x32_c(tran_low_t *input, tran_low_t *output,
 }
 
 #if CONFIG_TX64X64
-void vp9_fdwt64x64_c(tran_low_t *input, tran_low_t *output, int stride) {
+void vp9_fdwt64x64_c(const int16_t *input, tran_low_t *output, int stride) {
 #if DWT_TYPE == 26
   dyadic_analyze_26(4, 64, 64, input, stride, output, 64, 1);
 #elif DWT_TYPE == 97
@@ -300,8 +300,7 @@ void vp9_fdwt64x64_c(tran_low_t *input, tran_low_t *output, int stride) {
 #endif
 }
 
-void vp9_fdwtdct64x64_c(tran_low_t *input, tran_low_t *output,
-                        int stride) {
+void vp9_fdwtdct64x64_c(const int16_t *input, tran_low_t *output, int stride) {
   const int dwt_levels = 1;
   tran_low_t buffer[32 * 32];
   int i;
index 9fbddf0f80b4a4af48c07f753e179152e72fa08f..cf27c4eeeeb79a483b3f0774e47758de85f87858 100644 (file)
 extern "C" {
 #endif
 
-#if CONFIG_TX64X64
-void vp9_fdwt64x64(tran_low_t *input, tran_low_t *output, int stride);
-void vp9_fdwtdct64x64(tran_low_t *input, tran_low_t *output, int stride);
-#endif  // CONFIG_TX64X64
-void vp9_fdwt32x32(tran_low_t *input, tran_low_t *output, int stride);
-void vp9_fdwtdct32x32(tran_low_t *input, tran_low_t *output, int stride);
-
 #ifdef __cplusplus
 }  // extern "C"
 #endif
index 602996a07ba9f02b0199e43ee7a8bc1e195ecaf0..5e85a177c8194a388c20ea067979284bd410c647 100644 (file)
@@ -1764,9 +1764,16 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile,
             [partition_supertx_context_lookup[partition]][supertx_size][1]++;
         cm->counts.supertx_size[supertx_size]++;
 #if CONFIG_EXT_TX
-        if (supertx_size < TX_32X32 && !xd->mi[0].mbmi.skip)
-          ++cm->counts.ext_tx[xd->mi[0].mbmi.tx_size][xd->mi[0].mbmi.ext_txfrm];
-#endif
+#if CONFIG_WAVELETS
+        if (!xd->mi[0].mbmi.skip)
+          ++cm->counts.ext_tx[xd->mi[0].mbmi.tx_size]
+                             [xd->mi[0].mbmi.ext_txfrm];
+#else
+        if (supertx_size <= TX_16X16 && !xd->mi[0].mbmi.skip)
+          ++cm->counts.ext_tx[xd->mi[0].mbmi.tx_size]
+                             [xd->mi[0].mbmi.ext_txfrm];
+#endif  // CONFIG_WAVELETS
+#endif  // CONFIG_EXT_TX
         (*tp)->token = EOSB_TOKEN;
         (*tp)++;
       }
@@ -4638,8 +4645,10 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
             mi_8x8[mis * y + x].src_mi->mbmi.tx_size = tx_size;
     }
 #if CONFIG_EXT_TX
-    if (mbmi->tx_size < TX_32X32 &&
-        is_inter_block(mbmi) &&
+    if (is_inter_block(mbmi) &&
+#if !CONFIG_WAVELETS
+        mbmi->tx_size <= TX_16X16 &&
+#endif
         cm->base_qindex > 0 &&
         bsize >= BLOCK_8X8 &&
         !mbmi->skip &&
@@ -5789,10 +5798,7 @@ static void rd_supertx_sb(VP9_COMP *cpi, const TileInfo *const tile,
   tx_size = bsize_to_tx_size(bsize);
   vp9_subtract_plane(x, bsize, 0);
 #if CONFIG_EXT_TX
-  for (txfm = NORM; txfm < EXT_TX_TYPES; txfm++) {
-    if (tx_size > TX_16X16 && txfm != NORM)
-      continue;
-
+  for (txfm = NORM; txfm < GET_EXT_TX_TYPES(tx_size); txfm++) {
     xd->mi[0].mbmi.ext_txfrm = txfm;
 #endif  // CONFIG_EXT_TX
     txfm_rd_in_plane_supertx(x, &this_rate, &this_dist, &pnskip, &pnsse,
@@ -5807,7 +5813,9 @@ static void rd_supertx_sb(VP9_COMP *cpi, const TileInfo *const tile,
       x->skip = 1;
     } else {
 #if CONFIG_EXT_TX
-      if (tx_size < TX_32X32)
+#if !CONFIG_WAVELETS
+      if (tx_size <= TX_16X16)
+#endif
         *tmp_rate += cpi->ext_tx_costs[tx_size][txfm];
 #endif  // CONFIG_EXT_TX
       if (RDCOST(x->rdmult, x->rddiv, *tmp_rate, *tmp_dist)
index 1f537e673a1a2e397cb76d1c19eea72a11fd621d..dbae40e2027e3f8c832b4e89ce78aaba3000ba11 100644 (file)
@@ -23,6 +23,9 @@
 #include "vp9/encoder/vp9_quantize.h"
 #include "vp9/encoder/vp9_rd.h"
 #include "vp9/encoder/vp9_tokenize.h"
+#if CONFIG_WAVELETS
+#include "vp9/encoder/vp9_dwt.h"
+#endif
 
 struct optimize_ctx {
   ENTROPY_CONTEXT ta[MAX_MB_PLANE][16];
@@ -573,6 +576,34 @@ static void copy_fliplrud(const int16_t *src, int src_stride, int l,
   fliplrud(dest, dest_stride, l);
 }
 
+#if CONFIG_WAVELETS
+static void forw_tx32x32(MACROBLOCK *x, int plane,
+                         const int16_t *src_diff, int diff_stride,
+                         tran_low_t *const coeff) {
+  MACROBLOCKD *const xd = &x->e_mbd;
+  TX_TYPE tx_type = get_tx_type_large(plane, xd);
+  if (tx_type == WAVELET1_DCT_DCT) {
+    vp9_fdwtdct32x32(src_diff, coeff, diff_stride);
+  } else {
+    fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
+  }
+}
+
+#if CONFIG_TX64X64
+static void forw_tx64x64(MACROBLOCK *x, int plane,
+                         const int16_t *src_diff, int diff_stride,
+                         tran_low_t *const coeff) {
+  MACROBLOCKD *const xd = &x->e_mbd;
+  TX_TYPE tx_type = get_tx_type_large(plane, xd);
+  if (tx_type == WAVELET1_DCT_DCT) {
+    vp9_fdwtdct64x64(src_diff, coeff, diff_stride);
+  } else {
+    vp9_fdct64x64(src_diff, coeff, diff_stride);
+  }
+}
+#endif  // CONFIG_TX64X64
+#endif  // CONFIG_WAVELETS
+
 static void forw_tx16x16(MACROBLOCK *x, int plane,
                          const int16_t *src_diff, int diff_stride,
                          tran_low_t *const coeff) {
@@ -925,7 +956,11 @@ void vp9_xform_quant_nuq(MACROBLOCK *x, int plane, int block,
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx64x64(x, plane, src_diff, diff_stride, coeff);
+#else
       vp9_fdct64x64(src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_64x64_nuq(coeff, 4096, x->skip_block,
                              p->quant, p->quant_shift, pd->dequant,
                              (const cumbins_type_nuq *)p->cumbins_nuq,
@@ -935,7 +970,11 @@ void vp9_xform_quant_nuq(MACROBLOCK *x, int plane, int block,
       break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx32x32(x, plane, src_diff, diff_stride, coeff);
+#else
       fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_32x32_nuq(coeff, 1024, x->skip_block,
                              p->quant, p->quant_shift, pd->dequant,
                              (const cumbins_type_nuq *)p->cumbins_nuq,
@@ -1165,7 +1204,11 @@ void vp9_xform_quant_fp_nuq(MACROBLOCK *x, int plane, int block,
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx64x64(x, plane, src_diff, diff_stride, coeff);
+#else
       vp9_fdct64x64(src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_64x64_fp_nuq(coeff, 4096, x->skip_block,
                                 p->quant_fp, pd->dequant,
                                 (const cumbins_type_nuq *)p->cumbins_nuq,
@@ -1176,7 +1219,11 @@ void vp9_xform_quant_fp_nuq(MACROBLOCK *x, int plane, int block,
       break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx32x32(x, plane, src_diff, diff_stride, coeff);
+#else
       fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_32x32_fp_nuq(coeff, 1024, x->skip_block,
                                 p->quant_fp, pd->dequant,
                                 (const cumbins_type_nuq *)p->cumbins_nuq,
@@ -1384,7 +1431,11 @@ void vp9_xform_quant_dc_nuq(MACROBLOCK *x, int plane, int block,
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx64x64(x, plane, src_diff, diff_stride, coeff);
+#else
       vp9_fdct64x64_1(src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_dc_64x64_nuq(coeff, x->skip_block,
                                 p->quant[0], p->quant_shift[0], pd->dequant[0],
                                 p->cumbins_nuq[0], pd->dequant_val_nuq[0],
@@ -1392,7 +1443,11 @@ void vp9_xform_quant_dc_nuq(MACROBLOCK *x, int plane, int block,
       break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx32x32(x, plane, src_diff, diff_stride, coeff);
+#else
       vp9_fdct32x32_1(src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_dc_32x32_nuq(coeff, x->skip_block,
                                 p->quant[0], p->quant_shift[0], pd->dequant[0],
                                 p->cumbins_nuq[0], pd->dequant_val_nuq[0],
@@ -1584,7 +1639,11 @@ void vp9_xform_quant_dc_fp_nuq(MACROBLOCK *x, int plane, int block,
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx64x64(x, plane, src_diff, diff_stride, coeff);
+#else
       vp9_fdct64x64_1(src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_dc_64x64_fp_nuq(coeff, x->skip_block,
                                    p->quant_fp[0], pd->dequant[0],
                                    p->cumbins_nuq[0], pd->dequant_val_nuq[0],
@@ -1592,7 +1651,11 @@ void vp9_xform_quant_dc_fp_nuq(MACROBLOCK *x, int plane, int block,
       break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx32x32(x, plane, src_diff, diff_stride, coeff);
+#else
       vp9_fdct32x32_1(src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_dc_32x32_fp_nuq(coeff, x->skip_block,
                                    p->quant_fp[0], pd->dequant[0],
                                    p->cumbins_nuq[0], pd->dequant_val_nuq[0],
@@ -1784,7 +1847,11 @@ void vp9_xform_quant_fp(MACROBLOCK *x, int plane, int block,
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx64x64(x, plane, src_diff, diff_stride, coeff);
+#else
       vp9_fdct64x64(src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_fp_64x64(coeff, 4096, x->skip_block, p->zbin, p->round_fp,
                             p->quant_fp, p->quant_shift, qcoeff, dqcoeff,
                             pd->dequant, eob, scan_order->scan,
@@ -1792,7 +1859,11 @@ void vp9_xform_quant_fp(MACROBLOCK *x, int plane, int block,
       break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx32x32(x, plane, src_diff, diff_stride, coeff);
+#else
       fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_fp_32x32(coeff, 1024, x->skip_block, p->zbin,
                             p->round_fp, p->quant_fp, p->quant_shift,
                             qcoeff, dqcoeff, pd->dequant, eob,
@@ -1963,14 +2034,22 @@ void vp9_xform_quant_dc(MACROBLOCK *x, int plane, int block,
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx64x64(x, plane, src_diff, diff_stride, coeff);
+#else
       vp9_fdct64x64_1(src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_dc_64x64(coeff, x->skip_block, p->round,
                             p->quant_fp[0], qcoeff, dqcoeff,
                             pd->dequant[0], eob);
       break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx32x32(x, plane, src_diff, diff_stride, coeff);
+#else
       vp9_fdct32x32_1(src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_dc_32x32(coeff, x->skip_block, p->round,
                             p->quant_fp[0], qcoeff, dqcoeff,
                             pd->dequant[0], eob);
@@ -2154,7 +2233,11 @@ void vp9_xform_quant(MACROBLOCK *x, int plane, int block,
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx64x64(x, plane, src_diff, diff_stride, coeff);
+#else
       vp9_fdct64x64(src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_b_64x64(coeff, 4096, x->skip_block, p->zbin, p->round,
                            p->quant, p->quant_shift, qcoeff, dqcoeff,
                            pd->dequant, eob, scan_order->scan,
@@ -2162,7 +2245,11 @@ void vp9_xform_quant(MACROBLOCK *x, int plane, int block,
       break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      forw_tx32x32(x, plane, src_diff, diff_stride, coeff);
+#else
       fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
+#endif
       vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round,
                            p->quant, p->quant_shift, qcoeff, dqcoeff,
                            pd->dequant, eob, scan_order->scan,
@@ -2380,10 +2467,22 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize,
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      tx_type = get_tx_type_large(plane, xd);
+      if (tx_type == WAVELET1_DCT_DCT)
+        vp9_idwtdct64x64_add(dqcoeff, dst, pd->dst.stride);
+      else
+#endif  // CONFIG_EXT_TX && CONFIG_WAVELETS
       vp9_idct64x64_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
       break;
-#endif
+#endif  // CONFIG_TX64X64
     case TX_32X32:
+#if CONFIG_EXT_TX && CONFIG_WAVELETS
+      tx_type = get_tx_type_large(plane, xd);
+      if (tx_type == WAVELET1_DCT_DCT)
+        vp9_idwtdct32x32_add(dqcoeff, dst, pd->dst.stride);
+      else
+#endif  // CONFIG_EXT_TX && CONFIG_WAVELETS
       vp9_idct32x32_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
       break;
     case TX_16X16:
@@ -3194,7 +3293,7 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
         break;
       case TX_16X16:
         tx_type = get_tx_type(pd->plane_type, xd);
-        scan_order = &vp9_scan_orders[TX_16X16][tx_type];
+        scan_order = &vp9_intra_scan_orders[TX_16X16][tx_type];
         mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
         vp9_predict_intra_block(xd, block >> 4, bwl, TX_16X16, mode,
 #if CONFIG_FILTERINTRA
@@ -3238,7 +3337,7 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
         break;
       case TX_8X8:
         tx_type = get_tx_type(pd->plane_type, xd);
-        scan_order = &vp9_scan_orders[TX_8X8][tx_type];
+        scan_order = &vp9_intra_scan_orders[TX_8X8][tx_type];
         mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
         vp9_predict_intra_block(xd, block >> 2, bwl, TX_8X8, mode,
 #if CONFIG_FILTERINTRA
@@ -3282,7 +3381,7 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
         break;
       case TX_4X4:
         tx_type = get_tx_type_4x4(pd->plane_type, xd, block);
-        scan_order = &vp9_scan_orders[TX_4X4][tx_type];
+        scan_order = &vp9_intra_scan_orders[TX_4X4][tx_type];
         mode = plane == 0 ? get_y_mode(xd->mi[0].src_mi, block) : mbmi->uv_mode;
         vp9_predict_intra_block(xd, block, bwl, TX_4X4, mode,
 #if CONFIG_FILTERINTRA
@@ -3433,7 +3532,7 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
       break;
     case TX_16X16:
       tx_type = get_tx_type(pd->plane_type, xd);
-      scan_order = &vp9_scan_orders[TX_16X16][tx_type];
+      scan_order = &vp9_intra_scan_orders[TX_16X16][tx_type];
       mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
       vp9_predict_intra_block(xd, block >> 4, bwl, TX_16X16, mode,
 #if CONFIG_FILTERINTRA
@@ -3473,7 +3572,7 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
       break;
     case TX_8X8:
       tx_type = get_tx_type(pd->plane_type, xd);
-      scan_order = &vp9_scan_orders[TX_8X8][tx_type];
+      scan_order = &vp9_intra_scan_orders[TX_8X8][tx_type];
       mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
       vp9_predict_intra_block(xd, block >> 2, bwl, TX_8X8, mode,
 #if CONFIG_FILTERINTRA
@@ -3513,7 +3612,7 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
       break;
     case TX_4X4:
       tx_type = get_tx_type_4x4(pd->plane_type, xd, block);
-      scan_order = &vp9_scan_orders[TX_4X4][tx_type];
+      scan_order = &vp9_intra_scan_orders[TX_4X4][tx_type];
       mode = plane == 0 ? get_y_mode(xd->mi[0].src_mi, block) : mbmi->uv_mode;
       vp9_predict_intra_block(xd, block, bwl, TX_4X4, mode,
 #if CONFIG_FILTERINTRA
index 6c9e118a5a2a86ed3544fe431d0c06efe3d36b87..faab05041aa76218e737b9404e35ac2271c48f2f 100644 (file)
@@ -519,7 +519,6 @@ void vp9_alloc_compressor_data(VP9_COMP *cpi) {
     unsigned int tokens = get_token_alloc(cm->mb_rows, cm->mb_cols);
     CHECK_MEM_ERROR(cm, cpi->tok, vpx_calloc(tokens, sizeof(*cpi->tok)));
   }
-
   vp9_setup_pc_tree(&cpi->common, cpi);
 }
 
index 2dd60c87ab00c64ed1bbbf218bbccfb5a1841a68..634a1428808dc130e9080b5baa6cd2a2df13db7c 100644 (file)
@@ -393,7 +393,11 @@ typedef struct VP9_COMP {
   int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES];
   int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
 #if CONFIG_EXT_TX
+#if CONFIG_WAVELETS
+  int ext_tx_costs[TX_SIZES][EXT_TX_TYPES];
+#else
   int ext_tx_costs[3][EXT_TX_TYPES];
+#endif  // CONFIG_WAVELETS
 #endif  // CONFIG_EXT_TX
 #if CONFIG_COPY_MODE
   int copy_mode_cost_l2[COPY_MODE_CONTEXTS][2];
index 198b688229d447871284f8ccaf5e28a3b1dbc7bf..4a5980ac43c0413692d729e2c519ca45e481badd 100644 (file)
@@ -85,6 +85,11 @@ static void fill_mode_costs(VP9_COMP *cpi) {
 #if CONFIG_EXT_TX
   for (i = TX_4X4; i <= TX_16X16; ++i)
     vp9_cost_tokens(cpi->ext_tx_costs[i], fc->ext_tx_prob[i], vp9_ext_tx_tree);
+#if CONFIG_WAVELETS
+  for (; i < TX_SIZES; ++i)
+    vp9_cost_tokens(cpi->ext_tx_costs[i], fc->ext_tx_prob[i],
+                    vp9_ext_tx_large_tree);
+#endif  // CONFIG_WAVELETS
 #endif  // CONFIG_EXT_TX
 #if CONFIG_PALETTE
   for (i = 0; i < PALETTE_MAX_SIZE - 1; ++i)
index e607d860a948723019bc28115fd7bff6b8767080..94ddda000b97f8be350cb0c84e42116e1a95a982 100644 (file)
@@ -875,11 +875,24 @@ static void choose_largest_tx_size(VP9_COMP *cpi, MACROBLOCK *x,
 
   mbmi->tx_size = MIN(max_tx_size, largest_tx_size);
 
+#if CONFIG_EXT_TX
+  if (mbmi->ext_txfrm >= GET_EXT_TX_TYPES(mbmi->tx_size)) {
+    *rate = INT_MAX;
+    *distortion = INT64_MAX;
+    *sse = INT64_MAX;
+    *skip = 0;
+    return;
+  }
+#endif  // CONFIG_EXT_TX
+
   txfm_rd_in_plane(x, rate, distortion, skip,
                    sse, ref_best_rd, 0, bs,
                    mbmi->tx_size, cpi->sf.use_fast_coef_costing);
 #if CONFIG_EXT_TX
-  if (is_inter_block(mbmi) && mbmi->tx_size < TX_32X32 && bs >= BLOCK_8X8 &&
+  if (is_inter_block(mbmi) && bs >= BLOCK_8X8 &&
+#if !CONFIG_WAVELETS
+      mbmi->tx_size <= TX_16X16 &&
+#endif
       !xd->lossless && *rate != INT_MAX)
     *rate += cpi->ext_tx_costs[mbmi->tx_size][mbmi->ext_txfrm];
 #endif
@@ -921,14 +934,24 @@ static void choose_tx_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x,
   s1 = vp9_cost_bit(skip_prob, 1);
 
   for (n = max_tx_size; n >= 0;  n--) {
-    txfm_rd_in_plane(x, &r[n][0], &d[n], &s[n],
-                     &sse[n], ref_best_rd, 0, bs, n,
-                     cpi->sf.use_fast_coef_costing);
 #if CONFIG_EXT_TX
-    if (is_inter_block(mbmi) && n < TX_32X32 && bs >= BLOCK_8X8 &&
+    if (mbmi->ext_txfrm >= GET_EXT_TX_TYPES(n)) {
+      r[n][0] = r[n][1] = INT_MAX;
+      d[n] = INT64_MAX;
+    } else {
+#endif  // CONFIG_EXT_TX
+      txfm_rd_in_plane(x, &r[n][0], &d[n], &s[n],
+                       &sse[n], ref_best_rd, 0, bs, n,
+                       cpi->sf.use_fast_coef_costing);
+#if CONFIG_EXT_TX
+    }
+    if (is_inter_block(mbmi) && bs >= BLOCK_8X8 &&
+#if !CONFIG_WAVELETS
+        n <= TX_16X16 &&
+#endif
         !xd->lossless && r[n][0] != INT_MAX)
       r[n][0] += cpi->ext_tx_costs[n][mbmi->ext_txfrm];
-#endif
+#endif  // CONFIG_EXT_TX
     r[n][1] = r[n][0];
     if (r[n][0] < INT_MAX) {
       for (m = 0; m <= n - (n == (int) max_tx_size); m++) {
@@ -1172,7 +1195,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib,
           } else {
             int64_t unused;
             const TX_TYPE tx_type = get_tx_type_4x4(PLANE_TYPE_Y, xd, block);
-            const scan_order *so = &vp9_scan_orders[TX_4X4][tx_type];
+            const scan_order *so = &vp9_intra_scan_orders[TX_4X4][tx_type];
             vp9_highbd_fht4x4(src_diff, coeff, 8, tx_type);
             vp9_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
             ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
@@ -1305,7 +1328,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib,
         } else {
           int64_t unused;
           const TX_TYPE tx_type = get_tx_type_4x4(PLANE_TYPE_Y, xd, block);
-          const scan_order *so = &vp9_scan_orders[TX_4X4][tx_type];
+          const scan_order *so = &vp9_intra_scan_orders[TX_4X4][tx_type];
           vp9_fht4x4(src_diff, coeff, 8, tx_type);
           vp9_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
           ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
@@ -5429,7 +5452,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
       int64_t best_rdcost_tx = INT64_MAX;
       int best_ext_tx = NORM;
 
-      for (i = 0; i < EXT_TX_TYPES; i++) {
+      for (i = NORM; i < EXT_TX_TYPES; i++) {
         mbmi->ext_txfrm = i;
         super_block_yrd(cpi, x, &rate_y_tx, &distortion_y_tx, &dummy, psse,
                         bsize, txfm_cache, INT64_MAX);
@@ -5443,12 +5466,13 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
           best_rdcost_tx = rdcost_tx;
         }
       }
-      if (mbmi->tx_size >= TX_32X32)
-        mbmi->ext_txfrm = NORM;
-      else
-        mbmi->ext_txfrm = best_ext_tx;
+#if !CONFIG_WAVELETS
+      if (mbmi->tx_size > TX_16X16)
+        assert(best_ext_tx == NORM);
+#endif  // !CONFIG_WAVELETS
+      mbmi->ext_txfrm = best_ext_tx;
     }
-#endif
+#endif  // CONFIG_EXT_TX
 
     // Y cost and distortion
     super_block_yrd(cpi, x, rate_y, &distortion_y, &skippable_y, psse,
@@ -7236,9 +7260,11 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
     if (bestrd_tx == INT64_MAX)
       continue;
 
+#if !CONFIG_WAVELETS
     if (best_tx_size < TX_32X32)
       mbmi->ext_txfrm = best_tx_type;
     else
+#endif  // !CONFIG_WAVELETS
       mbmi->ext_txfrm = NORM;
     mbmi->tx_size = best_tx_size;
     vpx_memcpy(x->zcoeff_blk[mbmi->tx_size], tmp_zcoeff_blk,